[ 
https://issues.apache.org/jira/browse/FLINK-11174?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16722731#comment-16722731
 ] 

TisonKun commented on FLINK-11174:
----------------------------------

I see your concern and agree with you.

FLINK filters the label because 
[prometheus|https://prometheus.io/docs/instrumenting/writing_exporters/#naming] 
announces "Only [a-zA-Z0-9:_] are valid in metric names, any other characters 
should be sanitized to an underscore." and here are some related information.

[https://github.com/prometheus/prometheus/issues/4615]
 
[https://github.com/OpenObservability/OpenMetrics/blob/master/markdown/metric_exposition_format.md]

For a quick summary, prometheus follows the standard provided by OpenMetrics, 
which includes
 - Metric names are [a-zA-Z_:][a-zA-Z0-9_:]*
 - Label names are [a-zA-Z0-9_]*
 - Label values are full utf-8, null bytes are permitted

So I tend to release FLINK constraint, make it allowed that label values are 
utf-8. However, I am not access to a prometheus environment. So below I provide 
a patch you can make use of. Looking forward to you feedback.
{code:none}
diff --git 
a/flink-metrics/flink-metrics-prometheus/src/main/java/org/apache/flink/metrics/prometheus/AbstractPrometheusReporter.java
 
b/flink-metrics/flink-metrics-prometheus/src/main/java/org/apache/flink/metrics/prometheus/AbstractPrometheusReporter.java
index 426cd4c4f5..eebe67704f 100644
--- 
a/flink-metrics/flink-metrics-prometheus/src/main/java/org/apache/flink/metrics/prometheus/AbstractPrometheusReporter.java
+++ 
b/flink-metrics/flink-metrics-prometheus/src/main/java/org/apache/flink/metrics/prometheus/AbstractPrometheusReporter.java
@@ -88,7 +88,7 @@ public abstract class AbstractPrometheusReporter implements 
MetricReporter {
                for (final Map.Entry<String, String> dimension : 
group.getAllVariables().entrySet()) {
                        final String key = dimension.getKey();
                        
dimensionKeys.add(CHARACTER_FILTER.filterCharacters(key.substring(1, 
key.length() - 1)));
-                       
dimensionValues.add(CHARACTER_FILTER.filterCharacters(dimension.getValue()));
+                       dimensionValues.add(dimension.getValue());
                }
 
                final String scopedMetricName = getScopedName(metricName, 
group);
@@ -173,7 +173,7 @@ public abstract class AbstractPrometheusReporter implements 
MetricReporter {
 
                List<String> dimensionValues = new LinkedList<>();
                for (final Map.Entry<String, String> dimension : 
group.getAllVariables().entrySet()) {
-                       
dimensionValues.add(CHARACTER_FILTER.filterCharacters(dimension.getValue()));
+                       dimensionValues.add(dimension.getValue());
                }
 
                final String scopedMetricName = getScopedName(metricName, 
group);
{code}

> flink Metrics Prometheus labels support chinese
> -----------------------------------------------
>
>                 Key: FLINK-11174
>                 URL: https://issues.apache.org/jira/browse/FLINK-11174
>             Project: Flink
>          Issue Type: Improvement
>          Components: Metrics
>    Affects Versions: 1.6.2, 1.7.0
>            Reporter: Fan weiwen
>            Priority: Minor
>              Labels: pull-request-available
>
> use flink metrics and Prometheus 
> my job name is chinese 
> but  org.apache.flink.metrics.prometheus.AbstractPrometheusReporter
> replaceInvalidChars  only support  [a-zA-Z0-9:_] 
> so my job name is  replaceAll  ____
>  
> i think  labels key is  [a-zA-Z0-9:_]  ok 
> but  labels value  can support chinese?



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to