-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Loki count_over_time null handling goes wrong #4420
Comments
FYI: originally posted in the #loki Slack channel: https://grafana.slack.com/archives/CEPJRLQNL/p1632298704148900 |
@BitProcessor I wasn't able to reproduce it with Loki 2.3.0 but it happens with latest Loki docker image. It's caused by difference in Loki response - Example api call: Results: {
"status": "success",
"data": {
"resultType": "matrix",
"result": [],
"stats": {
"summary": {
"bytesProcessedPerSecond": 0,
"linesProcessedPerSecond": 0,
"totalBytesProcessed": 0,
"totalLinesProcessed": 0,
"execTime": 0.0029421
},
"store": {
"totalChunksRef": 0,
"totalChunksDownloaded": 0,
"chunksDownloadTime": 0,
"headChunkBytes": 0,
"headChunkLines": 0,
"decompressedBytes": 0,
"decompressedLines": 0,
"compressedBytes": 0,
"totalDuplicates": 0
},
"ingester": {
"totalReached": 1,
"totalChunksMatched": 0,
"totalBatches": 0,
"totalLinesSent": 0,
"headChunkBytes": 0,
"headChunkLines": 0,
"decompressedBytes": 0,
"decompressedLines": 0,
"compressedBytes": 0,
"totalDuplicates": 0
}
}
}
} latest: {
"status": "success",
"data": {
"resultType": "matrix",
"result": null,
"stats": {
"summary": {
"bytesProcessedPerSecond": 0,
"linesProcessedPerSecond": 0,
"totalBytesProcessed": 0,
"totalLinesProcessed": 0,
"execTime": 0.0099657
},
"store": {
"totalChunksRef": 0,
"totalChunksDownloaded": 0,
"chunksDownloadTime": 0,
"headChunkBytes": 0,
"headChunkLines": 0,
"decompressedBytes": 0,
"decompressedLines": 0,
"compressedBytes": 0,
"totalDuplicates": 0
},
"ingester": {
"totalReached": 1,
"totalChunksMatched": 0,
"totalBatches": 0,
"totalLinesSent": 0,
"headChunkBytes": 0,
"headChunkLines": 0,
"decompressedBytes": 0,
"decompressedLines": 0,
"compressedBytes": 0,
"totalDuplicates": 0
}
}
}
} |
No it's not expected. |
Can I move this issue to Loki's repo? |
Query http handler is wrapped with so many middleware for different purposes. We want `serverutil.JSONMiddleware` to be wrapped on top of `serverutil.NewPrepopulatedMiddleware`, reason being, we `PrepopulatedMiddleware.next` to have proper `Content-Type` set with `application/json; charset=UTF-8`. without that, empty array response are convertion into `null` value in the HTTPResponse. Fixes: #4420 Signed-off-by: Kaviraj <[email protected]>
@BitProcessor @ifrost Can you confirm you seeing this issue when running Loki in single binary mode? This PR #4457 fixes it! |
@kavirajk @cyriltovena see #4457 (comment) |
@BitProcessor Thanks for confirming!. It's odd though that I couldn't reproduce the issue with v2.3.0 (but only on the tip of the main branch that also only on single-binary mode). I re-opened the issue. I will dig deep to see if I missed anything!. |
@kavirajk it was happening for me on docker image when running a query with a narrow time range. I just checked the latest docker image and it's working fine 👍 Just to double check I also quickly compared with some older image (7 days old |
Hi! This issue has been automatically marked as stale because it has not had any We use a stalebot among other tools to help manage the state of issues in this project. Stalebots are also emotionless and cruel and can close issues which are still very relevant. If this issue is important to you, please add a comment to keep it open. More importantly, please add a thumbs-up to the original issue entry. We regularly sort for closed issues which have a We may also:
We are doing our best to respond, organize, and prioritize all issues but it can be a challenging task, |
If this was fixed, a bit of feedback might have been nice? |
This was not fixed. It was automatically closed by the stale bot. It should be reopened. |
Hey @darxriggs, the original issue was reported on quite old versions of Grafana and Loki, are you still seeing it on the latest versions of both? |
Loki 2.5.0 in single binary mode returns It have tried queries like:
After reading the details of this issue again, I understand that returning an empty array instead of I have had also #5074 in mind which was already mentioned here. It is about the same function but a different expected output. |
hey @darxriggs @BitProcessor thanks for confirming the fix! Apologies about the stalebot, we try our best to keep up but sometimes we don't get to everything. The stalebot does help us when issues go abandoned but it's an imperfect science. |
Is there a way to make the resulting [] be displayed as 0 on a Time Series widget? |
@rafaelpirolla Try adding a second Loki query that outputs a value of 0 at all times, next calculate the result and replace the final value. |
This doesn't work when showing multiple lines, e.g. with the 'by' operator. |
I think too that need to count no data as null, because it can be used in alerting for no data from pods/containers.
In this case, this query will return containers and pods with no logs from it. |
Maybe implemented by #7023 |
What happened:
When running the following Loki query in an Explore window:
sum(count_over_time({namespace="my-namespace", container="my-container"} | json | __error__ = "" | level="ERROR" [$__range]))
(or
sum(count_over_time({namespace="my-namespace", container="my-container"} | json | level="ERROR" | __error__ = "" [$__range]))
)where the resulting set is empty (as in: no logs found with level ERROR in the selected range), an error occurs:
Both Safari 15.0 and FF 92.0 throw a JS error:
Resulting in (Safari vs Firefox):
Adding the same query to a Stats panel, results in:
with the error in the left top, showing the same error as mentioned above.
What you expected to happen:
A sum over a count of logs should result in 0 when no logs are found?
(instead of null)
How to reproduce it (as minimally and precisely as possible):
Run a Loki
sum(count_over_time())
over a set of logs that returns no results in the select rangeAnything else we need to know?:
Environment:
The text was updated successfully, but these errors were encountered: