Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ZuperZee opened this issue Aug 9, 2021 · 8 comments
Open

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

ZuperZee opened this issue Aug 9, 2021 · 8 comments
Labels
type/bug Unexpected behavior or a feature is broken

Comments

@ZuperZee
Copy link

ZuperZee commented Aug 9, 2021

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

@bdrupieski
Copy link

I just started using this data source with Grafana 8.1.2 and don't seem to have this problem. Maybe try updating from 8.1.0 to 8.1.2?

@ZuperZee
Copy link
Author

ZuperZee commented Aug 30, 2021

Hmm, I'm not able to get it to happen with that JSON Model, but the bug still persist if params are used.

image

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": 27,
  "iteration": 1630310729410,
  "links": [],
  "panels": [],
  "schemaVersion": 30,
  "style": "dark",
  "tags": [],
  "templating": {
    "list": [
      {
        "allValue": null,
        "current": {
          "selected": false,
          "text": "Germany",
          "value": "Germany"
        },
        "description": null,
        "error": null,
        "hide": 0,
        "includeAll": false,
        "label": null,
        "multi": false,
        "name": "country",
        "options": [
          {
            "selected": true,
            "text": "Germany",
            "value": "Germany"
          },
          {
            "selected": false,
            "text": "United States",
            "value": "United States"
          }
        ],
        "query": "Germany,United States",
        "skipUrlSync": false,
        "type": "custom"
      },
      {
        "allValue": null,
        "current": {
          "selected": false,
          "text": "Germany",
          "value": "Germany"
        },
        "datasource": "Unis",
        "definition": "$[0].country",
        "description": null,
        "error": null,
        "hide": 0,
        "includeAll": false,
        "label": null,
        "multi": false,
        "name": "unis",
        "options": [],
        "query": {
          "cacheDurationSeconds": 300,
          "fields": [
            {
              "jsonPath": "$[0].country"
            }
          ],
          "method": "GET",
          "params": [
            [
              "country",
              "${country}"
            ]
          ],
          "queryParams": "",
          "urlPath": "/"
        },
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "type": "query"
      }
    ]
  },
  "time": {
    "from": "now-6h",
    "to": "now"
  },
  "timepicker": {},
  "timezone": "",
  "title": "JSON API not updating (bug)",
  "uid": "-UInQt4nk",
  "version": 8
}

Datasource name: Unis
Datasource url: http://universities.hipolabs.com/search

@marcusolsson
Copy link
Contributor

Hm. This reminds me of #95, which has been eluding me so far, unfortunately.

@ZuperZee
Copy link
Author

ZuperZee commented Sep 3, 2021

Hm. This reminds me of #95, which has been eluding me so far, unfortunately.

That bug doesn't seem to be this problem. This seems to only happen when params with variables are used. Fields with variables seem to work.

@clmattm
Copy link

clmattm commented Sep 9, 2021

Having a similar issue with params with variables. We use a text box instead of a dropdown.

Hitting "enter" just refreshes the page and clears the text box.

However, if we hit "tab", it correctly triggers and our table updates.

@qinix
Copy link

qinix commented Jan 11, 2022

Unfortunately, I got the same problem here with Grafana v8.3.3.

@HarterHorst
Copy link

HarterHorst commented 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.

@marcusolsson marcusolsson added type/bug Unexpected behavior or a feature is broken priority/critical-urgent and removed priority/awaiting-more-evidence labels Jan 20, 2022
@marcusolsson
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Unexpected behavior or a feature is broken
Projects
Status: Backlog
Development

No branches or pull requests

7 participants