DQL
Questions about Dynatrace Query Language
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Segments: include entities and related metrics/traces

janne-olkoniemi
Frequent Guest

I have just started to play around with segments and I hope that someone could help me how to include metrics and traces from entities to be part of segment definition.

I have currently the following variable in place on my segment definition and it picks the SAMPLE_TAG values correctly.

fetch dt.entity.service, from: -10d
| expand tag = tags
| fields tag
| filter startsWith(tag, "SAMPLE_TAG")
| dedup tag
| parse tag, "LD ':' LD:Service"
| fields Service,tag

And I have the following filter definition in place to pick the entities which are containing the SAMPLE_TAG.

janneolkoniemi_1-1770969469694.png

But I'm kind of lost that how I could include the metrics and traces from the entities which are having the tag SAMPLE_TAG. Is there some way with segments to include metrics and traces from entities which are containing a certain tag? 

 

1 REPLY 1

t_pawlak
Leader

Hi,
Segments don’t automatically “bring metrics and traces along” when you include only entities. You need separate Include blocks for the signals you want (e.g., Spans and Metrics) and scope them to the same entity set.
try subqueries filters:
Spans (traces) for services tagged some_tag

fetch spans, from: -10d
| filter dt.entity.service in [
    fetch dt.entity.service, from: -10d
    | expand tags
    | filter startsWith(tags, "OpenTelemetry")
    | fields id
    | dedup id
  ]

t_pawlak_0-1770987448082.png

Metrics for the same services:

timeseries req = sum(dt.service.request.count), by: {dt.entity.service}, from: -10d
| filter dt.entity.service in [
    fetch dt.entity.service, from: -10d
    | expand tags
    | filter startsWith(tags, "OpenTelemetry")
    | fields id
    | dedup id
  ]

t_pawlak_1-1770987507567.png

 

You must explicitly include metrics/spans in the Segment; selecting entities alone won’t scope those signals automatically

Featured Posts