Adil Idrissov
Adil Idrissov

Reputation: 3

Template variable in another variable - Grafana

Grafana version - v7.5.3

I have two “custom” variables -

env - has following values: test,prod

instanceidtest - someid

instanceidprod - anotherid

JSON example:

“targets”: [

    {

      "alias": "cpu",

      "dimensions": {

        "InstanceId": "$instanceid${env}"

      },

I want to template variable in another variable something like this - $instanceid${env} to become $instancetest

Upvotes: 0

Views: 3417

Answers (1)

Create just one custom variable called "env" like the following:

Values: test: someid,prod: anotherid

Note: the spaces are important

To get the id accordingly with the selected env use: ${env:value}

See this answer for more details.

Upvotes: 2

Related Questions