grafana / grafana

The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
https://grafana.com
GNU Affero General Public License v3.0
64.51k stars 12.08k forks source link

Loki: Add support to Query-result type of Variables #76612

Open matyax opened 1 year ago

matyax commented 1 year ago

Support to add a dashboard variable with the query-options set by querying Loki, using the Query-type "Query result".

This is available in Prometheus, but still not available in Loki. The Prom datasource teaches the user to expect that it is possible, so having support for this would not only be useful but also create a cohesive experience between tools.

Image

Image

ThommyH commented 10 months ago

came here to say this would be awesome to have

matyax commented 10 months ago

@ThommyH Thanks for the +1 on this. If possible, could you briefly describe your use case for this feature?

ThommyH commented 10 months ago

We have just started with frontend observability using FARO and added the example dashboard.

Here we would like to drill down the metrics per client, which we can identify easily through their own url. Also we would like to generate filter per path. Therefore, we would like to create variables from loki logs rather than loki labels. For this we would require at least logfmt to dynamically create labels.

Another example would be dashboards which filter logs based on a list of clients. Right now we either get the client names through a custom field in the dashboard or through recording rules, which generate prometheus metrics, where we can use the labels for variables, which are then used to filter loki queries. Quite some unnecessary workaround if you'd ask me :)

matyax commented 10 months ago

Perfect. Thank you @ThommyH ! I'll share this with the team.

ThommyH commented 10 months ago

In the meantime I added a workaround for our dashboards by adding a custom label to all queries and making use of ad hoc filters which can be created dynamically by clicking values in tables. Not perfect, but gets me to the result for now :). Main problem is that every query in the dashboard needs have the boilerplate for adding the custom label in order to work.

Thank you for sharing this with the team, I highly appreciate this :+1:

davideLarosa commented 1 week ago

Hi mates, is there any news about this feature? I'm trying to create a dashboard for Openshift that, based on audit logs, should be able to show actions filtered by users. But to get the "by user", i would like to set the user as a variable this way the dashboard can be generic and not dedicated to a single cluster.

Thank you! Cheers