knoguchi / grafana-dash

A utility to update Grafana dashboards
Apache License 2.0
10 stars 4 forks source link

Replace data source name in template #5

Open tmor opened 4 years ago

tmor commented 4 years ago

Summary

Hello, I used the template/variable feature and the data source names were saved.

This changes works for me.

Environments

Steps to reproduce

Example dashboard: templating-grafana7.0.6.zip

...
    "templating": {
      "list": [
        {
          "current": {
            "selected": true,
            "text": "CloudWatch(old)",
            "value": "CloudWatch(old)"
          },
...

Command:

jq -Mf ./update-datasource.jq --arg old "CloudWatch(old)" --arg new "CloudWatch(new)" < templating-grafana7.0.6.json | jq .dashboard.templating
knoguchi commented 4 years ago

"current" appears other part of the json. It needs some qualifier to avoid unintentional replacing.