VMAgent
VMAgent is an agent that allows you to set up the collection and processing of metrics.
Before you begin, set up VMAgent.
Set up VMAgent
You can set up the agent to collect metrics into your infrastructure.
1. Add a service user
Add a service user with the Projects scope permission and one of the following roles:
metrics.admin;member;- or
reader.
Users can be added by the Account Owner or users with the iam.admin.
2. Set up the agent to collect metrics
-
Open the CLI.
-
Create the
vmagent.yamlconfiguration file:nano /etc/vmagent/vmagent.yaml -
In the
vmagent.yamlconfiguration file, populate thescrape_configs:scrape_configs:- job_name: test_scrapescrape_interval: 1mmetrics_path: /projects/<project_id>/namespaces/<namespace>/prometheus/metricsstatic_configs:- targets:- <base_url>basic_auth:username: <user_id>password: <password>Specify:
<project_id>— Project ID. Can be copied in the control panel: in the top menu, click Products and select any product → open the projects menu → in the line of the required project, click ;<namespace>— the name of the selected namespace, for example,compute. You can find it in the Metrics Reference;<base_url>— the URL for accessing the Metrics service API. If you are configuring an agent to collect metrics from a dedicated server, use the cloud server pool URL that corresponds to the pool where your dedicated server is located. The list of URLs is available in the Metrics subsection of the List of URLs;<user_id>— the ID of the user you added in step 1;<password>— the password of the user you added in step 1.
-
Optional: you can configure metrics collection from multiple pools or projects. To add a new pool or project, repeat step 3.
-
Optional: add metrics export to external storage or processing systems, for example, VictoriaMetrics. To do this, add and populate the
remote_writesection in thevmagent.yamlconfiguration file. -
Exit the
nanotext editor and save your changes: press Ctrl+Х, and then Y+Enter. -
Launch VMAgent:
docker run \--name vmagent \--rm \-v ${PWD}/vmagent.yaml:/etc/vmagent/vmagent.yaml:ro \-p 8429:8429 \victoriametrics/vmagent:latest \--promscrape.config=/etc/vmagent/vmagent.yaml \--remoteWrite.url=http:/<storage_path>/api/v1/writeSpecify
<storage_path>— the address of your custom metrics storage. -
Optional: make sure that metrics are being collected. To do this, check the agent's connection to the Metrics service:
curl localhost:8429/targetsThe command output should display the
upstatus. Example output:job=test_scrape (1/1 up)