VictoriaMetrics / victorialogs-datasource

Grafana datasource for VictoriaLogs
Apache License 2.0
67 stars 2 forks source link

error decode response: invalid character 'x' in string escape code #24

Open Proxymiity opened 3 weeks ago

Proxymiity commented 3 weeks ago

Hi,

When using the latest version of VictoriaLogs (0.18.0 as of today, after upgrading from 0.7.0), the datasource stops working. A simple _time:5m or host:test-server returns a decoding error in the panel: error decode response: invalid character 'x' in string escape code

No specific error logged in the VictoriaLogs server itself, but the Grafana log has some errors:

GRAFANA  | logger=plugin.victorialogs-datasource t=2024-06-11T12:50:04.627607298Z level=error msg="error decode response: invalid character 'x' in string escape code"
GRAFANA  | logger=context userId=2 orgId=1 uname=*** t=2024-06-11T12:50:04.627862706Z level=info msg="Request Completed" method=POST path=/api/ds/query status=400 remote_addr=*** time_ms=105 duration=105.622792ms size=139 referer="http://***/d/bdoghm58zwdmof/test-panel?editPanel=2&orgId=1" handler=/api/ds/query status_source=downstream

The query itself works fine in the vmui. Datasource is on 0.2.1, and when added replies with "This datasource is working". Rolling back to our known working vlogs version (0.7.0) works well, however we lose new features of the query language.

rkaracic commented 2 weeks ago

Hi,

I'm having same issue as you. Latest working version for us is 0.15, DS is on latest version (0.2.1).

Maybe this additional info will help someone: E.g. query "instance:hostname" will not work, but if I query it like "hostname AND instance:hostname" this will work. It's ugly workaround, but maybe someone will find it useful.

hagen1778 commented 1 week ago

@dmitryk-dk is this related to the backend of the plugin?

dmitryk-dk commented 1 week ago

Hi @Proxymiity ! Can you share what version of the VictoriaLogs you have? Can you share an example of your response from the VMUI you have? This information can help us to detect the problem

Proxymiity commented 1 week ago

Hi,

Sure. The version that does not work is 0.18.0, but the same thing happens with 0.23.0. Here's a screenshot of the VMUI with the request: image

And here's what's in the Grafana panel request: image

The Grafana variable is defined as follows: image

(replacing the Grafana $host variable with the actual host:xxxxxx-test does not change a thing)

Proxymiity commented 1 week ago

FYI, I have a working panel with that version. Some are returning "no data" because there is no data in the timerange (which is expected), one is returning data correctly, and some are erroring with the same error you'd find within the first issue comment

dmitryk-dk commented 1 week ago

FYI, I have a working panel with that version. Some are returning "no data" because there is no data in the timerange (which is expected), one is returning data correctly, and some are erroring with the same error you'd find within the first issue comment

It would be helpful if you could share the response in JSON and remove sensitive data when you get that error. I will try to reproduce the issue. There are used standard JSON decoders, and I think the problem is with parsing response from the victoria logs. But it is only my assumption

Proxymiity commented 1 week ago

It would be helpful if you could share the response in JSON and remove sensitive data when you get that error. I will try to reproduce the issue. There are used standard JSON decoders, and I think the problem is with parsing response from the victoria logs. But it is only my assumption

By response, do you mean intercept the response from VLogs back to Grafana?

dmitryk-dk commented 1 week ago

It would be helpful if you could share the response in JSON and remove sensitive data when you get that error. I will try to reproduce the issue. There are used standard JSON decoders, and I think the problem is with parsing response from the victoria logs. But it is only my assumption

By response, do you mean intercept the response from VLogs back to Grafana?

Yes, or response from vmlogs to vmui. They should be identical.

Proxymiity commented 1 week ago

Here are the responses from both VictoriaLogs versions (mind the dot at the end of the url): 0.7.0: https://m.iya.at/hLfWw. 0.21.0: https://m.iya.at/hHZ76.

dmitryk-dk commented 1 week ago

Here are the responses from both VictoriaLogs versions (mind the dot at the end of the url): 0.7.0: https://m.iya.at/hLfWw. 0.21.0: https://m.iya.at/hHZ76.

Thank you for providing examples. I will check it soon

dmitryk-dk commented 4 days ago

Hi @Proxymiity , I think I found the problem and made a draft fix; if you can build a source from my PR and test it, that would be great. I will check the fix on my own

Proxymiity commented 4 days ago

Hi @Proxymiity , I think I found the problem and made a draft fix; if you can build a source from my PR and test it, that would be great. I will check the fix on my own

Hi, thanks for the quick draft. I will look into building the plugin and will keep you informed.

Proxymiity commented 2 days ago

Hi, just compiled and tested your fix. It does not error out anymore, but instead the color has vanished.

Here's vlogs 0.27.0 and your patch: image

Here's vlogs 0.7.0 and your patch: image

dmitryk-dk commented 2 days ago

@Proxymiity, the logs sent from vlogs only proxied to the UI part of the data source, I will think about how it is better to handle those values with colors. I think it should be handle on the UI part of the plugin @Loori-R , @hagen1778 wdyt?

@Proxymiity, can you also share the Grafana version that you are using?

valyala commented 2 days ago

This issue must be fixed in VictoriaLogs v0.27.1. The bugfix is at https://github.com/VictoriaMetrics/VictoriaMetrics/commit/c0caa6993903a748c8942c8c28b5901ee6d5f4d4 .

@Proxymiity , @rkaracic , could you upgrade VictoriaLogs to v0.27.1 and verify whether the issue is fixed there?

clrxbl commented 2 days ago

This issue must be fixed in VictoriaLogs v0.27.1. The bugfix is at VictoriaMetrics/VictoriaMetrics@c0caa69 .

@Proxymiity , @rkaracic , could you upgrade VictoriaLogs to v0.27.1 and verify whether the issue is fixed there?

I've had this issue aswell but after upgrading to 0.27.1, it went away.

rkaracic commented 2 days ago

I can confirm that issue is gone in 0.27.1

hagen1778 commented 1 day ago

The problem was fixed on the backend side by VictoriaLogs. Additionally, plugin now understands unicode and ANSI chars thanks to https://github.com/VictoriaMetrics/victorialogs-datasource/pull/38.