DEV Community

Cover image for Dynatrace segments: filter your data once, reuse it everywhere
Span Observer
Span Observer

Posted on Originally published at span.observer

Dynatrace segments: filter your data once, reuse it everywhere

It is 3 a.m. and the payments on-call engineer opens a dashboard that shows logs, traces and services from the whole company. They retype yesterday’s filters: cluster, namespace, team. Dynatrace segments remove that chore. You define the scope once, then pick it from a selector, whichever app you have open.

The facts come from the Dynatrace documentation on segments and from the vendor’s blog post on the topic. The structure and examples here are my own and start from an operating question: where should a filter live so that everyone benefits? The conditions and queries below are examples that were not run on a tenant, so try them on a small scope first. This applies to Dynatrace SaaS (the Grail platform). Compatibility with Dynatrace Managed is not verified and is not covered here.

The migration background (Management zones, buckets, IAM) is in the Grail vs Classic article. This one stays with day-to-day use.

Why Dynatrace segments beat filters rebuilt everywhere

A filter pasted into a dashboard serves that dashboard only. The same filter copied into a Notebook, then into a Workflow query, drifts quickly: one targets the payments namespace, another forgets the staging cluster. When the organisation changes, you fix ten places.

A segment moves that filter to the centre. The documentation describes it as a way to structure and filter observability data across the apps of the platform. The vendor stresses three properties: the selected segment stays active as you move between apps, it combines with the filter bar and dashboard variables, and it always respects access rights.

What a segment is not

A segment holds no data and grants no rights. Queries, with or without a segment, apply IAM policies. It is a convenience filter, not a security boundary. Keep that distinction in mind for the rest of the article.

Anatomy of a segment: includes

A segment starts empty. Each include adds one data type to the scope, filtered by a condition. A query returns only the data referenced by an include of the selected segment: with no matching include, the result is empty.

  • Signals: logs, metrics, events, spans and others. The documentation advises referencing them directly, because the filter is then more efficient.
  • Entities: they go through entity-to-signal relationships, mostly for compatibility with classic entities (dt.entity.host, dt.entity.service, dt.entity.kubernetes_cluster). A segment allows only one relationship hop.
  • Combination: include blocks are joined by OR. Their order has no effect on the result.

Here is the « payments-prod » segment for our on-call team: two includes, one for logs and one for spans, with the same conditions.

Two includes of an example segment, logs and spans, filtered on the payments namespace and the prod-eu cluster

Conditions are evaluated when the query runs, so they affect its duration. For complex conditions or fields that need normalising, the documentation recommends processing the data upstream with OpenPipeline instead.

Variables: one segment for ten clusters

Creating one segment per cluster brings back the duplicated-filter problem. Variables solve it: the include contains $name, and the user picks the value when applying the segment.

Values come from a DQL query, or from a static list built with the data command and record(...). The first column of the result is the primary variable, which supplies the suggested values. Later columns are secondary variables, tied to the chosen value. A * suffix after the name turns equality into « starts with ».

Variable DQL query listing three clusters and two include conditions using $cluster and $cluster\*

Variable pitfalls

  • Neither the variable name nor its values may contain the * character.
  • The query runs with the user’s own permissions. Avoid high-volume types such as logs to fill it.
  • Do not use a variable to look up entities by ID: keep it for a dimension, such as a cloud region.
  • An empty drop-down can point to a missing permission: storage:filter-segments:read and the right to run the segments management app.

Visibility and permissions: who sees what

The Visibility setting has two values: Unlisted (the default), where the segment appears only in its owner’s list, and Anyone in the environment. Beware: an unlisted segment stays usable. If a shared Notebook or dashboard references it, anyone with access to that document gets it too.

Who may configure segments visible to everyone depends on IAM permissions. For data access rights, go back to buckets and policies, as explained in the article on Management zones and tagging.

Setting up a segment, step by step

  1. Pick the dimension that separates your teams: namespace, cluster, team tag. If the fields are inconsistent, fix them first in OpenPipeline.
  2. Open segment management (Settings > Environment segmentation > Segments) and create the segment.
  3. Add one include per useful data type: logs, spans, events.
  4. If the scope repeats, introduce a variable rather than duplicating the segment.
  5. Set the visibility, name the segment after the team and pin it in the selector for the people who use it often.

On the usage side, the vendor post cites troubleshooting, SLOs, release validation with Site Reliability Guardian, and security. For dashboard tiles and queries, see the DQL dashboard examples.

How to check the segment does its job

Compare a count with and without the segment in a Notebook. If the two numbers differ, an include is missing or a condition is too broad.

Two DQL check queries, with manual filters then with the segment, whose counts should match

Then test with a user from another team: they should see the segment in their list if visibility allows it, and their queries must stay limited by their policies.

Good practices

  • One segment per team or application scope, named the way the team says it out loud.
  • Reference signals directly rather than going through entities.
  • No variable on a bulky data type; prefer a short list or a light type.
  • Never count on a segment to protect data: write the IAM policy.
  • Review the list every quarter and delete segments nobody pins any more.

To tie the segment to alert responsibility, see also the article on Ownership.

Frequently asked questions

Does a segment replace a Management zone?

Only for filtering. Segments do not carry access control: that goes through buckets and IAM policies.

Is an unlisted segment private?

No. It appears only in its owner’s list, but it stays usable in a shared Notebook or dashboard.

What is the maximum number of segments?

I could not read the values on the documentation’s limits page, so check it before planning a large-scale rollout.

Conclusion

A segment is a filter written once and chosen in one click. It saves the on-call engineer time and aligns teams on the same scope, as long as access rights stay in IAM. Start with a single segment for your busiest team, verify it with a count, then spread the practice. For more depth, the segments documentation covers each concept.

Independent blog, not affiliated with Dynatrace LLC. Dynatrace is a trademark of Dynatrace LLC.


Originally published on span.observer. French version: https://span.observer/fr/segments-dynatrace-filtrer-donnees/.

Top comments (0)