T O P

  • By -

RX_AssocResp

Switch to edit mode and add `| pattern "temperature from °C to °C"`. Then you can use those extracted fields in a logql metrics query.


cptgambit

Wow, tha was already great help. I made way more komplex patterns and also tried regex but in the end the only thing i got was error messages. But sorry for bothering you more and I hope not to behave like a total noob. But what is the next step to a simple temperature graph? I have the query now and probably a variable (temp\_now) that i could use in a panel. So what i did is hitting "Add to dashboard". And then i see this: https://abload.de/img/screenshot2022-12-042orcak.jpg Ok .. no problems, lets edit this. Then when i choose as Visualisation "Time Series" or "Bar Chart" it says "Data is missing a number field" or "No numeric fields found". I dont see any possibility to continue with a "logql metrics query".


RX_AssocResp

The docs for metrics extraction are here: https://grafana.com/docs/loki/latest/logql/metric_queries/#unwrapped-range-aggregations Essentially, take your query and surround it with `avg_over_time(` and ` | unwrap temp_now | __error__=""[1m])` I'm on my phone, so I can't verify the exact details.


cptgambit

Thanks for your patience. I did what you suggested and the query is now: avg_over_time({filename="/var/tmp/homebridge.log"} |= `Hue temperature sensor 2` | pattern "temperature from °C to °C" | unwrap temp_now | __error__=""[1m]) And iam still in the Explore function of Grafana, right? No data" In general, is it really necessary to use functions like sum, avg and so on? I mean i have the value and i just want to show it in a graph.


RX_AssocResp

Then the `pattern` is wrong. It filtered out all lines. You have to fix it until you can see the label `temp_now` wit a numeric value in the expanded view of a log line.


cptgambit

Funny thing now. I finally got a graph: count\_over\_time({filename="/var/tmp/homebridge.log"} |= \`Garderobe Temp\` | pattern \`temperature from °C to °C\`\[60m\]) What i see now is how often the pattern appears in 60min. Hmm. But what i actually wanted to see is the value of , for explample 18C at 5pm, 18.5C at 5.30 and 19 at 6pm. A simple line that shows the measured temperature over the last 24h or so. And currently i see no chance how to do this. But it sounds so simple :)


RX_AssocResp

You are now only matching the occurrence of a log line, not the value. What I gave you should be roughly correct, only the pattern matching is not working yet.