Ce contenu n'est pas disponible dans la langue sélectionnée.
Chapter 16. Enabling Prometheus metrics
Prometheus is an open-source systems and service monitoring and alerting toolkit that you can use to monitor services deployed in a standalone Apache Karaf container. Prometheus collects and stores metrics from configured services at given intervals, evaluates rule expressions, displays the results, and can trigger alerts if a specified condition becomes true.
Red Hat support for Prometheus is limited to the setup and configuration recommendations provided in Red Hat product documentation.
Prometheus uses “exporters” that are installed and configured on the clients to expose an endpoint to Prometheus format. This endpoint is an HTTP interface that provides a list of metrics and the current values of the metrics. Prometheus periodically scrapes each target-defined endpoint and writes the collected data to its database. Prometheus gathers data over an extended time, rather than just for the currently running session. Prometheus stores the data so that you can graphically visualize and run queries on the data.
16.1. Enabling the export of metrics from a standalone Apache Karaf container
Prometheus uses a configuration file ( https://raw.githubusercontent.com/jboss-fuse/application-templates/master/prometheus/prometheus-config.yml
) which includes metrics exposed by Camel.
The metrics that you can identify are limited to those supplied in JMX.
You must deploy a Fuse application in order for Apache Camel metrics to be generated.
Procedure
To enable the export of Prometheus metrics from a standalone Apache Karaf container using the command line:
-
Open a command prompt and make sure you are in the
etc/
directory of your Apache Karaf installation. Type the following command to create the Prometheus configuration file from the example file in the
etc/
directory:cp prometheus-config.yml-example prometheus-config.yml
-
The exporter is only available when you use the
fuse
orfuse.bat
command to start Fuse: runbin/fuse
on Linux/Unix orbin\fuse.bat
on Windows. -
When Fuse has restarted, you can view the exposed metrics by opening a web browser at:
http://localhost:9779
Optionally you can change the default values of the KARAF_PROMETHEUS_PORT
and KARAF_PROMETHEUS_CONFIG
configuration variables from the command line.
16.2. Configuring the Prometheus server to scrape exposed metrics from the Apache Karaf container
To enable the Prometheus server to scrape metrics from the Apache Karaf container, the endpoint which exposes the metrics must be added to the targets
property of the Prometheus configuration file.
Procedure
-
Navigate to the
/prometheus.yml
configuration file in the Prometheus installation directory. Add the Apache Karaf endpoint to scrape:
scrape_configs: - job_name: 'prometheus' # metrics_path defaults to '/metrics' # scheme defaults to 'http'. static_configs: - targets: ['localhost:9779']