grafana / grafana-infinity-datasource

CSV, JSON, GraphQL, XML and HTML datasource for grafana.
https://grafana.com/docs/plugins/yesoreyeram-infinity-datasource
Apache License 2.0
734 stars 91 forks source link

[Bug] Variable editor broken #32

Closed yesoreyeram closed 2 years ago

yesoreyeram commented 3 years ago

With the recent 6.0 alpha 7 release, the variable queries with nested variables are not working as expected.

magaton commented 3 years ago

Hello, I just hit the same problem. Do you maybe have an idea when it could be fixed?

yesoreyeram commented 3 years ago

@magaton what error you are getting? Can you share more details

magaton commented 3 years ago

Sure, I am having 2 chained variables: year and week. The week values are different every year. Then I am trying to define 'week' variable by query: { Week(filter: { in: { value: $year } }) { value } }

but as soon as I type $year it gets automatically replaced by the selected value for the year. I understood that the bug is reported for this situation.

Another thing: If I specify the invalid return type for the Query variable, the variable editor may go wild, closing itself, and then I need to start from the beginning. Hope this helps.

Screenshot 2021-02-23 at 07 48 01
Saravananalytics commented 3 years ago

@magaton what error you are getting? Can you share more details

Hi, How to add filters using url in variable , To make a common filter for the whole dashboard grafana

kindly help me

Saravananalytics commented 3 years ago

@magaton what error you are getting? Can you share more details

Hi, How to add filters using url in variable , To make a common filter for the whole dashboard grafana

kindly help me

I couldnt get the values in filter preview using infinity , when i was doing with mysql datasource i am able to get. But using infinity plugin i am not able to get. How to achieve, Thanks in advance previewvalue

magaton commented 3 years ago

By using Advanced Options, per the screenshot I posted above. If you don't specify the URL here then the default one from Datasource will be taken

Saravananalytics commented 3 years ago

Can you please explain how to using Dashboard Filters in URL

magaton commented 3 years ago

@yesoreyeram do you plan to fix this issue in 0.7.0?

yesoreyeram commented 3 years ago

yes. this will be the priority for 0.7.0 ( but expect some delay due to time constraints )

magaton commented 3 years ago

Understand. It is not your fault that you wrote an extremely useful plugin :) I am using it with neo4j as database and have days, weeks, months and years modelled as nodes in graph. And I would like to have chained variables that would populate in drop downs: for year 2021, all the months (1-12) for month 12 in year 2021, all the days: 2021-12-01. - 2021-12-31 for year 2020, all the weeks (1-53) for year 2020 and week 15, all the days (dates)

However, I could possibly get those variables as Query from a different datasource. Is there anything already available to your knowledge? Precalculating everything and storing it in a database (e.g mysql) is something I would like to avoid, if possible.

Thank you, Milan

magaton commented 3 years ago

Hello, is this fixed in version 0.7.1 latest?

yesoreyeram commented 3 years ago

Not tested explicitly @magaton . Feel free to test and report

magaton commented 3 years ago

ok, will do. Thank you!

antonbezkrovny commented 3 years ago

Not worked:( any updates?

magaton commented 3 years ago

Tested, it is not working. Variable Editor seems broken. I cannot type in the GraphQL query in URL field. It keeps closing. Hate to ask, but @yesoreyeram do you have any idea when this can be fixed?

yesoreyeram commented 3 years ago

@magaton - Can you try 0.7.3? This have potential fixes. No fixes provided for nested variables yet. But the wild closing behaviour of variable editor and few UX defects should be resolved.

If anything not working as expected, report here please.

francispeixoto commented 3 years ago

I've seen the issue myself, and I was able to bypass it by editing the variables via the dashboard's JSON model directly rather than going through the GUI

gdiana commented 3 years ago

@francispeixoto How and where did you do this? I know how to access the model but if you can use a screenshot it would be useful if you have the time.

wolflumin commented 3 years ago

Encountered a similar issue today where adding any columns wipes the data returned. Entering URL works fine and returns all data in the array but adding a column for any of the selectors causes no data to be returned. Works fine in a panel query--only exhibits the problem in Variables. Grafana v8.1.5 Infinity v0.7.8

howardhhm commented 2 years ago

+1

abferm commented 2 years ago

Similar issue to @wolflumin , everything was working fine in grafana 7.2.1, but when I tried upgrading to grafana 7.4.0 or higher my variable queries stopped working. My dev console shows the data in the api response, but the columns appear to not be selected correctly.

gdiana commented 2 years ago

Similar issue to @wolflumin , everything was working fine in grafana 7.2.1, but when I tried upgrading to grafana 7.4.0 or higher my variable queries stopped working. My dev console shows the data in the api response, but the columns appear to not be selected correctly.

I think the variable editor has been deprecated! To fix would have impacted on too many other things

abferm commented 2 years ago

I think the variable editor has been deprecated!

I didn't even edit the variables, they stopped working when running the same dashboard json on a newer version of grafana.

yesoreyeram commented 2 years ago

If it works previously, it shouldn't have impact. Can you provide reproduction steps and dashboard json please @abferm

chriswiggins commented 2 years ago

Hi, we're having the same issue on our dashboard too. Grafana v8.2.3 and the latest Infinity plugin.

As soon as we add a column into the variable query, it doesn't return any data (as in #181 and #191)

abferm commented 2 years ago

@yesoreyeram I added some screenshots on #191 I managed to reproduce against a public graphql api. See the attached dashboard.

Steps to reproduce:

  1. Run grafana/grafana:7.2.1 docker image, install infinity plugin via environment variable
  2. Load Dashboard json
  3. Observe values for variable
  4. Run grafana/grafana:8.2.3 docker image, install infinity plugin via environment variable
  5. Load Dashboard json
  6. Observe variable value empty except for "None" option
{
  "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"
      }
    ]
  },
  "description": "",
  "editable": true,
  "gnetId": null,
  "graphTooltip": 0,
  "id": 3,
  "iteration": 1635975321610,
  "links": [],
  "panels": [
    {
      "datasource": null,
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "align": null,
            "axisLabel": "",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "drawStyle": "line",
            "fillOpacity": 0,
            "filterable": false,
            "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": 9,
        "w": 12,
        "x": 0,
        "y": 0
      },
      "id": 2,
      "options": {
        "showHeader": true
      },
      "pluginVersion": "7.2.1",
      "targets": [
        {
          "columns": [],
          "csv_options": {
            "columns": "",
            "comment": "",
            "delimiter": ",",
            "relax_column_count": false,
            "skip_empty_lines": false,
            "skip_lines_with_error": false
          },
          "data": "",
          "filters": [],
          "format": "table",
          "global_query_id": "",
          "refId": "A",
          "root_selector": "data.continent.countries",
          "source": "url",
          "type": "graphql",
          "url": "https://countries.trevorblades.com/",
          "url_options": {
            "data": "query {\n  continent(code: \"$country_code\") {\n    countries {\n      name\n      capital\n      phone\n    }\n  }\n}",
            "method": "POST"
          }
        }
      ],
      "title": "Panel Title",
      "type": "table"
    }
  ],
  "schemaVersion": 26,
  "style": "dark",
  "tags": [],
  "templating": {
    "list": [
      {
        "allValue": null,
        "current": {
          "selected": true,
          "text": "Antarctica",
          "value": "AN"
        },
        "datasource": "Infinity",
        "definition": "Infinity- (infinity) ",
        "description": null,
        "error": null,
        "hide": 0,
        "includeAll": false,
        "label": "Country",
        "multi": false,
        "name": "country_code",
        "options": [],
        "query": {
          "infinityQuery": {
            "columns": [
              {
                "selector": "name",
                "text": "name",
                "type": "string"
              },
              {
                "selector": "code",
                "text": "code",
                "type": "string"
              }
            ],
            "csv_options": {
              "columns": "",
              "comment": "",
              "delimiter": ",",
              "relax_column_count": false,
              "skip_empty_lines": false,
              "skip_lines_with_error": false
            },
            "data": "",
            "filters": [],
            "format": "table",
            "refId": "variable",
            "root_selector": "data.continents",
            "source": "url",
            "type": "graphql",
            "url": "https://countries.trevorblades.com/",
            "url_options": {
              "data": "# Write your query or mutation here\nquery{\n  continents{\n    name\n    code\n  }\n}",
              "method": "POST"
            }
          },
          "query": "",
          "queryType": "infinity"
        },
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "tagValuesQuery": "",
        "tags": [],
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      }
    ]
  },
  "time": {
    "from": "now-6h",
    "to": "now"
  },
  "timepicker": {},
  "timezone": "",
  "title": "Countries Copy",
  "uid": "sKxlaEFnk",
  "version": 4
}
jameskirsop commented 2 years ago

Is there a sample Dashboard JSON that serves as a 'workaround' for this issue as mentioned by @yesoreyeram in this comment?

I'm not sure what such a workaround should look like in a JSON representation and having something that could be used as a template to build our own would be helpful.

Perhaps, however, as per the above sample from @abferm this just doesn't work in current releases of Grafana even with manual modification of the JSON. Noting that I've tried manual modification using the above sample as a guide and can't get it to work as expected in Grafana v8.2.3.

yesoreyeram commented 2 years ago

v0.8.0 should fix these issues. Let me know if anyone still having issues.