datadog-agent icon indicating copy to clipboard operation
datadog-agent copied to clipboard

Parameterization the name of metric in the Datadog query

Open jrybak23 opened this issue 5 years ago • 1 comments

There are a bunch of custom metrics that looks like:

metric.name.key1
metric.name.key2
...

There is a template variables dropdown (https://docs.datadoghq.com/dashboards/template_variables/) on the dashboard that contains all keys. (Name of the variable is $key and values key1, key2..)

The metrics query like this works fine:

avg:metric.name.key1{*}.as_count()

But is it possible to parametrize the query with the $key variable by concatenation with the part of the name of metric? So it would look like this:

avg:metric.name.$key{*}.as_count()

As I know, it is possible to something like that by using tags but unfortunately, there are no any metrics with the tag "key".

Not sure that the issue was created in the appropriate repo so move it to the correct one if needed. Also, here is the same StackOverflow question: https://stackoverflow.com/questions/64661079/string-interpolation-with-the-name-of-metric-in-the-datadog-query

jrybak23 avatar Nov 03 '20 10:11 jrybak23

I have a similar problem:

The original query is: "query": "sum:ray.cluster.active_nodes{$service,$host}" and it works fine.

When I do "query": "sum:bigraycluster.ray.cluster.active_nodes{$service,$host}" it works but when I add a variable "query": "sum:$raycluster.ray.cluster.active_nodes{$service,$host}" it gives me a query error.

Are variables not allowed in metrics? I did try {$raycluster}

23ewrdtf avatar Feb 15 '24 12:02 23ewrdtf