Delivering metrics from HAProxy and other third-party applications
Yandex Unified Agent supports metric collection in the Prometheus format and metric conversion to the Yandex Monitoring format. Unified Agent enables you to pull metrics from applications that deliver them in the Prometheus format.
To deliver metrics from third-party applications to Yandex Monitoring, use the metrics_pull input that regularly polls a third-party application directly (if the application supports metrics in Prometheus format) or polls a special export application that integrates with Prometheus.
As an example, let's consider the delivery of HAProxy
Example of delivering HAProxy metrics
This procedure can also be used to send metrics from any third-party applications integrated with Prometheus
-
Install HAProxy
and HAProxy Exporter for Prometheus .-
To install HAProxy and HAProxy Exporter for Prometheus, run the following command:
sudo apt install haproxy prometheus-haproxy-exporter
-
Make sure the exporter is running and exposes metrics. To do so, run
curl http://localhost:9101/metrics
. Sample command output:curl http://localhost:9101/metrics # HELP go_gc_duration_seconds A summary of the GC invocation durations. # TYPE go_gc_duration_seconds summary go_gc_duration_seconds{quantile="0"} 0 go_gc_duration_seconds{quantile="0.25"} 0 go_gc_duration_seconds{quantile="0.5"} 0 go_gc_duration_seconds{quantile="0.75"} 0 go_gc_duration_seconds{quantile="1"} 0 go_gc_duration_seconds_sum 0 go_gc_duration_seconds_count 0 # HELP go_goroutines Number of goroutines that currently exist. # TYPE go_goroutines gauge go_goroutines 6 # HELP go_info Information about the Go environment. # TYPE go_info gauge go_info{version="go1.10.4"} 1
-
-
Set up a service account under which metrics will be written to Yandex Monitoring.
-
Create a service account in the folder you want to write metrics to and assign it the
monitoring.editor
role. -
Link your service account to a virtual machine with Unified Agent installed.
-
-
Install and configure Yandex Unified Agent:
-
Create a file named config.yml in your home folder.
config.yml:
status: port: "16241" storages: - name: main plugin: fs config: directory: /var/lib/yandex/unified_agent/main max_partition_size: 100mb max_segment_size: 10mb channels: - name: cloud_monitoring channel: pipe: - storage_ref: name: main output: plugin: yc_metrics config: folder_id: "$FOLDER_ID" iam: cloud_meta: {} routes: - input: plugin: metrics_pull config: url: http://localhost:9101/metrics format: prometheus: {} namespace: haproxy channel: channel_ref: name: cloud_monitoring - input: plugin: agent_metrics config: namespace: ua channel: pipe: - filter: plugin: filter_metrics config: match: "{scope=health}" channel_ref: name: cloud_monitoring import: - /etc/yandex/unified_agent/conf.d/*.yml
Where
$FOLDER_ID
is the ID of the folder to write metrics to. -
Install Unified Agent on your VM by running the following command in the home folder:
docker run \ -p 16241:16241 -it --detach --uts=host \ --name=ua \ -v /proc:/ua_proc \ -v `pwd`/config.yml:/etc/yandex/unified_agent/config.yml \ -e PROC_DIRECTORY=/ua_proc \ -e FOLDER_ID=a1bs81qpemb4******** \ cr.yandex/yc/unified-agent
You can find more ways to install the agent in Yandex Unified Agent installation and startup.
-
-
Make sure the metrics are delivered to Yandex Monitoring:
-
On the Yandex Monitoring home page
, go to Metric Explorer. -
In the query block, select:
- Folder where metrics are collected.
service=custom
label value.- Metric name starting with the
haproxy
prefix.
-