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

metrics labels can Support Chinese? #1988

Closed
najun79 opened this Issue Sep 14, 2016 · 10 comments

Comments

Projects
None yet
6 participants
@najun79
Copy link

najun79 commented Sep 14, 2016

takeout_requests_total{instance="",job="takeout_requests_total",mealscount="0",mealsname="��������",userid="user",username="������"} 3
takeout_requests_total{instance="",job="takeout_requests_total",mealscount="0",mealsname="�ϱ���ը����",userid="user",username="������"} 3
takeout_requests_total{instance="",job="takeout_requests_total",mealscount="1",mealsname="��������",userid="user",username="������"} 3
takeout_requests_total{instance="",job="takeout_requests_total",mealscount="1",mealsname="�ϱ���ը����",userid="user",username="������"} 6

labels mealsname is Chinese(utf8),takeout_requests_total can be send to pushgateway and Correctly received,but prom/Prometheus can not pull it.metrics labels can Support Chinese?

@songjiayang

This comment has been minimized.

Copy link

songjiayang commented Sep 14, 2016

check your db charset ?

@najun79

This comment has been minimized.

Copy link
Author

najun79 commented Sep 14, 2016

utf-8

@beorn7

This comment has been minimized.

Copy link
Member

beorn7 commented Sep 14, 2016

Label values fully support UTF-8. If you run into any issues, a detailed error report would be very helpful.

@aecolley

This comment has been minimized.

Copy link

aecolley commented Sep 18, 2016

Github comments seem to support 正體字 / 简化字, but the text in the mealsname of the original post appears to be gibberish (mostly Unicode "replacement characters", with the occasional Greek or Armenian letter). This makes me doubt that the text is really UTF-8. It's quite possible that the data are being passed over the net in the wrong charset, of course. Can you get intelligible responses from the pushgateway's own /metrics?

There's always the possibility that the characters being replaced by are outside the Unicode BMP, requiring 4-byte UTF-8 encodings. That's probably not a well-tested case. But, of course, it should be.

I notice that a bare request to Prometheus's own /metrics produces a response with the header Content-Type: text/plain;version=0.0.4 without a charset parameter; a correct HTTP/1.1 client will default to ISO-8859-1. I can't immediately tell whether the bytes are ISO-8859-1 or UTF-8, because apparently "prométheus" is not a valid job name. So, this is worth further investigation IMHO.

@beorn7

This comment has been minimized.

Copy link
Member

beorn7 commented Sep 19, 2016

I notice that a bare request to Prometheus's own /metrics produces a response with the header Content-Type: text/plain;version=0.0.4 without a charset parameter; a correct HTTP/1.1 client will default to ISO-8859-1. I can't immediately tell whether the bytes are ISO-8859-1 or UTF-8, because apparently "prométheus" is not a valid job name. So, this is worth further investigation IMHO.

That's a good point. If the text format is used, we should definitely specify the charset in the content type. I filed prometheus/docs#557 about it.

However, in this particular case, I don't think it explains the issue. First, a charset header is not required by the protobuf format. If the UTF-8 string makes it onto the Pushgateway, it will be scraped correctly by the Prometheus server (as it uses the protobuf format). Second, if I'm not missing anything, the Prometheus server will always interpret the payload of an HTTP request as UTF-8, no matter what might or might not be in the header.

Perhaps the problem happens in the last step, namely delivering the query result via the HTTP API?

@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Oct 26, 2016

@najun79 can you confirm if the issue is only in the HTTP API?

@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Feb 13, 2017

No response, presuming this issue isn't with Prometheus.

@codwu

This comment has been minimized.

Copy link

codwu commented Apr 6, 2017

if label value is chinese, prometheus give an error message: invalid label value "\xd5\xd7\xcd\xf8\xc2"

@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Apr 6, 2017

This is not valid utf-8: https://play.golang.org/p/NAcJaCo7Pu

@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.