Ad-hoc Filter in InfluxDB 2.0

I am using InfluxDB 2.0 and flux language for writing the queries.
I am using Grafana-Cloud for visualizing the queries.
I am trying to create the ad-hoc filters but nothing comes in the ad-hoc filter.

It always shows no options found.

whole dashboard work file and I have used many template variables as well and everything works fine but the ad-hoc filter is not working at all.

Do Ad-hoc filters support InfluxDB 2.0? If yes, then what I am doing wrong so I am not getting any values.

Thanks

@gautamravikant6

I would start by researching our docs:

according to it ad-hoc queries are supported for influx.

This forum is also a valuable resource for these sorts of questions :+1:

Hi everyone,

I am facing a similar issue using the following setup:

  • Grafana Open Source version 10.0.1
  • InfluxDB version 2.7.1
  • Query Language: Flux

When using a variable of type adhoc filter on a dashboard, the dropdown list stays empty showing “No options found”. When looking at request at response I get the impression that InfluxQL is used instead of Flux. Might this cause problems and is there a way to change the behavior?

Thanks in advance

Request:

{
    "queries": [
        {
            "refId": "metricFindQuery",
            "query": "SHOW TAG KEYS",
            "rawQuery": true,
            "datasource": {
                "type": "influxdb",
                "uid": "xxx"
            },
            "datasourceId": 1
        }
    ]
}

Response:

{
    "results": {
        "metricFindQuery": {
            "error": "invalid: error @1:1-1:5: undefined identifier SHOW\n\nerror @1:6-1:9: undefined identifier TAG\n\nerror @1:10-1:14: undefined identifier KEYS",
            "status": 500,
            "frames": [
                {
                    "schema": {
                        "refId": "metricFindQuery",
                        "meta": {
                            "typeVersion": [
                                0,
                                0
                            ],
                            "executedQueryString": "SHOW TAG KEYS"
                        },
                        "fields": []
                    },
                    "data": {
                        "values": []
                    }
                }
            ]
        }
    }
}

Welcome @gamdschie

Your request is using InfluxQL instead of Flux. A Flux request for a varaible to display the values of the tag “EquipNumber” on a dashboard would look like this:

import "influxdata/influxdb/schema"
schema.tagValues(
    bucket: "bucket_name",
    tag: "EquipNumber"
)

Hi @grant2 ,

thanks for your quick reply. My understanding is that the request is generated automatically by Grafana when clicking “+” to use the ad hoc filter on the dashboard:

I defined the following variable for the ad hoc filter:

Unfortunately I do not see a way to modify the request, because no query can be defined for a variable of type “ad hoc filter”. Am I wrong here?