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
1
vote
2 answers

Create daily ingestion alerts on Grafana LOKI for top clients sending logs

Is there any way to know how much data is being pushed to Grafana Loki by each application?
vyshak m
  • 131
  • 1
  • 7
1
vote
1 answer

Add 2 fields in LogQL to use within aggregate function

I have log lines that contain a few timestamp fields. Here is an example of log line I am filtering in order to process it: { "time": "2022-06-22T10:33:08.710037238Z", "@version": "1", "message": "Duration at response processing ends", …
MarkoPaulo
  • 474
  • 4
  • 19
1
vote
1 answer

Handle JSONParserErr with line_format

Нello, I have some log streams that unfortunately are a mix of both json and non-json items; e.g. (every line is a separate item): { msg: "User 'bob' logged in", noisy: "context", please: "ignore this attribute" } { msg: "User 'bob' called api…
Gershom Maes
  • 7,358
  • 2
  • 35
  • 55
1
vote
0 answers

sort nginx logs with loki logql against request_time field

this is my logql query {namespace="ingress-nginx"} | json | http_host="admin.site.com" and request_time > 20 and status!="499" | line_format "status={{.status}}\t request_time={{.request_time}}\t {{.request}}" I get the following…
DmitrySemenov
  • 9,204
  • 15
  • 76
  • 121
1
vote
1 answer

How to sort 500-511 HTTP errors in a file produced daily on Grafana using Loki as Datasource

How to grep for only 500 errors (500-511) in a file that is created daily with date stamp in file name. These files are configured to be pushed by promtail agent to Loki server so I can visualize them on Grafana. The files are being produced daily…
1
vote
1 answer

How to slice the string using logql?

I have values in my logs in grafana loki something like this data 1234-02-01,12:30,1 data 1234-03-02,11:30,12 I am able to slice these values and separate date and time from this using trunc but I don't seem to do for the last value because it…
user12252991
  • 105
  • 1
  • 9
1
vote
2 answers

Grafana/Loki: How to use multi-select template variable with LogQL?

I have a custom template variable that displays the following comma seperated values: info, error, warning, debug. The name of the variable is $Level with multi-select enabled. I need it to have so when you select more than 1 value the line filter…
FestiveHydra235
  • 473
  • 1
  • 7
  • 23
0
votes
1 answer

Facing an issue with time ranges in queries

Can someone help me understand how to query for different specific time ranges in Grafana? I'm using count_over_time, and I want to subtract the count of systems that sent the lines "Timestamp" in the last hour from the count of systems that sent…
0
votes
0 answers

Create Grafana Alert when a string matches after a string in time period of 30 seconds

I need to create an alert on MSTeams when my application gateway restarts or get failed due to any reason. I have found that in logs for every restart there are logs having string: 'BEGIN AppGateway deployment' and 'END AppGateway deployment' in a…
0
votes
0 answers

Loki summing up the parsed value from two different application

I have two applications printing the logs, the message ID is same in both the app logs. I have the extract the the processing time and sum both the time and get the value as 1050. Logs: app1: Record id:xxxxx-0 :: Message id:**xxx-xxx-xxxx-xxxx-1**…
Saran Raj
  • 1
  • 1
0
votes
0 answers

How to return a zero vector in Loki LogQL metric query when grouping is used and result would be No Data?

I have the following Loki query: I want to use this to create a Grafana alert that alerts when "somelog" appears in the log. sum by (namespace) (count_over_time({namespace=~"something.+", container="backend"} |= "somelog" [$__range])) It correctly…
0
votes
1 answer

How to get the amount of unique labels in a Loki/Grafana Query

for some context we migrated from Elastic/Kibana to Loki/Grafana and imported several years of logs, all is going well, I can query the logs and explore as expected. Now I'm in the process of building the dashboards we had in Kibana and I'm having…
0
votes
0 answers

How can I improve Loki line_format output to include an embedded html link?

I'm using Grafana loki to monitor squid proxy logs and then I run the following query on them to determine the exact youtube URL visited. (In order for this to work, I've installed a man in the middle…
0
votes
2 answers

build a dashboard in logs counting how many time each log appears

Loki Log click the log screenshot attached here i have get logs with this query {namespace="health-helper-stg"} |json | line_format "{{.log}}" There are multiple logs with different msg types from multiple apps. So i need to get count of each msg…
0
votes
1 answer

in Grafana how to pass a search query to search two strings with OR operator in logs?

{app="overflow"}|="Checking error 1" OR |="Checking warning 1" OR |="Checking info 1" I tried this one it was not working. Please let me know what can be tried to have two strings searched up in one query. Thanks.