Start and end parameters in query label_values ​(filename) loki

Viewed 2295

I am setting up a logs grafana dashboard, and I would like to dynamically load the files that are generated in the logs directory into the dashboard selection variable via loki datasource.

I can load, but only log files that undergo modification are loaded.

After 1 day no longer appear.


26/11

Input dashboard

27/11

enter image description here


Know that api loki/api/v1/label/filename has the parameters start end

Loki API Documentation

Consulting the api, I have the expected results

enter image description here

How can I pass these parameters in the query label_values(filename)?

enter image description here

I've tried label_values({start: 1603506254000000000, end: 1607506254000000000}, filename), but it didn't work.

enter image description here

Would I have a way to spend an initial and final period, so that I could see all the files for the current month?


UPDATE:

I forwarded the question to github grafana / loki and it looks like an implementation that will be done in the future. https://github.com/grafana/loki/issues/3011

1 Answers

And log files that listed, after 1 day no longer appear.

I guess this is happening because in your config Grafana refreshes labels when dashboard is loaded. Probably Grafana takes labels from records loaded from Loki. And since the number of these records is limited (1000 by default), you are able to see only the most recent labels. You can try to increase this limit in data source config to check if my guess is correct and more labels appear.

Alternatively, you could try to refresh labels on time range changed (see the pic below), then proper labels should appear when you select the time range when they arrived on you dashboard. The query still would be label_values​(filename).

on time range change.

Related