Metrics of an image-based application
To collect metrics of an image-based application in addition to VM system metrics:
-
Configure collection of VM system metrics (for details, see the section Monitoring agent).
-
In the
plans/<PLAN_NAME>/deployment/deploy.tfmanifest included in the service package of the image-based application, configure the prometheus plugin:-
In the
/etc/telegraf/telegraf.ddirectory, create ametrics.conffile and set the prometheus plugin settings. -
If the
/etc/telegraf/telegraf.d/directory (including all files) does not have thetelegrafowner and thetelegrafgroup assigned, assign them.Prometheus plugin configurationresource "ivkcs_agent_exec" "monitoring" {...step {index = 1type = "bash"content = <<-EOC#!/bin/bash...# Creating the metrics.conf filecat <<EOT > /etc/telegraf/telegraf.d/metrics.conf# Prometheus plugin[[inputs.prometheus]]name_override = "<NAME>"urls = ["<METRICS_URL>"]# Representing metrics via field key with tag preservationmetric_version = 2EOT# Assigning the owner and group to the telegraf.d directory and its fileschown -R telegraf:telegraf /etc/telegraf/telegraf.d/EOC...}...}
Here:
<NAME>— the prefix of the metrics. The value cannot be empty. If thename_overrideparameter is not set, the default valueprometheuswill be applied.<METRICS_URL>— the URL from which the image-based application provides metrics. For example,http://localhost:8428/metrics.
-
For example, an image-based application provides metrics at http://localhost:8428/metrics in the format:
go_gc_duration_seconds{quantile="0"} 0go_gc_duration_seconds{quantile="0.25"} 0go_gc_duration_seconds{quantile="0.5"} 0go_gc_duration_seconds{quantile="0.75"} 0go_gc_duration_seconds{quantile="1"} 8.4326e-05vm_app_version{version="victoria-metrics-20240301-000115-tags-v1.93.13-0-g26266a463", short_version="v1.93.13"} 1vm_allowed_memory_bytes 4933135564
The prometheus plugin is configured in the metrics.conf file:
[[inputs.prometheus]]name_override = "victoria"urls = ["http://localhost:8428/metrics"]# Representing metrics via field key with tag preservationmetric_version = 2
In this case, the monitoring agent will send the metrics to Cloud Monitoring in the format:
victoria_go_gc_duration_seconds{quantile="0"} 0victoria_go_gc_duration_seconds{quantile="0.25"} 0victoria_go_gc_duration_seconds{quantile="0.5"} 0victoria_go_gc_duration_seconds{quantile="0.75"} 0victoria_go_gc_duration_seconds{quantile="1"} 8.4326e-05victoria_vm_app_version{version="victoria-metrics-20240301-000115-tags-v1.93.13-0-g26266a463", short_version="v1.93.13"} 1victoria_vm_allowed_memory_bytes 4933135564