Ad-hoc filters for a custom plugin

hi everyone.

I’m developing a custom datasource plugin. I have the basics working and now trying to implement ad-hoc filters for it.

I have several questions:

  1. first of all I couldn’t find any real documentation about it. only some commit comments on github.

    is there real howto or doc somewhere?

  2. looking at the elastic and influxdb implementation I see that getTagKeys supposed to return array of {text: .., type: ...} and getTagValues returns array of `{text: …, value: …}

    but… looking at the implementation in public/app/features/dashboard/ad_hoc_filters.ts I don’t see type and value actually used.

    in the plugin that I’m developing it would be really helpful if I could have different text and value for the TagValues, but so far I couldn’t figure out a way to make it work. values do not show up in templateSrv.getAdhocFilters

  3. is there a way to customise dropdown options for condition and operator?

  4. Is there a way to access current range while computing TagKeys and TagValues? I’d like to eliminate the options that do not exist in the current range from the dropdown.

  5. in general, is there a proper way to report errors from datasource plugin to the user? for example, if a user overwrites condition or operator to something that the plugin doesn’t support, is there a way to display a nice error message?

Thanks in advance for the help.


  1. no documentation for the internals of this feature

  2. different text / value is not supported

  3. no

  4. yes, use timeSrv

  5. you can return an error, or use alertSrv or send an appEvents.emit(‘alert-error’