Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error executing query: parse error at char 31: unknown escape sequence U+0020 ' ' #3010

Closed
Keleir opened this Issue Aug 1, 2017 · 4 comments

Comments

Projects
None yet
3 participants
@Keleir
Copy link

Keleir commented Aug 1, 2017

What did you do?

I have gathered some window system metrics via snmp_exporter, and got these value as following:

# HELP hrStorageUsed The amount of the storage represented by this entry that is allocated, in units of hrStorageAllocationUnits. - 1.3.6.1.2.1.25.2.3.1.6
# TYPE hrStorageUsed gauge
hrStorageUsed{hrStorageDescr="C:\\ Label:  Serial Number 40663d48"} 5.399618e+06
hrStorageUsed{hrStorageDescr="D:\\ Label:  Serial Number 54e7a6b6"} 650729
hrStorageUsed{hrStorageDescr="Physical Memory"} 18596
hrStorageUsed{hrStorageDescr="Virtual Memory"} 19331

# HELP hrStorageSize The size of the storage represented by this entry, in units of hrStorageAllocationUnits - 1.3.6.1.2.1.25.2.3.1.5
# TYPE hrStorageSize gauge
hrStorageSize{hrStorageDescr="C:\\ Label:  Serial Number 40663d48"} 7.838207e+06
hrStorageSize{hrStorageDescr="D:\\ Label:  Serial Number 54e7a6b6"} 2.6213887e+07
hrStorageSize{hrStorageDescr="Physical Memory"} 262135
hrStorageSize{hrStorageDescr="Virtual Memory"} 384577

But when I use this metric to present a Singlestat of disk usage with grafana, it occurs problem:

singlestat_error
The error info is:

{
  "status": "error",
  "errorType": "bad_data",
  "error": "parse error at char 31: unknown escape sequence U+0020 ' '",
  "message": "parse error at char 31: unknown escape sequence U+0020 ' '"
}

My opinion is that the label value hrStorageDescr contains some special characters just like C:\\ Label: Serial Number 40663d48 which makes the promsql query crash.

So I paste the query exprssion into prometheus's own query box, It also the same promble:

prom_error

Environment

  • Prometheus version: 1.7.1
@gouthamve

This comment has been minimized.

Copy link
Member

gouthamve commented Aug 1, 2017

Hi I think you need escape the \ in the query. Could you try: {hrStorageDescr="C:\\ Label: SerialNumber...}?

Also if its erroring at :, try escaping that too.

@Keleir

This comment has been minimized.

Copy link
Author

Keleir commented Aug 2, 2017

@gouthamve I create a grafana Templating of hrStorageDescr with name device and refering it in query statment by $device:

Query: query_result(hrStorageSize{job="snmp_windows", instance="$server"})

Regex: .*hrStorageDescr="(.*?)",.*

templating

This will mathch the label values of hrStorageDescr:

C:\\ Label:  Serial Number 40663d48
D:\\ Label:  Serial Number 54e7a6b6
Physical Memory
Virtual Memory

With this templating, My query on grafana is:

( hrStorageUsed{hrStorageDescr="$device",instance=~"$server"} / hrStorageSize{hrStorageDescr="$device",instance=~"$server"}) * 100

But this occurs error as above.

@grobie

This comment has been minimized.

Copy link
Member

grobie commented Nov 12, 2017

Backslash needs to be escaped by another backslash. If grafana doesn't handle this correctly, open a bug report there.

@grobie grobie closed this Nov 12, 2017

@lock

This comment has been minimized.

Copy link

lock bot commented Mar 23, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Mar 23, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.