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

ASF GitHub Bot commented on FLINK-6221:
---------------------------------------

Github user zentol commented on a diff in the pull request:

    https://github.com/apache/flink/pull/3833#discussion_r116377143
  
    --- Diff: 
flink-metrics/flink-metrics-prometheus/src/main/java/org/apache/flink/metrics/prometheus/PrometheusReporter.java
 ---
    @@ -133,61 +136,58 @@ public void notifyOfRemovedMetric(final Metric 
metric, final String metricName,
                collectorsByMetricName.remove(metricName);
        }
     
    +   @SuppressWarnings("unchecked")
    +   private static String getLogicalScope(MetricGroup group) {
    +           return ((FrontMetricGroup<AbstractMetricGroup<?>>) 
group).getLogicalScope(CHARACTER_FILTER, SCOPE_SEPARATOR);
    +   }
    +
        private Collector createGauge(final Gauge gauge, final String name, 
final String identifier, final List<String> labelNames, final List<String> 
labelValues) {
    -           return io.prometheus.client.Gauge
    -                   .build()
    -                   .name(name)
    -                   .help(identifier)
    -                   .labelNames(toArray(labelNames, String.class))
    -                   .create()
    -                   .setChild(new io.prometheus.client.Gauge.Child() {
    -                           @Override
    -                           public double get() {
    -                                   final Object value = gauge.getValue();
    -                                   if (value instanceof Double) {
    -                                           return (double) value;
    -                                   }
    -                                   if (value instanceof Number) {
    -                                           return ((Number) 
value).doubleValue();
    -                                   } else if (value instanceof Boolean) {
    -                                           return ((Boolean) value) ? 1 : 
0;
    -                                   } else {
    -                                           log.debug("Invalid type for 
Gauge {}: {}, only number types and booleans are supported by this reporter.",
    -                                                   gauge, 
value.getClass().getName());
    -                                           return 0;
    -                                   }
    +           return newGauge(name, identifier, labelNames, labelValues, new 
io.prometheus.client.Gauge.Child() {
    +                   @Override
    +                   public double get() {
    +                           final Object value = gauge.getValue();
    +                           if (value instanceof Double) {
    +                                   return (double) value;
    +                           }
    +                           if (value instanceof Number) {
    +                                   return ((Number) value).doubleValue();
    +                           } else if (value instanceof Boolean) {
    +                                   return ((Boolean) value) ? 1 : 0;
    +                           } else {
    +                                   LOG.debug("Invalid type for Gauge {}: 
{}, only number types and booleans are supported by this reporter.",
    +                                           gauge, 
value.getClass().getName());
    +                                   return 0;
                                }
    -                   }, toArray(labelValues, String.class));
    +                   }
    +           });
        }
     
        private static Collector createGauge(final Counter counter, final 
String name, final String identifier, final List<String> labelNames, final 
List<String> labelValues) {
    -           return io.prometheus.client.Gauge
    -                   .build()
    -                   .name(name)
    -                   .help(identifier)
    -                   .labelNames(toArray(labelNames, String.class))
    -                   .create()
    -                   .setChild(new io.prometheus.client.Gauge.Child() {
    -                           @Override
    -                           public double get() {
    -                                   return (double) counter.getCount();
    -                           }
    -                   }, toArray(labelValues, String.class));
    +           return newGauge(name, identifier, labelNames, labelValues, new 
io.prometheus.client.Gauge.Child() {
    +                   @Override
    +                   public double get() {
    +                           return (double) counter.getCount();
    +                   }
    +           });
    +   }
    +
    +   private Collector createGauge(final Meter meter, final String name, 
final String identifier, final List<String> labelNames, final List<String> 
labelValues) {
    +           return newGauge(name + "_rate", identifier, labelNames, 
labelValues, new io.prometheus.client.Gauge.Child() {
    --- End diff --
    
    Meter metrics should contain "rate" in their name already, so we don't have 
to append "_rate" here.


> Add Prometheus support to metrics
> ---------------------------------
>
>                 Key: FLINK-6221
>                 URL: https://issues.apache.org/jira/browse/FLINK-6221
>             Project: Flink
>          Issue Type: Improvement
>          Components: Metrics
>    Affects Versions: 1.2.0
>            Reporter: Joshua Griffith
>            Assignee: Maximilian Bode
>            Priority: Minor
>
> [Prometheus|https://prometheus.io/] is becoming popular for metrics and 
> alerting. It's possible to use 
> [statsd-exporter|https://github.com/prometheus/statsd_exporter] to load Flink 
> metrics into Prometheus but it would be far easier if Flink supported 
> Promethus as a metrics reporter. A [dropwizard 
> client|https://github.com/prometheus/client_java/tree/master/simpleclient_dropwizard]
>  exists that could be integrated into the existing metrics system.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to