Skip to main content

Grail filter segments API

  • Reference

Filter-Segment Management for Grail.

Slice, dice and contextualize your data to make it easier to find, understand and work with.

Latest (V2)
npm install @dynatrace-sdk/client-filter-segment-management

filterSegmentsClient​

import { filterSegmentsClient } from '@dynatrace-sdk/client-filter-segment-management';

createFilterSegment​

filterSegmentsClient.createFilterSegment(config): Promise<DetailedFilterSegment>

Create a new filter-segment.

Create a new segment and define data.

Required scopes:

  • storage:filter-segments:write
  • storage:filter-segments:share if isPublic is set to true

New Filter-Segment

Provide a name and an optional description for the filter-segment.

Variables

Create variables to apply in your filter-segment data filters

Includes (Segment data)

Include all data that should be accessible when applying the filter-segment

IsPublic (Visibility)

  • false: The filter-segment is private and only visible to the owner
  • true: The filter-segment is visible to everyone in the environment

Parameters​

NameType
config.body*requiredNewFilterSegment

Returns​

Return typeStatus codeDescription
DetailedFilterSegment201Filter-segment successfully created.

Throws​

Error TypeError Message
ErrorEnvelopeErrorFilter-segment Bad Request. | unauthorized | missing permissions

Code example

import { filterSegmentsClient } from "@dynatrace-sdk/client-filter-segment-management";

const data = await filterSegmentsClient.createFilterSegment(
{
body: {
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",
},
],
},
},
);

deleteFilterSegment​

filterSegmentsClient.deleteFilterSegment(config): Promise<void>

Delete a filter-segment.

Remove the filter-segment from the environment for all users.

Required scopes:

  • storage:filter-segments:delete

Parameters​

NameTypeDescription
config.filterSegmentUid*requiredstringUID of the filter-segment

Example: D82a1jdA23a

Returns​

Return typeStatus codeDescription
void204Filter-segment successfully deleted.

Throws​

Error TypeError Message
ErrorEnvelopeErrorbad request | unauthorized | missing permissions | Not found: the server cannot find the requested filter-segment.

Code example

import { filterSegmentsClient } from "@dynatrace-sdk/client-filter-segment-management";

const data = await filterSegmentsClient.deleteFilterSegment(
{ filterSegmentUid: "D82a1jdA23a" },
);

getFilterSegment​

filterSegmentsClient.getFilterSegment(config): Promise<DetailedFilterSegment>

Get filter-segment by UID.

Get filter-segment by its UID.

Required scopes:

  • storage:filter-segments:read

Parameters​

NameTypeDescription
config.addFieldsnull | Array<"INCLUDES" | "VARIABLES" | "EXTERNALID" | "RESOURCECONTEXT">Add additional fields.
config.filterSegmentUid*requiredstringUID of the filter-segment

Example: D82a1jdA23a

Returns​

Return typeStatus codeDescription
DetailedFilterSegment200Filter-segment successfully retrieved.

Throws​

Error TypeError Message
ErrorEnvelopeErrorbad request | unauthorized | missing permissions | Not found: the server cannot find the requested filter-segment.

Code example

import { filterSegmentsClient } from "@dynatrace-sdk/client-filter-segment-management";

const data = await filterSegmentsClient.getFilterSegment({
filterSegmentUid: "D82a1jdA23a",
});

getFilterSegments​

filterSegmentsClient.getFilterSegments(config): Promise<FilterSegments>

Get all filter-segments.

Returns all filter-segments. If details like description are not needed then consider using the :lean endpoint.

Required scopes:

  • storage:filter-segments:read

Parameters​

NameTypeDescription
config.addFieldsnull | Array<"VARIABLES" | "EXTERNALID" | "RESOURCECONTEXT">Add additional fields.

Returns​

Return typeStatus codeDescription
FilterSegments200Filter-segments successfully retrieved.

Throws​

Error TypeError Message
ErrorEnvelopeErrorbad request | unauthorized | missing permissions

Code example

import { filterSegmentsClient } from "@dynatrace-sdk/client-filter-segment-management";

const data = await filterSegmentsClient.getFilterSegments();

getFilterSegmentsEntityModel​

filterSegmentsClient.getFilterSegmentsEntityModel(config): Promise<FilterSegmentNamespaceDto>

Get filter-segment-entity-model.

Returns the filter-segment-entity-model.

Required scopes:

  • storage:filter-segments:read

Returns​

Return typeStatus codeDescription
FilterSegmentNamespaceDto200Filter-segments-entity-model successfully retrieved.

Throws​

Error TypeError Message
ErrorEnvelopeErrorbad request | unauthorized | missing permissions

Code example

import { filterSegmentsClient } from "@dynatrace-sdk/client-filter-segment-management";

const data =
await filterSegmentsClient.getFilterSegmentsEntityModel();

getLeanFilterSegments​

filterSegmentsClient.getLeanFilterSegments(config): Promise<LeanFilterSegments>

Get all filter-segments in a minimal/lean form.

Returns all filter-segments in a minimal representational form. This endpoint saves resources and as a result quicker response times can be expected over the more detailed get-all endpoint.

Required scopes:

  • storage:filter-segments:read

Parameters​

NameTypeDescription
config.addFieldsnull | Array<"VARIABLES" | "EXTERNALID" | "RESOURCECONTEXT" | "OWNER">Add additional fields.

Returns​

Return typeStatus codeDescription
LeanFilterSegments200Filter-segments successfully retrieved.

Throws​

Error TypeError Message
ErrorEnvelopeErrorbad request | unauthorized | missing permissions

Code example

import { filterSegmentsClient } from "@dynatrace-sdk/client-filter-segment-management";

const data =
await filterSegmentsClient.getLeanFilterSegments();

partiallyUpdateFilterSegment​

filterSegmentsClient.partiallyUpdateFilterSegment(config): Promise<void>

Partially update a filter-segment.

Update one or more fields of a filter-segment.

Required scopes:

  • storage:filter-segments:write
  • storage:filter-segments:share to change isPublic to true

Following fields can be updated:

  • name
  • description
  • isPublic
  • variables*
  • includes*

* If given the value will be overridden.

Fields not given will be ignored.

Parameters​

NameTypeDescription
config.body*requiredPartialUpdateFilterSegment
config.filterSegmentUid*requiredstringUID of the filter-segment

Example: D82a1jdA23a
config.optimisticLockingVersion*requirednumberversion which should be updated. used for optimistic locking.

Example: 1
Minimum: 0

Returns​

Return typeStatus codeDescription
void200Filter-segment successfully updated.

Throws​

Error TypeError Message
ErrorEnvelopeErrorbad request | unauthorized | missing permissions | Not found: the server cannot find the requested filter-segment.

Code example

import { filterSegmentsClient } from "@dynatrace-sdk/client-filter-segment-management";

const data =
await filterSegmentsClient.partiallyUpdateFilterSegment({
filterSegmentUid: "D82a1jdA23a",
optimisticLockingVersion: 1,
body: {
description:
"only includes data of the development environment",
},
});

updateFilterSegment​

filterSegmentsClient.updateFilterSegment(config): Promise<void>

Update a filter-segment. All fields will be overwritten (also undefined or null fields).

Update one or more fields of a filter-segment.

Required scopes:

  • storage:filter-segments:write
  • storage:filter-segments:share to change isPublic to true

Following fields can be updated:

  • name
  • description
  • isPublic
  • variables*
  • includes*

* Values of the fields will be overridden or removed if not given.

Provide all other fields with unchanged values.

Parameters​

NameTypeDescription
config.body*requiredUpdateFilterSegment
config.filterSegmentUid*requiredstringUID of the filter-segment

Example: D82a1jdA23a
config.optimisticLockingVersion*requirednumberversion which should be updated. used for optimistic locking.

Example: 1
Minimum: 0

Returns​

Return typeStatus codeDescription
void200Filter-segment successfully updated.

Throws​

Error TypeError Message
ErrorEnvelopeErrorbad request | unauthorized | missing permissions | Not found: the server cannot find the requested filter-segment.

Code example

import { filterSegmentsClient } from "@dynatrace-sdk/client-filter-segment-management";

const data = await filterSegmentsClient.updateFilterSegment(
{
filterSegmentUid: "D82a1jdA23a",
optimisticLockingVersion: 1,
body: {
uid: "D82a1jdA23a",
name: "dev_environment",
description:
"only includes data of the development environment",
variables: {
type: "query",
value: "fetch logs | limit 1",
},
isPublic: false,
owner: "john.doe",
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",
},
],
},
},
);

Types​

CustomValidationErrorInfo​

NameType
message*requiredstring

DetailedFilterSegment​

NameTypeDescription
allowedOperationsnull | Array<"READ" | "WRITE" | "DELETE" | "SHARE">Defines the allowed operations of the current user.
descriptionnull | stringDescription of the filter-segment.

Example: only includes data of the dev environment
externalIdnull | stringOptional unique identifier of the filter-segment. Used for Dynatrace Configuration as Code
includesnull | Array<Include>List of includes of the filter-segment.
isPublicbooleanIndicates if the filter-segment is publicly accessible within the tenant.

Example: false
isReadyMadenull | booleanIndicates if the segment is ready-made.

Example: false
name*requiredstringName of the filter-segment.

Example: dev_environment
owner*requiredstringDefines the owner of the filter-segment.

Example: john.doe
uid*requiredstringUnique identifier of the filter-segment.

Example: D82a1jdA23a
variablesFilterSegmentVariablesVariables of the filter-segment.
versionnumberUsed 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.

Example: 1

ErrorEnvelope​

NameType
errorExceptionalReturn

ErrorInfo​

NameType
message*requiredstring

ExceptionalReturn​

NameType
codenumber
errorDetails*requiredArray<CustomValidationErrorInfo | InvalidAuditEventsErrorInfo | MediaTypeErrorInfo | ParameterErrorInfo | ProxyErrorInfo | QueryFrontendRawErrorInfo | RequestBodyErrorInfo>
message*requiredstring

FilterSegment​

List of filter-segments.

NameTypeDescription
allowedOperationsnull | Array<"READ" | "WRITE" | "DELETE" | "SHARE">Defines the allowed operations of the current user.
descriptionnull | stringDescription of the filter-segment.

Example: only includes data of the dev environment
externalIdnull | stringOptional unique identifier of the filter-segment. Used for Dynatrace Configuration as Code
isPublicbooleanIndicates if the filter-segment is publicly accessible within the tenant.

Example: false
isReadyMadenull | booleanIndicates if the segment is ready-made.

Example: false
name*requiredstringName of the filter-segment.

Example: dev_environment
owner*requiredstringDefines the owner of the filter-segment.

Example: john.doe
uid*requiredstringUnique identifier of the filter-segment.

Example: D82a1jdA23a
variablesFilterSegmentVariablesVariables of the filter-segment.
versionnumberUsed 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.

Example: 1

FilterSegmentNamespaceDto​

NameTypeDescription
allowedFilterOperationsArray<FilterSegmentPushDownFilterableDto>Allowed filter operations.
name*requiredstringName of the namespace.

Example: dt.entity
typesArray<FilterSegmentTypeDto>Types of the namespace.

FilterSegmentPropertyDto​

NameType
namestring
typestring

FilterSegmentPushDownFilterableDto​

Allowed filter operations.

NameType
filterNamestring
supportedAttributesArray<string>

FilterSegmentRelationshipDto​

NameType
namestring
targetstring

FilterSegmentTypeDto​

Types of the namespace.

NameType
displayNamestring
filtersEntitiesOnlyboolean
fromTypesArray<FilterSegmentRelationshipDto>
namestring
propertiesArray<FilterSegmentPropertyDto>
relatedTargetEntityOnlyboolean
restrictedParentPropertiesArray<string>

FilterSegmentVariables​

Variables of the filter-segment.

NameTypeDescription
type*requiredstringType of the variable.
value*requiredstringValue of the variable.

FilterSegments​

NameTypeDescription
filterSegments*requiredArray<FilterSegment>List of filter-segments.

Include​

List of includes of the filter-segment.

NameTypeDescription
applyTonull | Array<string>[Experimental] The tables that the entity-filter will be applied to.

Example: ["logs","events"]
dataObject*requiredstringThe data object that the filter will be applied to. Use '_all_data_object' to apply it to all dataObjects.

Example: logs
filter*requiredstringData will be filtered by this value. Field names must only contain letters, numbers and underscores, otherwise they need to be escaped using quotes(`).
relationshipRelationship[Experimental] The relationship of an include which has to be be specified when the data object is an entity view.

InvalidAuditEventsErrorInfo​

NameType
invalidAuditEventIndices*requiredArray<number>
invalidEventIndicesArray<number>
message*requiredstring

LeanFilterSegment​

List of filter-segments.

NameTypeDescription
allowedOperationsnull | Array<"READ" | "WRITE" | "DELETE" | "SHARE">Defines the allowed operations of the current user.
externalIdnull | stringOptional unique identifier of the filter-segment. Used for Dynatrace Configuration as Code
isPublicbooleanIndicates if the filter-segment is publicly accessible within the tenant.

Example: false
isReadyMadenull | booleanIndicates if the segment is ready-made.

Example: false
name*requiredstringName of the filter-segment.

Example: dev_environment
ownernull | stringDefines the owner of the filter-segment.

Example: john.doe
uid*requiredstringUnique identifier of the filter-segment.

Example: D82a1jdA23a
variablesFilterSegmentVariablesVariables of the filter-segment.

LeanFilterSegments​

NameTypeDescription
filterSegments*requiredArray<LeanFilterSegment>List of filter-segments.

MediaTypeErrorInfo​

NameType
message*requiredstring
supportedMediaTypes*requiredArray<string>

NewFilterSegment​

NameTypeDescription
descriptionnull | stringDescription of the filter-segment.

Example: only includes data of the dev environment
externalIdnull | stringOptional unique identifier of the filter-segment. Used for Dynatrace Configuration as Code
includesnull | Array<NewInclude>List of includes of the filter-segment.
isPublic*requiredbooleanIndicates if the filter-segment is publicly accessible within the tenant.

Example: false
name*requiredstringName of the filter-segment.

Example: dev_environment
variablesFilterSegmentVariablesVariables of the filter-segment.

NewInclude​

List of includes of the filter-segment.

NameTypeDescription
applyTonull | Array<string>[Experimental] The tables that the entity-filter will be applied to.

Example: ["logs","events"]
dataObject*requiredstringThe data object that the filter will be applied to. Use '_all_data_object' to apply it to all dataObjects.

Example: logs
filter*requiredstringData will be filtered by this value. Field names must only contain letters, numbers and underscores, otherwise they need to be escaped using quotes(`).
relationshipNewRelationship[Experimental] The relationship of an include which has to be be specified when the data object is an entity view.

NewRelationship​

[Experimental] The relationship of an include which has to be be specified when the data object is an entity view.

NameTypeDescription
name*requiredstringName of the relationship.

Example: belongs_to
target*requiredstringTarget of the relationship.

Example: dt.entity.host

ParameterErrorInfo​

NameType
message*requiredstring
parameterDescriptor*requiredstring

PartialUpdateFilterSegment​

NameTypeDescription
descriptionnull | stringDescription of the filter-segment.

Example: only includes data of the dev environment
externalIdnull | stringOptional unique identifier of the filter-segment. Used for Dynatrace Configuration as Code
includesnull | Array<NewInclude>List of includes of the filter-segment.
isPublicnull | booleanIndicates if the filter-segment is publicly accessible within the tenant.

Example: false
namenull | stringName of the filter-segment.

Example: dev_environment
variablesFilterSegmentVariablesVariables of the filter-segment.

ProxyErrorInfo​

NameType
message*requiredstring

QueryFrontendRawErrorInfo​

NameType
message*requiredstring
rawQueryFrontendResponse*requiredstring

Relationship​

[Experimental] The relationship of an include which has to be be specified when the data object is an entity view.

NameTypeDescription
name*requiredstringName of the relationship.

Example: belongs_to
target*requiredstringTarget of the relationship.

Example: dt.entity.host

RequestBodyErrorInfo​

NameType
bodyDescriptor*requiredstring
message*requiredstring

UpdateFilterSegment​

NameTypeDescription
descriptionnull | stringDescription of the filter-segment.

Example: only includes data of the dev environment
externalIdnull | stringOptional unique identifier of the filter-segment. Used for Dynatrace Configuration as Code
includesnull | Array<NewInclude>List of includes of the filter-segment.
isPublic*requiredbooleanIndicates if the filter-segment is publicly accessible within the tenant.

Example: false
name*requiredstringName of the filter-segment.

Example: dev_environment
owner*requiredstringDefines the owner of the filter-segment.

Example: john.doe
uid*requiredstringUnique identifier of the filter-segment.

Example: D82a1jdA23a
variablesFilterSegmentVariablesVariables of the filter-segment.

Enums​

DetailedFilterSegmentAllowedOperationsItem​

⚠️ Deprecated Use literal values.

Defines the allowed operations of the current user.

Enum keys​

Delete | Read | Share | Write

FilterSegmentAllowedOperationsItem​

⚠️ Deprecated Use literal values.

Defines the allowed operations of the current user.

Enum keys​

Delete | Read | Share | Write

GetFilterSegmentQueryAddFieldsItem​

⚠️ Deprecated Use literal values.

Enum keys​

Externalid | Includes | Resourcecontext | Variables

GetFilterSegmentsQueryAddFieldsItem​

⚠️ Deprecated Use literal values.

Enum keys​

Externalid | Resourcecontext | Variables

GetLeanFilterSegmentsQueryAddFieldsItem​

⚠️ Deprecated Use literal values.

Enum keys​

Externalid | Owner | Resourcecontext | Variables

LeanFilterSegmentAllowedOperationsItem​

⚠️ Deprecated Use literal values.

Defines the allowed operations of the current user.

Enum keys​

Delete | Read | Share | Write

Still have questions?
Find answers in the Dynatrace Community