Create a filter segment in Dynatrace with the Grail Filter Segments API by providing its name, visibility, includes, variables, and optional description.
| POST | SaaS | https://{your-environment-id}.apps.dynatrace.com/v1/filter-segments |
Create a new segment and define data.
Provide a name and an optional description for the filter-segment.
Create variables to apply in your filter-segment data filters
Include all data that should be accessible when applying the filter-segment
false: The filter-segment is private and only visible to the ownertrue: The filter-segment is visible to everyone in the environmentTo execute this request, you need a platform token or OAuth access token with all of the following scopes:
storage:filter-segments:writestorage:filter-segments:share if isPublic is set to trueTo learn how to obtain and use it, see Tokens and authentication.
| Parameter | Type | Description | In | Required |
|---|---|---|---|---|
| body | New | - | body | Required |
NewFilterSegment object| Element | Type | Description | Required |
|---|---|---|---|
| description | string | Description of the filter-segment. | Optional |
| externalId | string | Optional unique identifier of the filter-segment. Used for Dynatrace Configuration as Code | Optional |
| includes | New | List of includes of the filter-segment. | Optional |
| isPublic | boolean | Indicates if the filter-segment is publicly accessible within the tenant. | Required |
| name | string | Name of the filter-segment. | Required |
| variables | Filter | Variables of the filter-segment. | Optional |
NewInclude objectList of includes of the filter-segment.
| Element | Type | Description | Required |
|---|---|---|---|
| applyTo | string[] | [Experimental] The tables that the entity-filter will be applied to. | Optional |
| dataObject | string | The data object that the filter will be applied to. Use '_all_data_object' to apply it to all dataObjects. | Required |
| filter | string | Data will be filtered by this value. Field names must only contain letters, numbers and underscores, otherwise they need to be escaped using quotes(`). | Required |
| relationship | New | [Experimental] The relationship of an include which has to be be specified when the data object is an entity view. | Optional |
NewRelationship object[Experimental] The relationship of an include which has to be be specified when the data object is an entity view.
| Element | Type | Description | Required |
|---|---|---|---|
| name | string | Name of the relationship. | Required |
| target | string | Target of the relationship. | Required |
FilterSegmentVariables objectVariables of the filter-segment.
| Element | Type | Description | Required |
|---|---|---|---|
| type | string | Type of the variable. | Required |
| value | string | Value of the variable. | Required |
This is a model of the request body, showing the possible elements. It has to be adjusted for usage in an actual request.
{"name": "dev_environment","description": "only includes data of the dev environment","variables": {"type": "query","value": "fetch logs | limit 1"},"isPublic": false,"includes": [{"filter": "{\"type\":\"Group\",\"range\":{\"from\":0,\"to\":19},\"logicalOperator\":\"AND\",\"explicit\":false,\"children\":[{\"type\":\"Statement\",\"range\":{\"from\":0,\"to\":19},\"key\":{\"type\":\"Key\",\"textValue\":\"content\",\"value\":\"content\",\"range\":{\"from\":0,\"to\":7}},\"operator\":{\"type\":\"ComparisonOperator\",\"textValue\":\"=\",\"value\":\"=\",\"range\":{\"from\":8,\"to\":9}},\"value\":{\"type\":\"String\",\"textValue\":\"\\\"[debug]\\\"\",\"value\":\"[debug]\",\"range\":{\"from\":10,\"to\":19},\"isEscaped\":true}}]}","dataObject": "logs"},{"filter": "{\"type\":\"Group\",\"range\":{\"from\":0,\"to\":18},\"logicalOperator\":\"AND\",\"explicit\":false,\"children\":[{\"type\":\"Statement\",\"range\":{\"from\":0,\"to\":18},\"key\":{\"type\":\"Key\",\"textValue\":\"content\",\"value\":\"content\",\"range\":{\"from\":0,\"to\":7}},\"operator\":{\"type\":\"ComparisonOperator\",\"textValue\":\"=\",\"value\":\"=\",\"range\":{\"from\":8,\"to\":9}},\"value\":{\"type\":\"String\",\"textValue\":\"\\\"[info]\\\"\",\"value\":\"[info]\",\"range\":{\"from\":10,\"to\":18},\"isEscaped\":true}}]}","dataObject": "events"}]}
| Code | Type | Description |
|---|---|---|
| 201 | Detailed | Filter-segment successfully created. |
| 400 | Error | Filter-segment Bad Request. |
| 401 | Error | unauthorized |
| 403 | Error | missing permissions |
DetailedFilterSegment object| Element | Type | Description |
|---|---|---|
| allowedOperations | string[] | Defines the allowed operations of the current user. The element can hold these values
|
| description | string | Description of the filter-segment. |
| externalId | string | Optional unique identifier of the filter-segment. Used for Dynatrace Configuration as Code |
| includes | Include[] | List of includes of the filter-segment. |
| isPublic | boolean | Indicates if the filter-segment is publicly accessible within the tenant. |
| isReadyMade | boolean | Indicates if the segment is ready-made. |
| name | string | Name of the filter-segment. |
| owner | string | Defines the owner of the filter-segment. |
| uid | string | Unique identifier of the filter-segment. |
| variables | Filter | Variables of the filter-segment. |
| version | integer | Used for optimistic locking. Update requests define with this on which version the data updated is based on. This must match with the version stored, otherwise the update will fail due to concurrent modification. |
Include objectList of includes of the filter-segment.
| Element | Type | Description |
|---|---|---|
| applyTo | string[] | [Experimental] The tables that the entity-filter will be applied to. |
| dataObject | string | The data object that the filter will be applied to. Use '_all_data_object' to apply it to all dataObjects. |
| filter | string | Data will be filtered by this value. Field names must only contain letters, numbers and underscores, otherwise they need to be escaped using quotes(`). |
| relationship | Relationship | [Experimental] The relationship of an include which has to be be specified when the data object is an entity view. |
Relationship object[Experimental] The relationship of an include which has to be be specified when the data object is an entity view.
| Element | Type | Description |
|---|---|---|
| name | string | Name of the relationship. |
| target | string | Target of the relationship. |
FilterSegmentVariables objectVariables of the filter-segment.
| Element | Type | Description |
|---|---|---|
| type | string | Type of the variable. |
| value | string | Value of the variable. |
ErrorEnvelope object| Element | Type | Description |
|---|---|---|
| error | Exceptional | - |
ExceptionalReturn object| Element | Type | Description |
|---|---|---|
| code | integer | - |
| errorDetails | (Custom | - |
| message | string | - |
CustomValidationErrorInfo objectErrorInfo object| Element | Type | Description |
|---|---|---|
| message | string | - |
InvalidAuditEventsErrorInfo objectMediaTypeErrorInfo objectParameterErrorInfo objectProxyErrorInfo objectQueryFrontendRawErrorInfo objectRequestBodyErrorInfo object{"uid": "D82a1jdA23a","name": "dev_environment","description": "only includes data of the dev environment","variables": {"type": "query","value": "fetch logs | limit 1"},"isPublic": false,"owner": "john.doe","includes": [{"filter": "here goes the filter","dataObject": "logs"},{"filter": "here goes another filter","dataObject": "events"}],"version": 1}
{"error": {"code": 400,"message": "Missing request header","errorDetails": [{"type": "parameter","parameterDescriptor": "Dt-Tenant","message": "is required"}]}}