Anthony Kong
Anthony Kong

Reputation: 40624

How to correct the query statement (string interpolation) in the Datadog dashboard?

I want to be able to parameterised my datadog dashboard.

I have already introduced a template variable flavor which to indicate if it is dev or prod environment.

What I wish to achieve is to switch data from one environment o another when I select a different environment (e.g. from dev-db-master to prod-db-master). The string interpolation is necessary because I want to display multiple time series within a single chart.

enter image description here

However the chart is basically blank

enter image description here

The Json tab also shows a pink background which indicates either the json is malformed or the query is too complex.

My goal is to be able to, by changing the template variable flavor,

I can change a group of time series from, says, 'dev-db-master', 'dev-db1-master' and 'dev-db2-master' to 'prod-db-master', 'prod-db1-master' and 'prod-db2-master'.

Can you suggest a way to construct a string with a template variable?

Upvotes: 2

Views: 5565

Answers (1)

XYZ123
XYZ123

Reputation: 456

What about using the template variables doc?

You could select:

  • Name: Name,
  • Tag or Attribute: name,
  • Default Value: dev-db-master

Then you'll be able to replace your {name:$flavor-db-master} with {$Name}

Otherwise, if you actually wants the value of the template variable you have to use $flavor.value. I advise to use a not widget to check the actual behavior.

EDIT:

This kind of setup is not the recommended. It would be better to set two tags on your database:

  • env:dev or env:prod
  • dbname:db1-master or dbname:db2-master.

You would then have a unique selection of tags, env:dev,dbname:db1-master. It would then be easy to have a query such as:

"q": "avg:aws.rds.bin_log_disk_usage{$Env,dbname:db1-master}"

Upvotes: 1

Related Questions