Json Logql query for getting multiple line graphs grouping by a single json key

132 Views Asked by At

new to logql here.

This is a sample json log line I have:

{
"accessedts":1696477777255,
"command":"get_user_details",
"country":"US",
"referrer":"google",
"status":"SUCCESS",
}

I am trying to write a simple logql query which will give me multiple line graphs, each representing the rate for a country (grouping by the country field. there would be mulitiple countries in the logs) and doing the same for the referrer.

So the end expectation would be to have a line graph per country which represents the rate.

I was trying something like this (but did not work):

sum by (country) (rate({namespace="mynamespace"}| json | __error__!="JSONParserErr"[10m]))

I can see all my logs when I query for {namespace="mynamespace"} in the explorer.

Would you know how I could write a query for this ?

0

There are 0 best solutions below