|
| 1 | +--- |
| 2 | +layout: "" |
| 3 | +page_title: dynatrace_kubernetes_enrichment Resource - terraform-provider-dynatrace" |
| 4 | +subcategory: "Cloud Platforms" |
| 5 | +description: |- |
| 6 | + The resource `dynatrace_kubernetes_enrichment` covers configuration for generic metadata enrichment rules for Kubernetes |
| 7 | +--- |
| 8 | + |
| 9 | +# dynatrace_kubernetes_app (Resource) |
| 10 | + |
| 11 | +-> This resource requires the API token scopes **Read settings** (`settings.read`) and **Write settings** (`settings.write`) |
| 12 | + |
| 13 | +## Dynatrace Documentation |
| 14 | + |
| 15 | +- Kubernetes app - https://docs.dynatrace.com/docs/platform-modules/infrastructure-monitoring/container-platform-monitoring/kubernetes-app |
| 16 | + |
| 17 | +- Settings API - https://www.dynatrace.com/support/help/dynatrace-api/environment-api/settings (schemaId: `builtin:kubernetes.generic.metadata.enrichment`) |
| 18 | + |
| 19 | +## Export Example Usage |
| 20 | + |
| 21 | +- `terraform-provider-dynatrace -export dynatrace_kubernetes_enrichment` downloads all existing generic metadata enrichment rules for Kubernetes |
| 22 | + |
| 23 | +The full documentation of the export feature is available [here](https://dt-url.net/h203qmc). |
| 24 | + |
| 25 | +## Resource Example Usage |
| 26 | + |
| 27 | +```terraform |
| 28 | +resource "dynatrace_kubernetes_enrichment" "#name#" { |
| 29 | + scope = "environment" |
| 30 | + rules { |
| 31 | + rule { |
| 32 | + type = "LABEL" |
| 33 | + enabled = true |
| 34 | + source = "#name#" |
| 35 | + target = "dt.cost.product" |
| 36 | + } |
| 37 | + rule { |
| 38 | + type = "ANNOTATION" |
| 39 | + enabled = true |
| 40 | + source = "#name#" |
| 41 | + target = "dt.security_context" |
| 42 | + } |
| 43 | + } |
| 44 | +} |
| 45 | +``` |
| 46 | + |
| 47 | +<!-- schema generated by tfplugindocs --> |
| 48 | +## Schema |
| 49 | + |
| 50 | +### Optional |
| 51 | + |
| 52 | +- `rules` (Block List, Max: 1) Dynatrace allows to use metadata defined on Kubernetes nodes, namespaces, and pods to set security and cost allocation attributes and dimensions for metrics, events, log, spans, and entities associated with the respective Kubernetes resource. |
| 53 | + |
| 54 | + The following annotation keys are considered: |
| 55 | + * `metadata.dynatrace.com/dt.security_context` |
| 56 | + * `metadata.dynatrace.com/dt.cost.product` |
| 57 | + * `metadata.dynatrace.com/dt.cost.costcenter` |
| 58 | + |
| 59 | + Pod annotations determine the attributes of data associated with the pod itself, and containers belonging to the pod. |
| 60 | + |
| 61 | +Namespace annotations determine the attributes of data associated with the namespace itself, workloads, services, and - if not overwritten on pod level - pods, and containers belonging to the namespace. |
| 62 | + |
| 63 | +Node annotations determine the attributes of data associated with only the node. |
| 64 | + |
| 65 | + Depending on your specific use case and environment, you have the following enrichment options: |
| 66 | + |
| 67 | + **Manual annotation:** |
| 68 | + |
| 69 | + Use the aforementioned annotation keys when annotating your namespaces and pods to enrich your Kubernetes data with security and cost allocation attributes. |
| 70 | + |
| 71 | +With Dynatrace Operator version 1.3.0, the aforementioned namespace annotations are copied down to pods in the namespace, if they are not yet set on the respective pod. |
| 72 | + |
| 73 | + **Rule-based annotation:** |
| 74 | + |
| 75 | +If you already have labels or annotations defined on your namespaces, and you want to reuse them for enrichment, you can do so with the help of rules definable here. |
| 76 | + |
| 77 | +**Example:** |
| 78 | + |
| 79 | + * Namespace label: |
| 80 | + * `label/example: test-value` |
| 81 | + |
| 82 | + * Rule: |
| 83 | + * `Label` |
| 84 | + `label/example --> dt.security_context` |
| 85 | + |
| 86 | + * Pod annotation: |
| 87 | + * `metadata.dynatrace.com/dt.security_context: test-value` |
| 88 | + |
| 89 | +A maximum of 5 rules can be defined. The first applicable rule will be applied. Preexisting annotations will not be overwritten. For a detailed description of this feature, have a look at our [documentation](https://dt-url.net/pn22sye). (see [below for nested schema](#nestedblock--rules)) |
| 90 | +- `scope` (String) The scope of this setting (KUBERNETES_CLUSTER). Omit this property if you want to cover the whole environment. |
| 91 | + |
| 92 | +### Read-Only |
| 93 | + |
| 94 | +- `id` (String) The ID of this resource. |
| 95 | + |
| 96 | +<a id="nestedblock--rules"></a> |
| 97 | +### Nested Schema for `rules` |
| 98 | + |
| 99 | +Required: |
| 100 | + |
| 101 | +- `rule` (Block List, Min: 1) (see [below for nested schema](#nestedblock--rules--rule)) |
| 102 | + |
| 103 | +<a id="nestedblock--rules--rule"></a> |
| 104 | +### Nested Schema for `rules.rule` |
| 105 | + |
| 106 | +Required: |
| 107 | + |
| 108 | +- `enabled` (Boolean) This setting is enabled (`true`) or disabled (`false`) |
| 109 | +- `source` (String) The source must follow the syntax of Kubernetes annotation/label keys as defined in the [Kubernetes documentation](https://dt-url.net/2c02sbn). |
| 110 | + |
| 111 | +`source := (prefix/)?name` |
| 112 | + |
| 113 | +`prefix := [a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*` |
| 114 | + |
| 115 | +`name := ([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9]` |
| 116 | + |
| 117 | +Additionally, the name can have at most 63 characters, and the overall length of the source must not exceed 75 characters. |
| 118 | +- `target` (String) Possible Values: `Dt_cost_costcenter`, `Dt_cost_product`, `Dt_security_context` |
| 119 | +- `type` (String) Possible Values: `ANNOTATION`, `LABEL` |
| 120 | + |
0 commit comments