From loki to chart problem

Dear all

I need to plot a simple chart with “time” on X-Axis and “value” on “Y-Axis”.
This is the simple LogQL query:

and then I’ve applied some “transformation” to obtain two columns:

but It doesn’t work.

I think that the problem could be the “date_time” is not interpreted as “time” for X-Axis. How I can fix it?

Thank you,

You should expect the timestamp to come from the query results directly, so the only thing you need to supply is the value itself.

Try this, first change the last part of your query to:

... | line_format `{{ .value | replace "," "" }}`

And in the transform tab, transform the line value to numeric:

Thanks for replay @tonyswumac

The problem is exactly the timestamp; it is extracted from the query (with:

… | label_format ts={{.date}}T{{.time}}

but It is “string” and not timestamp.

In other words, as shown In the image below, I need to use my ts value (“B” selection) instead of the default value (“A” selection); “B” is timestamp into my log files, “A” is the timestamp of line inserted into the Loki.

I think you should look to fix the timestamp issue during log ingestion. From your log agent, you should do minimum parsing necessary to get the timestamp so your logs can be sent to Loki with the correct timestamp instead of the timestamp of the log ingestion.

That is the approach I’d take. Otherwise you are stuck trying to manipulate query which I don’t think should be something that you (or any of your user) should have to worry about when querying for logs.

1 Like

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