|
| 1 | +--- |
| 2 | +layout: "" |
| 3 | +page_title: Resource - terraform-provider-dynatrace" |
| 4 | +subcategory: "Grail" |
| 5 | +description: |- |
| 6 | + The resource `dynatrace_segment` covers configuration of segments to logically structure and conveniently filter observability data across apps on the Dynatrace platform |
| 7 | +--- |
| 8 | + |
| 9 | +# dynatrace_segment (Resource) |
| 10 | + |
| 11 | +-> **Dynatrace SaaS only** |
| 12 | + |
| 13 | +-> To utilize this resource with access to all segments, please define the environment variables `DT_CLIENT_ID`, `DT_CLIENT_SECRET`, `DT_ACCOUNT_ID` with an OAuth client including the following permissions: **View Filter-Segments** (`storage:filter-segments:read`), **Create and Update Filter-Segments** (`storage:filter-segments:write`), **Share Filter-Segments** (`storage:filter-segments:share`), **Delete Filter-Segments** (`storage:filter-segments:delete`) and **Maintain all Filter-Segments on the environment** (`storage:filter-segments:admin`). |
| 14 | + |
| 15 | +-> This resource is excluded by default in the export utility, please explicitly specify the resource to retrieve existing configuration. |
| 16 | + |
| 17 | +-> The `includes.items[X].filter` attribute, which is a JSON string, is unfriendly for configuration as code. The structure of that attribute is not publicly documented and therefore subject to change without warning. The resource schema has been created to match our REST API, but we will be reaching out to product management on further enhancement of this endpoint. In the meantime, please use the export utility to create configurations more efficiently. |
| 18 | + |
| 19 | +## Dynatrace Documentation |
| 20 | + |
| 21 | +- Segments - https://docs.dynatrace.com/docs/manage/segments |
| 22 | + |
| 23 | +- Grail Storage Filter-Segments (API) - https://########.apps.dynatrace.com/platform/swagger-ui/index.html?urls.primaryName=Grail+-+Filter+Segments |
| 24 | + |
| 25 | +## Resource Example Usage |
| 26 | + |
| 27 | +```terraform |
| 28 | +# ID GQ7NqJGPV1N |
| 29 | +resource "dynatrace_segment" "#name#" { |
| 30 | + name = "#name#" |
| 31 | + description = "Example description" |
| 32 | + is_public = true |
| 33 | + includes { |
| 34 | + items { |
| 35 | + data_object = "_all_data_object" |
| 36 | + filter = jsonencode({ |
| 37 | + "children": [ |
| 38 | + { |
| 39 | + "key": { |
| 40 | + "range": { |
| 41 | + "from": 0, |
| 42 | + "to": 16 |
| 43 | + }, |
| 44 | + "textValue": "k8s.cluster.name", |
| 45 | + "type": "Key", |
| 46 | + "value": "k8s.cluster.name" |
| 47 | + }, |
| 48 | + "operator": { |
| 49 | + "range": { |
| 50 | + "from": 17, |
| 51 | + "to": 18 |
| 52 | + }, |
| 53 | + "textValue": "=", |
| 54 | + "type": "ComparisonOperator", |
| 55 | + "value": "=" |
| 56 | + }, |
| 57 | + "range": { |
| 58 | + "from": 0, |
| 59 | + "to": 27 |
| 60 | + }, |
| 61 | + "type": "Statement", |
| 62 | + "value": { |
| 63 | + "range": { |
| 64 | + "from": 19, |
| 65 | + "to": 27 |
| 66 | + }, |
| 67 | + "textValue": "$cluster", |
| 68 | + "type": "String", |
| 69 | + "value": "$cluster" |
| 70 | + } |
| 71 | + } |
| 72 | + ], |
| 73 | + "explicit": false, |
| 74 | + "logicalOperator": "AND", |
| 75 | + "range": { |
| 76 | + "from": 0, |
| 77 | + "to": 27 |
| 78 | + }, |
| 79 | + "type": "Group" |
| 80 | + }) |
| 81 | + } |
| 82 | + items { |
| 83 | + data_object = "dt.entity.cloud_application" |
| 84 | + filter = "" |
| 85 | + relationship { |
| 86 | + name = "clustered_by" |
| 87 | + target = "dt.entity.kubernetes_cluster" |
| 88 | + } |
| 89 | + } |
| 90 | + items { |
| 91 | + data_object = "dt.entity.cloud_application_instance" |
| 92 | + filter = "" |
| 93 | + relationship { |
| 94 | + name = "clustered_by" |
| 95 | + target = "dt.entity.kubernetes_cluster" |
| 96 | + } |
| 97 | + } |
| 98 | + items { |
| 99 | + data_object = "dt.entity.cloud_application_namespace" |
| 100 | + filter = "" |
| 101 | + relationship { |
| 102 | + name = "clustered_by" |
| 103 | + target = "dt.entity.kubernetes_cluster" |
| 104 | + } |
| 105 | + } |
| 106 | + items { |
| 107 | + data_object = "dt.entity.container_group_instance" |
| 108 | + filter = "" |
| 109 | + relationship { |
| 110 | + name = "belongs_to" |
| 111 | + target = "dt.entity.kubernetes_cluster" |
| 112 | + } |
| 113 | + } |
| 114 | + items { |
| 115 | + data_object = "dt.entity.host" |
| 116 | + filter = "" |
| 117 | + relationship { |
| 118 | + name = "clustered_by" |
| 119 | + target = "dt.entity.kubernetes_cluster" |
| 120 | + } |
| 121 | + } |
| 122 | + items { |
| 123 | + data_object = "dt.entity.kubernetes_cluster" |
| 124 | + filter = jsonencode({ |
| 125 | + "children": [ |
| 126 | + { |
| 127 | + "key": { |
| 128 | + "range": { |
| 129 | + "from": 0, |
| 130 | + "to": 11 |
| 131 | + }, |
| 132 | + "textValue": "entity.name", |
| 133 | + "type": "Key", |
| 134 | + "value": "entity.name" |
| 135 | + }, |
| 136 | + "operator": { |
| 137 | + "range": { |
| 138 | + "from": 12, |
| 139 | + "to": 13 |
| 140 | + }, |
| 141 | + "textValue": "=", |
| 142 | + "type": "ComparisonOperator", |
| 143 | + "value": "=" |
| 144 | + }, |
| 145 | + "range": { |
| 146 | + "from": 0, |
| 147 | + "to": 22 |
| 148 | + }, |
| 149 | + "type": "Statement", |
| 150 | + "value": { |
| 151 | + "range": { |
| 152 | + "from": 14, |
| 153 | + "to": 22 |
| 154 | + }, |
| 155 | + "textValue": "$cluster", |
| 156 | + "type": "String", |
| 157 | + "value": "$cluster" |
| 158 | + } |
| 159 | + } |
| 160 | + ], |
| 161 | + "explicit": false, |
| 162 | + "logicalOperator": "AND", |
| 163 | + "range": { |
| 164 | + "from": 0, |
| 165 | + "to": 22 |
| 166 | + }, |
| 167 | + "type": "Group" |
| 168 | + }) |
| 169 | + } |
| 170 | + items { |
| 171 | + data_object = "dt.entity.kubernetes_node" |
| 172 | + filter = "" |
| 173 | + relationship { |
| 174 | + name = "clustered_by" |
| 175 | + target = "dt.entity.kubernetes_cluster" |
| 176 | + } |
| 177 | + } |
| 178 | + items { |
| 179 | + data_object = "dt.entity.kubernetes_service" |
| 180 | + filter = "" |
| 181 | + relationship { |
| 182 | + name = "clustered_by" |
| 183 | + target = "dt.entity.kubernetes_cluster" |
| 184 | + } |
| 185 | + } |
| 186 | + items { |
| 187 | + data_object = "dt.entity.service" |
| 188 | + filter = "" |
| 189 | + relationship { |
| 190 | + name = "clustered_by" |
| 191 | + target = "dt.entity.kubernetes_cluster" |
| 192 | + } |
| 193 | + } |
| 194 | + } |
| 195 | + variables { |
| 196 | + type = "query" |
| 197 | + value =<<-EOT |
| 198 | + fetch dt.entity.kubernetes_cluster |
| 199 | + | fields cluster = entity.name |
| 200 | + | sort cluster |
| 201 | + EOT |
| 202 | + } |
| 203 | +} |
| 204 | +``` |
| 205 | + |
| 206 | + |
| 207 | +<!-- schema generated by tfplugindocs --> |
| 208 | +## Schema |
| 209 | + |
| 210 | +### Required |
| 211 | + |
| 212 | +- `is_public` (Boolean) Indicates if the filter-segment is publicly accessible within the tenant |
| 213 | +- `name` (String) Name of the filter-segment |
| 214 | + |
| 215 | +### Optional |
| 216 | + |
| 217 | +- `description` (String) Description of the filter-segment |
| 218 | +- `includes` (Block List, Max: 1) List of includes of the filter-segment (see [below for nested schema](#nestedblock--includes)) |
| 219 | +- `variables` (Block List, Max: 1) Variables of the filter-segment (see [below for nested schema](#nestedblock--variables)) |
| 220 | + |
| 221 | +### Read-Only |
| 222 | + |
| 223 | +- `id` (String) The ID of this resource. |
| 224 | + |
| 225 | +<a id="nestedblock--includes"></a> |
| 226 | +### Nested Schema for `includes` |
| 227 | + |
| 228 | +Optional: |
| 229 | + |
| 230 | +- `items` (Block Set, Max: 20) TODO: No documentation available (see [below for nested schema](#nestedblock--includes--items)) |
| 231 | + |
| 232 | +<a id="nestedblock--includes--items"></a> |
| 233 | +### Nested Schema for `includes.items` |
| 234 | + |
| 235 | +Required: |
| 236 | + |
| 237 | +- `data_object` (String) The data object that the filter will be applied to. Use '_all_data_object' to apply it to all dataObjects |
| 238 | +- `filter` (String) Data will be filtered by this value |
| 239 | + |
| 240 | +Optional: |
| 241 | + |
| 242 | +- `apply_to` (Set of String) [Experimental] The tables that the entity-filter will be applied to` |
| 243 | +- `relationship` (Block List, Max: 1) [Experimental] The relationship of an include which has to be be specified when the data object is an entity view (see [below for nested schema](#nestedblock--includes--items--relationship)) |
| 244 | + |
| 245 | +<a id="nestedblock--includes--items--relationship"></a> |
| 246 | +### Nested Schema for `includes.items.relationship` |
| 247 | + |
| 248 | +Required: |
| 249 | + |
| 250 | +- `name` (String) Name of the relationship |
| 251 | +- `target` (String) Target of the relationship |
| 252 | + |
| 253 | + |
| 254 | + |
| 255 | + |
| 256 | +<a id="nestedblock--variables"></a> |
| 257 | +### Nested Schema for `variables` |
| 258 | + |
| 259 | +Required: |
| 260 | + |
| 261 | +- `type` (String) Type of the variable |
| 262 | +- `value` (String) Value of the variable |
0 commit comments