Questions tagged [logql]

LogQL is a query language for Grafana Loki, similar to PromQL for Prometheus. This tag should be added to questions about crafting query to Grafana Loki. Consider also adding the `grafana-loki` tag.

56 questions
2
votes
1 answer

Count number of unique values using Loki LogQL

I have a log stream that has a UserID= label. I'm trying to count the number of unique users within an hour. Here's an example of my log stream: ts=2022-09-16T10:52:54.21344541Z level=INFO UserID=65166…
TheEdgeOfRage
  • 565
  • 1
  • 8
  • 21
2
votes
0 answers

Get unique fields list in grafana LogQL

My query : ({job="spring-service"} | json | url = "/user/login") I'm trying to get all the unique user id's from logs and not the count. But I couldn't, its easy to get count of the fields.
Revanth G
  • 21
  • 1
  • 3
2
votes
2 answers

Combining multiple log lines from Loki in Grafana

I have stream of http logs (fastify pino format) via Loki that look like: [2022-07-25T16:59:40.796Z] INFO: incoming request…
hardillb
  • 54,545
  • 11
  • 67
  • 105
2
votes
0 answers

Create Grafana Table Dashboard from Loki logs on Pytest results

I am quite a beginner with this, but I spent quite an amount of time already. I am trying to create a Table in Grafana from Pytest results from a Grafana Loki data source. There are multiple pytest tasks running at the same time. Thus, the table…
Strongman
  • 51
  • 1
  • 1
  • 3
2
votes
1 answer

Use variables on grafana loki queries (LogQL)

I have succesfully installed Loki on a server and Promtail on multiple hosts of my datacenter. Each host runs a different number of tomcats, like tomcat10, tomcat11...tomcat20. So on promtail, my job gets a label with the hostname and __path__ is…
user2087103
  • 141
  • 2
  • 13
2
votes
2 answers

How to plot max-in-1h-window of rate-per-1-second of events in Grafana?

We have a rate limit of 500 fetches per second from an external API. I want to track how close are we to this limit as the user base grows on a scale of weeks. I don't need the exact rate every second, I need the maximum 1-second-rate in a 1 hour…
2
votes
0 answers

How do you extract and manipulate multiple values from log lines via LogQL for graphing?

I have a system that imports records into a database and then logs the import duration as hh:mm:ss.fffffff. These logs are imported into Loki, and I'm trying to create a graph of the import times in Grafana. Below is a sample log…
Eddie Deyo
  • 5,200
  • 8
  • 35
  • 35
1
vote
1 answer

How to determine which services did not send logs in the last 24h Grafana Loki LogQL

My company has a lot of customers, each having 1 or more services. Each of these services sends logs to a loki server. Each Service is unique by the combination of the 2 labels customer_id and service_name. I would like to have a grafana panel that…
1
vote
1 answer

Parse LogQL substring as JSON

Is it possible to apply | json to a substring of a log line? Example Log line 2023-07-17T19:24:51:…
sdc
  • 2,603
  • 1
  • 27
  • 40
1
vote
1 answer

filter filenames in logql (grafana), extracted from multiple subfolders

I am building a dashboard in grafana, and previously, my queries to get the logs were: {filename=~"/var/logs/tfc/local/reportserver+.+"} This was to get all rotated files from the reportserver logs. Now there may be other servers sending their logs…
PhoenixBlue
  • 967
  • 2
  • 9
  • 26
1
vote
1 answer

How do I unwrap multiple labels in a LogQL query?

I have the following LogQL query: sum_over_time({filename=~".+Notifications.+", log_level="INFO"} |~ "(SentNotifications|DeliveredNotifications)" | regexp "message=\"SentNotifications\", NotificationCount=\"(?P\\d+)\""…
John Grieb
  • 15
  • 3
1
vote
0 answers

Conditional filtering logs in Grafana

I have a Loki instance connected as data source to Grafana collecting the log records from a web-app. Only some of those logs related with web-server contain "request_id=XYZ" and I would like to filter out specific log records using $request_id…
BaqBak
  • 15
  • 4
1
vote
1 answer

How to write an IF in LogQL query?

In Grafana I added an Exclude parameter to the Dashboard. If the Exclude field is empty, I would want it to do nothing, otherwise exclude lines that contain the regex in Exclude field. I would want to write something like: {label="this"} ( if…
KamilCuk
  • 120,984
  • 8
  • 59
  • 111
1
vote
1 answer

grafana logql query using line_format and regexReplaceAll dynamically

I need to read my logs just like they were displayed in the application console. My grafana LogQL query looks like this : {job="myjob", host="myserver"} | json | line_format `{{ regexReplaceAll "{(.*?)}" .MessageTemplate "{{.Properties_${1}}}"…
A_V
  • 362
  • 1
  • 3
  • 19
1
vote
0 answers

Is there any way to enable/disable log queries in Grafana based on a multi-variable?

I have a Grafana dashboard with a Logs panel. The panel has 3 separate queries: A, B & C. Each query filters the log data in a different way and displays the results in a different way. Having all 3 queries in the same panel rather than in separate…
Biggles
  • 21
  • 2