Agent best practices
One agent per host
Avoid running more than one Unified Agent instance on the same host with the same configuration files since that might cause problems with the agent.
Agent monitoring
When using Unified Agent, we recommend that you enable collecting health metrics for the agent.
To do so, add a delivery route with the agent_metrics
input to the agent configuration. Configuration example:
status:
port: 16241
routes:
- input:
plugin: agent_metrics
config:
namespace: ua
channel:
pipe:
- filter:
plugin: filter_metrics
config:
match: "{scope=health}"
output:
plugin: yc_metrics
config:
folder_id: "$FOLDER_ID"
iam:
cloud_meta: {}
See also agent_metrics input.
Using storage
Use a storage to reliably deliver metrics to Yandex Monitoring with Unified Agent. It will let you temporarily store messages sent over a pipe before being passed on to the channel output.
Using a storage can help you avoid data loss if the agent fails to write the data to the specified output (including repeat attempts). This may happen due to network issues or destination API unavailability.
Example of agent configuration with a storage:
status:
port: 16241
storages:
- name: main
plugin: fs
config:
directory: /var/lib/yandex/unified_agent/main
max_partition_size: 1gb
max_segment_size: 500mb
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: linux_metrics
config:
poll_period: 15s
namespace: sys
channel:
channel_ref:
name: cloud_monitoring
See also Storages.
Calculation of CPU usage time
Before, to indicate the percentage of CPU usage on the chart, the sys.system.CpuUsagePercent
metric was used. Linux no longer provides this metric; however, you can calculate it using the following two metrics:
sys.system.UsefulTime
: CPU active usage time.sys.system.IdleTime
: CPU idle time.
To add a CPU usage percentage chart to a dashboard:
-
Install and run Unified Agent.
-
Open the dashboard you need or create a new one.
-
In the upper-right corner, click
and select Chart to add a new widget to the dashboard. -
In the new widget, create three requests in text mode (the
icon):-
UsefulTime
request:"sys.system.UsefulTime"{folderId = "<folder_ID>", service = "custom", cpu = "-"}
Where
<folder_ID>
is the ID of the folder your dashboard is located in.Click the
icon to hide this metric from the chart. -
IdleTime
request:"sys.system.IdleTime"{folderId = "<folder_ID>", service = "custom", cpu = "-"}
Where
<folder_ID>
is the ID of the folder your dashboard is located in.Click the
icon to hide this metric from the chart. -
CpuUsagePercent
request:100 * UsefulTime / (IdleTime + UsefulTime)
-
-
Click Execute query and make sure you can see the chart with CPU usage.
-
In the upper-right corner, click
to save your widget.