Parsed JSON logs to Grafana Chart

Hello,
I have logs stored in JSON in Loki. I store in my logs the money available on a user account at a time T.
I would like to be able to display in my Grafana a chart representing the evolution of the customer balance.
Here is how I tried it:

{application="BinanceProxy",type="BalanceUpdate",userId="4561"} | json usdt_balance="message.balanceItems[0][walletBalance]" | line_format "{{ .usdt_balance }}"

With this LogQL query, with a graphical representation with Grafana’s “Logs” widget, I do have the expected result, I only have the balance. See:

However, when I switch to Chart mode, Grafana tells me that it is impossible to display.
So I tried to switch to Table mode to see what was wrong, and here is the result:

What I did wrong ? Any solution for this problem?
Thanks a lot, I love Loki and Grafana !

@Jujujul try applying transformations to the Table visualisation:

image
You can then filter to only show the columns (labels from Loki).
You won’t need to keep your line_format here.

Thank you for your answer.
I did what you advised and it looks much better!

However, when I switch to Graph mode, I always get this message: Unable to graph data.

So I tried to rename my ‘ts’ column to ‘Time’ as you can see in the screenshot above. But still not.
I looked in the “debug” button from my last transformation, and I could see that my ‘amount’ column was a string. I wonder if the problem would not come from there, maybe I should cast the value in decimal ?

So I tried this :
( Image in my next post because “News users can only embed 2 image in their post” )

but I’m not sure it’s the best way to do it. I can’t find the value of my column when I’m in hover mode over the chart as you can see on the graph above. Another alternative or is this the best way to go?

Thanks you very much

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.