question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Template variables doesn't work with the datasource in v8.1.0

See original GitHub issue

After moving from Grafana v8.0.6 to v8.1.0 the template variables stops working. A full page refresh is needed to update the template variables.

This also happens to panel queries.

v8.1.0 (bug) Grafana-variable-v8 1 0

v8.0.6 Grafana-variable-v8 0 6

I wasn’t able to get this bug to happen to the influx datasource, but this might be more of a Grafana issue.

JSON MODEL

{
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": "-- Grafana --",
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "target": {
          "limit": 100,
          "matchAny": false,
          "tags": [],
          "type": "dashboard"
        },
        "type": "dashboard"
      }
    ]
  },
  "editable": true,
  "gnetId": null,
  "graphTooltip": 0,
  "id": 18,
  "iteration": 1628502370253,
  "links": [],
  "panels": [
    {
      "datasource": null,
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisLabel": "",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "drawStyle": "line",
            "fillOpacity": 0,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "lineInterpolation": "linear",
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "auto",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          }
        },
        "overrides": []
      },
      "gridPos": {
        "h": 22,
        "w": 24,
        "x": 0,
        "y": 0
      },
      "id": 2,
      "options": {
        "legend": {
          "calcs": [],
          "displayMode": "list",
          "placement": "bottom"
        },
        "tooltip": {
          "mode": "single"
        }
      },
      "targets": [
        {
          "alias": "${id}",
          "refId": "A",
          "scenarioId": "random_walk"
        }
      ],
      "title": "${id}",
      "type": "timeseries"
    }
  ],
  "refresh": "",
  "schemaVersion": 30,
  "style": "dark",
  "tags": [],
  "templating": {
    "list": [
      {
        "allValue": null,
        "current": {
          "selected": false,
          "text": "1",
          "value": "1"
        },
        "description": null,
        "error": null,
        "hide": 0,
        "includeAll": false,
        "label": null,
        "multi": false,
        "name": "index",
        "options": [
          {
            "selected": true,
            "text": "1",
            "value": "1"
          },
          {
            "selected": false,
            "text": "2",
            "value": "2"
          },
          {
            "selected": false,
            "text": "3",
            "value": "3"
          },
          {
            "selected": false,
            "text": "4",
            "value": "4"
          },
          {
            "selected": false,
            "text": "5",
            "value": "5"
          },
          {
            "selected": false,
            "text": "6",
            "value": "6"
          }
        ],
        "query": "1,2,3,4,5,6",
        "queryValue": "",
        "skipUrlSync": false,
        "type": "custom"
      },
      {
        "allValue": null,
        "current": {
          "selected": false,
          "text": "92",
          "value": "92"
        },
        "datasource": "Grafana API",
        "definition": "$.items[${index}].id",
        "description": null,
        "error": null,
        "hide": 0,
        "includeAll": false,
        "label": null,
        "multi": false,
        "name": "id",
        "options": [],
        "query": {
          "cacheDurationSeconds": 0,
          "fields": [
            {
              "jsonPath": "$.items[${index}].id"
            }
          ],
          "method": "GET",
          "params": [],
          "queryParams": "",
          "urlPath": "/"
        },
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "type": "query"
      }
    ]
  },
  "time": {
    "from": "now-6h",
    "to": "now"
  },
  "timepicker": {
    "refresh_intervals": [
      "500ms",
      "1s",
      "2s",
      "5s",
      "10s",
      "30s",
      "1m",
      "5m",
      "15m",
      "30m",
      "1h",
      "2h",
      "1d"
    ]
  },
  "timezone": "",
  "title": "Template variable test",
  "uid": "AMq8k0mnh",
  "version": 24
}

Datasource name: GRAFANA API Datasrouce url: https://grafana.com/api/plugins

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
marcusolssoncommented, Jan 20, 2022

Thank you all for confirming and providing details! I’ll prioritize this.

0reactions
HarterHorstcommented, Jan 18, 2022

I have the same problem. When I select a variable in a dropdown the database query does not execute with the new variable. No http call in the debugger.

I found a strange fix by coincidence. I tried to create a workaround with getting all values from the web api and filter it with the transformation “filter data by value” using the variable in my table. And now it works!

What works is not the transformation itself, it’s the trigger from the transformation that starts a new query for the database. I found out that the transformation “filter data by value” cannot handle variables at all but it will trigger a query refresh. Even if I disable the transformation it works. Hope this can help to find the bug.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Template variable not updating · Issue #95 - GitHub
The variables are defined using MySQL as datasource. If var-c is updated, the depending variables var-b and var-a are updated properly. That's why...
Read more >
Solved: Data Source Environment Variables not working for
Solved: Hi I have migrated a solution between environments. The solution includes an app whose data is based on a SharePoint library. There...
Read more >
Fix List for IBM Operational Decision Manager
1 THAT WAS WORKING PROPERLY WITH 8.8 AND 8.9.0. RS03080, HTDS: OUTPUT PARAMETERS CANNOT BE SERIALIZED. RS03096, XU CONNECTION LOST WHEN DATASOURCE NOT...
Read more >
template_file | Data Sources | hashicorp/template
Use the file function to load the template source from a separate file on disk. vars - (Optional) Variables for interpolation within the...
Read more >
How to use MongoDB exporter metrics in Grafana?
Good afternoon, I'm having some problems connecting Mongodb exporter metrics to Grafana. Metrics are being successfully extracted for ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found