cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Logical operator similar to Prometheus "unless" in DQL

cabeywardhana
Visitor

I have Prometheus query where it has "unless" logical operator to DQL. (Ref: logical-set-binary-operators )
Is there a similar logical operator which I could utilze in DQL? 
If not, how can I use existing features to achieve a similar result to Prometheus?

4 REPLIES 4

krzysztof_hoja
Dynatrace Champion
Dynatrace Champion

I think you have not in operators in mind. This is example DQL query which operated on 2 different data sets (like Prometheus instant vectors) and does what "unless" does:

data 
record(val=1,  label="a"),
record(val=2,  label="b"),
record(val=3,  label="c")
| filter not label in [
  data
  record(val2=10,  label="a")
  | fields label
]

krzysztof_hoja_0-1711135124947.png

 

Can you give example of data you work with?

Kris 

Thank you for the prompt response @krzysztof_hoja 
I am working with two timeseries metrics combined using a join in my Grail DQL query.
The following is a representation of what my query looks like: 

timeseries avg(metric1)
    interval: 10m
    by: {id}
| join [ 
    timeseries avg(metric2)
    interval: 10m
    by: {id}
], on: {id}, kind: ???

 What I am after is to combine/join two timeseries metrics with an operator which does the same as unless operator in Prometheus.
 

krzysztof_hoja
Dynatrace Champion
Dynatrace Champion

Please check if this query gives what you need:

timeseries avg(dt.host.cpu.system), by:{dt.entity.host}, filter:aws.region=="us-east-1"
| filterOut dt.entity.host in [
    timeseries avg(dt.host.memory.usage), by:{dt.entity.host} , filter:aws.region=="us-east-1"
    | fields dt.entity.host
]

IMHO it works like unless

On my test tenant, results of component queries and combined one look like this:

krzysztof_hoja_0-1711572478995.png

 

This solution works for me. Thank you 🙏

Featured Posts