You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by gobozov <gi...@git.apache.org> on 2017/12/31 08:54:15 UTC

[GitHub] flink pull request #4299: [FLINK-7155] [metrics] Add Influxdb reporter

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

    https://github.com/apache/flink/pull/4299#discussion_r159136038
  
    --- Diff: flink-metrics/flink-metrics-influxdb/src/main/java/org/apache/flink/metrics/influxdb/InfluxdbReporter.java ---
    @@ -0,0 +1,76 @@
    +/*
    + * 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.influxdb;
    +
    +import org.apache.flink.annotation.PublicEvolving;
    +import org.apache.flink.dropwizard.ScheduledDropwizardReporter;
    +import org.apache.flink.metrics.MetricConfig;
    +
    +import com.codahale.metrics.MetricFilter;
    +import com.codahale.metrics.ScheduledReporter;
    +import metrics_influxdb.HttpInfluxdbProtocol;
    +import metrics_influxdb.api.measurements.CategoriesMetricMeasurementTransformer;
    +
    +import java.util.concurrent.TimeUnit;
    +
    +/**
    + * This class acts as a factory for the {@link metrics_influxdb.InfluxdbReporter} and allows using it as a Flink
    + * reporter.
    + */
    +@PublicEvolving
    +public class InfluxdbReporter extends ScheduledDropwizardReporter {
    +
    +	public static final String ARG_USER = "user";
    +	public static final String ARG_PASSWORD = "password";
    +	public static final String ARG_DB = "db";
    +
    +	@Override
    +	public ScheduledReporter getReporter(final MetricConfig config) {
    +		final String host = config.getString(ARG_HOST, "localhost");
    +		final Integer port = config.getInteger(ARG_PORT, HttpInfluxdbProtocol.DEFAULT_PORT);
    +		final String user = config.getString(ARG_USER, null);
    +		final String password = config.getString(ARG_PASSWORD, null);
    +		final String db = config.getString(ARG_DB, "flink");
    +		final String conversionRate = config.getString(ARG_CONVERSION_RATE, null);
    +		final String conversionDuration = config.getString(ARG_CONVERSION_DURATION, null);
    +
    +		final metrics_influxdb.InfluxdbReporter.Builder builder =
    +			metrics_influxdb.InfluxdbReporter.forRegistry(registry);
    +
    +		builder.protocol(new HttpInfluxdbProtocol(host, port, user, password, db));
    --- End diff --
    
    We built same thing for our needs using same InfluxDb reporter. The disadvantage is that it does not support https, we modified it to support sslContext. I also don't see way to provide tags to reporter builder.


---