Skip to content

Commit

Permalink
[FLINK-9187][metrics] Add Prometheus PushGateway reporter
Browse files Browse the repository at this point in the history
This closes apache#6184.
  • Loading branch information
lamber-ken authored and zentol committed Jul 11, 2018
1 parent 60df251 commit 5ee5dbf
Show file tree
Hide file tree
Showing 10 changed files with 532 additions and 271 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<table class="table table-bordered">
<thead>
<tr>
<th class="text-left" style="width: 20%">Key</th>
<th class="text-left" style="width: 15%">Default</th>
<th class="text-left" style="width: 65%">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><h5>deleteOnShutdown</h5></td>
<td style="word-wrap: break-word;">true</td>
<td>Specifies whether to delete metrics from the PushGateway on shutdown.</td>
</tr>
<tr>
<td><h5>host</h5></td>
<td style="word-wrap: break-word;">(none)</td>
<td>The PushGateway server host.</td>
</tr>
<tr>
<td><h5>jobName</h5></td>
<td style="word-wrap: break-word;">(none)</td>
<td>The job name under which metrics will be pushed</td>
</tr>
<tr>
<td><h5>port</h5></td>
<td style="word-wrap: break-word;">-1</td>
<td>The PushGateway server port.</td>
</tr>
<tr>
<td><h5>randomJobNameSuffix</h5></td>
<td style="word-wrap: break-word;">true</td>
<td>Specifies whether a random suffix should be appended to the job name.</td>
</tr>
</tbody>
</table>
26 changes: 26 additions & 0 deletions docs/monitoring/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,32 @@ Flink metric types are mapped to Prometheus metric types as follows:

All Flink metrics variables (see [List of all Variables](#list-of-all-variables)) are exported to Prometheus as labels.

### PrometheusPushGateway (org.apache.flink.metrics.prometheus.PrometheusPushGatewayReporter)

In order to use this reporter you must copy `/opt/flink-metrics-prometheus-{{site.version}}.jar` into the `/lib` folder
of your Flink distribution.

Parameters:

{% include generated/prometheus_push_gateway_reporter_configuration.html %}

Example configuration:

{% highlight yaml %}

metrics.reporter.promgateway.class: org.apache.flink.metrics.prometheus.PrometheusPushGatewayReporter
metrics.reporter.promgateway.host: localhost
metrics.reporter.promgateway.port: 9091
metrics.reporter.promgateway.jobName: myJob
metrics.reporter.promgateway.randomJobNameSuffix: true
metrics.reporter.promgateway.deleteOnShutdown: false

{% endhighlight %}

The PrometheusPushGatewayReporter pushes metrics to a [Pushgateway](https://github.com/prometheus/pushgateway), which can be scraped by Prometheus.

Please see the [Prometheus documentation](https://prometheus.io/docs/practices/pushing/) for use-cases.

### StatsD (org.apache.flink.metrics.statsd.StatsDReporter)

In order to use this reporter you must copy `/opt/flink-metrics-statsd-{{site.version}}.jar` into the `/lib` folder
Expand Down
5 changes: 5 additions & 0 deletions flink-docs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ under the License.
<artifactId>flink-runtime_${scala.binary.version}</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-metrics-prometheus</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<!-- necessary for loading the web-submission extension -->
<groupId>org.apache.flink</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public class ConfigOptionsDocGenerator {
new OptionsClassLocation("flink-yarn", "org.apache.flink.yarn.configuration"),
new OptionsClassLocation("flink-mesos", "org.apache.flink.mesos.configuration"),
new OptionsClassLocation("flink-mesos", "org.apache.flink.mesos.runtime.clusterframework"),
new OptionsClassLocation("flink-metrics/flink-metrics-prometheus", "org.apache.flink.metrics.prometheus"),
};

static final String DEFAULT_PATH_PREFIX = "src/main/java";
Expand Down
6 changes: 6 additions & 0 deletions flink-metrics/flink-metrics-prometheus/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ under the License.
<version>${prometheus.version}</version>
</dependency>

<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient_pushgateway</artifactId>
<version>${prometheus.version}</version>
</dependency>

<!-- test dependencies -->

<dependency>
Expand Down
Loading

0 comments on commit 5ee5dbf

Please sign in to comment.