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

    https://github.com/apache/flink/pull/5857#discussion_r191578999
  
    --- Diff: 
flink-metrics/flink-metrics-prometheus/src/main/java/org/apache/flink/metrics/prometheus/PrometheusPushGatewayReporter.java
 ---
    @@ -0,0 +1,79 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.flink.metrics.prometheus;
    +
    +import org.apache.flink.annotation.PublicEvolving;
    +import org.apache.flink.metrics.Metric;
    +import org.apache.flink.metrics.MetricConfig;
    +import org.apache.flink.metrics.reporter.MetricReporter;
    +import org.apache.flink.metrics.reporter.Scheduled;
    +import org.apache.flink.util.AbstractID;
    +
    +import io.prometheus.client.CollectorRegistry;
    +import io.prometheus.client.exporter.PushGateway;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +/**
    + * /**
    + * {@link MetricReporter} that exports {@link Metric Metrics} via 
Prometheus Pushgateway.
    + */
    +@PublicEvolving
    +public class PrometheusPushGatewayReporter extends 
AbstractPrometheusReporter implements Scheduled {
    +   private static final Logger LOG = 
LoggerFactory.getLogger(PrometheusPushGatewayReporter.class);
    +
    +   public static final String ARG_HOST = "host";
    +   public static final String ARG_PORT = "port";
    +
    +   public static final char JOB_NAME_SEPARATOR = '-';
    +   public static final String JOB_NAME_PREFIX = "flink" + 
JOB_NAME_SEPARATOR;
    +
    +   private PushGateway pushGateway;
    +   private final String jobName;
    +
    +   public PrometheusPushGatewayReporter() {
    +           String random = new AbstractID().toString();
    +           jobName = JOB_NAME_PREFIX + random;
    --- End diff --
    
    It is very possible that I'm overthinking this, and I've come up with a 
compromise.
    
    If there is one thing we learned in regards to the metric system it is that 
users despise random IDs, especially so if they can't connect them with 
anything else. The random ID that you're suggesting is exactly that; a random 
piece of data, that effectively is just a workaround for the questionable 
design of the PushGateway.
    For the sake of analyzing metrics this ID is irrelevant, it just eats up 
space.
    The randomness is especially problematic since this ID is used for deleting 
metrics (which one has to do at some point), making this arbitrary value 
_really_ important.
    
    For our intents however we just need _unique_ value for each container, 
i.e. dispatcher/taskmanager etc., not necessarily random .
    Every distributed component already has such an ID, most notable the 
TaskManager ID that is already exposed to the metric system. JobManager IDs are 
currently not exposed, but it was only a matter of time until this becomes 
necessary.
    While technically still a random value it at least does not an an entirely 
not label/dimension, but merely copies an existing one.


---

Reply via email to