Try it free

Use segments to scope Services and Smartscape apps

  • Latest Dynatrace
  • Tutorial
  • 6-min read
  • Published Oct 07, 2026

Segments let you logically filter observability data across Dynatrace Apps. To work correctly in Services Services and Smartscape Smartscape, a segment for services should cover two separate data sources: metrics and topology. This tutorial explains why both data sources are needed and shows you how to create such a service segment.

Who is this for?

This tutorial is for platform engineers, SREs, and developers who rely on segments that filter the service list and the topology view to a specific part of their environment, for example, a Kubernetes namespace, a cloud region, or a host group.

What will you learn?

By the end of this tutorial, you'll have a working segment that scopes both the service list in Services Services and the topology view in Smartscape Smartscape to a specific part of your environment.

In this tutorial, you'll learn how to:

  • Understand why a service segment should cover both metrics and topology.
  • Create a segment that correctly filters both the service list and the topology view.
  • Verify the created segment in the Dynatrace Apps.

Before you begin

Prerequisites

  • Access to Services Services and Smartscape Smartscape in your Dynatrace environment.
  • storage:filter-segments:write and storage:filter-segments:read permissions. To learn how to set up these permissions, see Permissions in Grail.

You can also follow along without any setup by using the Dynatrace Playground.

Prior knowledge

Basic familiarity with the following concepts is helpful but not required, as you'll find instructions and examples throughout this page.

  • Include data in segments
  • Service-related concepts
  • Explore the service entity in Smartscape on Grail

Things to consider and known limitations

Before you build your segment, review the following information to avoid common pitfalls.

Data sources behind service segments

The service list in Services Services and the topology view in Smartscape Smartscape rely on separate data stores. The service list shows metrics, such as response time, throughput, and failure rate. The topology view maps the relationships: how services relate to hosts, namespaces, and other services. Different slices of data power each view.

A segment that covers only metrics filters the service list but leaves the topology view unfiltered. A segment that covers only topology works in Smartscape Smartscape but not in Services Services. To scope both apps correctly, your segment should address both data sources: metrics and topology.

Legacy dt.entity.* attributes

Do not use legacy dt.entity.* attributes in your segments, as they might incorrectly filter the service list in Services Services.

  • Do not use dt.entity.service in your segments. Instead, use dt.smartscape.service.
  • Do not use legacy dt.entity.* attributes in include blocks in your segments. In an existing segment, you should see a warning if you have an include block with legacy dt.entity.* attributes. Replace such attributes with dt.smartscape.* attributes.

Entity-to-entity relationships

When you add an include block to your segment by selecting More in the segment editor, don't use the entries listed under Classic entities (by type). Entity-to-entity relationships in segments apply to legacy dt.entity.* attributes only and don't work with Smartscape entities.

For Smartscape-based service segments, use the DQL variable approach described in this tutorial to derive service IDs instead of relationship traversal.

Create a service segment

Follow these steps to create a segment that correctly scopes both Services Services and Smartscape Smartscape.

1. Start creating a segment

To start creating a segment

  1. Go to Settings Settings > Environment segmentation > Segments.
  2. Select Segment. The segment editor opens.
  3. At the top of the page, enter a descriptive segment name, for example, Services by AWS region.
  4. Set Visibility to Anyone in the environment so that your teammates can use this segment.

The segment editor shows the Services by AWS region segment that is visible to everyone. Continue with the following steps to add the required include blocks to your service segment.

2. Add a "Data (all types)" include

To add a Data (all types) include block to your segment

  1. In the segment editor, enter the following filter condition under Data (all types). Do not copy and paste the condition, but manually enter it.

    aws.region = $aws.region

    The $aws.region variable is added to the Variables section in the segment editor.

    Keep the filter conditions dynamic and reference a field with $ instead of a literal, for example, k8s.namespace.name = $k8s.namespace.name or k8s.cluster.name = $k8s.cluster.name. This way, the segment stays flexible and reusable, and you can select the required value when using the segment.

  2. Select Preview to verify the result.

  3. In the preview results, go to the Metrics tab, and confirm that the expected service metrics appear.

    At this point, it's expected that the Entities tab doesn't return any service entities.

  4. Select Save.

You've added the Data (all types) include block that scopes Services Services.

When you filter using primary Grail fields or tags, Dynatrace automatically carries that attribute through to the matching service metrics. This is why a single Data (all types) include block is enough to filter the service list in Services Services. To scope Smartscape Smartscape too, continue with the next two steps.

3. Edit the variable

To edit the $aws.region variable of your segment

  1. In the segment editor, select (Edit variables(s)) by the $aws.region variable.

  2. Enter the required variable query in the code field on the left, for example:

    metrics
    | filter isNotNull(aws.region) and aws.region != "" // filter for services that have an AWS region
    | fields aws.region, dt.smartscape.service
    | summarize by: aws.region, dt.smartscape.service = collectDistinct(dt.smartscape.service)
    | sort lower(aws.region)

    This variable query looks up which services match your filter. The result is used in the Entities include block that you'll add in the next step.

  3. Select Run to confirm that the correct service list is returned.

    Review the table under Preview (2 variables created). The aws.region column contains the values for the primary $aws.region variable, which is the AWS region you select when you apply the segment. The dt.smartscape.service column shows the values for the secondary $dt.smartscape.service variable, which is the list of services for a region. For details, see Primary and secondary variables.

  4. Select Done.

You've edited the $aws.region variable. Now your segment has the primary $aws.region variable and the secondary $dt.smartscape.service variable.

Scale limit for metric-based variable queries

The variable query in this tutorial retrieves matching service IDs from service metrics. This approach works reliably for up to 10,000 services. In environments where your filter matches more services than that—for example, a single segment covering all production services across a large fleet—the variable query may return an incomplete list, leaving some services unfiltered.

If you hit this limit, split a broad segment into narrower ones. For example, create one segment per cluster or per region so that each variable query stays within the 10,000-service threshold.

4. Add an "Entities" include

To add an Entities include block to your segment

  1. In the segment editor, select More > Entities.

  2. Add a filter condition that references the variable from the previous step:

    type = "SERVICE" AND id in ($dt.smartscape.service)
  3. Select Preview to confirm that the expected services appear.

  4. Select Save in the upper-right corner of the segment editor.

You've added the Entities include block that scopes Smartscape Smartscape.

You've created a service segment! Your segment now contains a Data (all types) include block for metrics, a variable that retrieves matching service IDs, and an Entities include block for topology. The segment is visible to everyone in your environment.

Apply your new segment

With your segment created, verify that it correctly scopes both Services Services and Smartscape Smartscape.

1. Filter service list with your segment

To filter the service list in Services Services using your new segment

  1. Go to Services Services > Explorer (Early Access).
  2. In the upper-left corner of the page, select (Filter by segments).
  3. Under Filter by segments, select your new Services by AWS region segment, and then choose all the required AWS regions.
  4. Select Apply to confirm the segment selection.

The service list updates to show only the services matching your segment. Response time, throughput, and failure rate reflect only the metrics included in the segment.

2. Verify your segment in topology view

To filter the service nodes in Smartscape Smartscape using your new segment

  1. Go to Smartscape Smartscape > Service dependency graph.
  2. In the upper-right corner of the page, select (Segment selector).
  3. Under Filter by segments, select your new Services by AWS region segment, and then choose all the required AWS regions.
  4. Select Apply to confirm the segment selection.

The topology view shows only the service nodes matching your segment and their relationships.

Explore further segment examples

The following examples show you how to create segments for two common scenarios. In each case, follow the steps in Create a service segment and replace the filter conditions and variable query with the values provided in the example.

Primary Grail field example

Filter by host group

Create the following segment when you want to scope services to a specific host group. Because a host group is not automatically propagated to service metrics, follow all steps in Create a service segment.

1. Start creating a segment

Follow the instructions in Start creating a segment.

2. Add a "Data (all types)" include
dt.host_group.id = $dt.host_group.id
3. Edit the variable
metrics
| filter isNotNull(dt.host_group.id) and dt.host_group.id != ""
| fields dt.host_group.id, dt.smartscape.service
| summarize by: dt.host_group.id, dt.smartscape.service = collectDistinct(dt.smartscape.service)
| sort lower(dt.host_group.id)
4. Add an "Entities" include
type = "SERVICE" AND id in ($dt.smartscape.service)

Primary Grail tag example

Filter by team tag

Create the following segment when your services are tagged with a team ownership tag and may span multiple namespaces. Because primary_tags.* fields are propagated to service metrics, the Data (all types) include block can filter the service list in Services Services. To scope Smartscape Smartscape too, edit a variable and add an Entities include block.

1. Start creating a segment

Follow the instructions in Start creating a segment.

2. Add a "Data (all types)" include
primary_tags.team = $primary_tags.team
3. Edit the variable
metrics
| filter isNotNull(primary_tags.team) and primary_tags.team = "payments"
| fields primary_tags.team, dt.smartscape.service
| summarize by: primary_tags.team, dt.smartscape.service = collectDistinct(dt.smartscape.service)
| sort lower(primary_tags.team)
4. Add an "Entities" include
type = "SERVICE" AND id in ($dt.smartscape.service)

Congratulations!

You've created a service segment that covers both metrics and topology, verified that it correctly scopes Services Services and Smartscape Smartscape, and explored how to create segments for host groups and team tags. Your segments keep the service list and topology view in sync across both apps.

Services Services ships with ready-made segments for common dimensions such as an AWS region, Kubernetes namespace, and host group. Check the segment selector in the Explorer (Early Access) view to see which segments are already available in your environment.

Related topics

  • Segments
  • Include data in segments
Related tags
Application ObservabilityServicesServicesSmartscapeSmartscape