VM System Metrics
To collect VM system metrics and send them to Cloud Monitoring:
-
During the service image creation process (for more details, see the section Creating a service image), install the monitoring agent:
-
Download and install the software package into the target OS:
- https://mcs-monitoring.hb.ru-msk.vkcloud-storage.ru/telegraf/telegraf_1.28.5-vkcs.1-1_amd64.deb — for Debian-based images.
- https://mcs-monitoring.hb.ru-msk.vkcloud-storage.ru/telegraf/telegraf-1.28.5-vkcs.1-1.x86_64.rpm — for RHEL-based images.
-
In the
/etc/telegraf/directory, create the monitoring agent configuration filetelegraf.conf:undefined
-
General settings
[agent]interval = "10s"round_interval = falsemetric_batch_size = 1000metric_buffer_limit = 10000collection_jitter = "2s"flush_interval = "10s"flush_jitter = "2s"logfile = ""
CPU plugin
[[inputs.cpu]]percpu = falsetotalcpu = truecollect_cpu_time = falsereport_active = falsefieldpass = ["usage_user", "usage_system", "usage_iowait", "usage_irq", "usage_guest"]
Memory plugin
[[inputs.mem]]fieldpass = ["available_percent", "available", "used_percent", "used", "free", "cached", "dirty"]
Disk plugin
[[inputs.disk]]ignore_fs = ["tmpfs", "devtmpfs", "devfs", "iso9660", "overlay", "aufs", "squashfs"]fieldpass = ["free", "used_percent", "inodes_free"]
DiskIO plugin
[[inputs.diskio]]fieldpass = ["reads", "writes", "read_bytes", "write_bytes", "read_time", "write_time", "io_time", "weighted_io_time"]
Net plugin
[[inputs.net]]fieldpass = ["bytes_sent", "bytes_recv", "packets_sent", "packets_recv", "err_in", "err_out", "drop_in", "drop_out"]
NetStat information
[[inputs.netstat]]fieldpass = ["tcp_established"]```For more information about the plugins, see the section [Standard metrics](/en/monitoring-services/monitoring/concepts/mon-metrics).
-
In the
plans/<PLAN_NAME>/deployment/deploy.tfmanifest included in the service package of the image-based application, configure sending VM system metrics to Cloud Monitoring:-
Obtain the data for configuring the monitoring agent output plugin:
data "ivkcs_monitoring_user" "write" {} -
In the
/etc/telegraf/telegraf.d/directory, create files with additional configuration parameters for the monitoring agent and reload it:-
global_tags.conf— global tags. -
output.conf— output plugin settings.Use the
ivkcs_agent_execresource.Additional configuration and reloading of the monitoring agentresource "ivkcs_agent_exec" "monitoring" {hosts = [local.hosts_name]name = "setup_monitoring"uuid = var.instance_uuidstep {index = 1type = "bash"content = <<-EOC#!/bin/bash# Creating the global_tags.conf filecat <<EOT > /etc/telegraf/telegraf.d/global_tags.conf# Global tags[global_tags]# VM IDvm_uuid = "${vkcs_compute_instance.compute.id}"EOT# Creating the output.conf filecat <<EOT > /etc/telegraf/telegraf.d/output.conf# Configuring the output plugin using the ivkcs_monitoring_user data source[[outputs.mcs_metrics]]user_id = "${data.ivkcs_monitoring_user.write.user_id}"password = "${data.ivkcs_monitoring_user.write.password}"project_id = "${data.ivkcs_monitoring_user.write.project_id}"auth_url = "${data.ivkcs_monitoring_user.write.auth_url}"namespace = "${data.ivkcs_monitoring_user.write.namespace}"endpoint = "${data.ivkcs_monitoring_user.write.endpoint}"EOT# Assigning the owner and group to the telegraf.d directory and the files in itchown -R telegraf:telegraf /etc/telegraf/telegraf.d/# Reloading the monitoring agent and adding it to the host autostartsystemctl restart telegrafsystemctl enable telegrafEOCoptions {timeout = "5m"attempts = 1}}timeouts {create = "10m"}}
-
-