VMAgent
VMAgent - An agent that allows you to customize the collection and processing of metrics.
Before you begin , configure the VMAgent.
Customize VMAgent
You can configure an agent to get metrics into your infrastructure.
1. Add a service user
Add a service user with authorization in the access area Projects and role:
metrics.admin;I'm a member;- or
reader.
Users can be added by the Account Owner or users with the role of iam.admin.
2. Configure the agent to receive metrics
-
Open the CLI.
-
Create the
vmagent.yamlconfiguration file:nano /etc/vmagent/vmagent.yaml -
In the
vmagent.yamlconfiguration file, fill in thescrape_configsblock:scrape_configs:
- job_name: test_scrape
scrape_interval: 1m
metrics_path: /projects/<project_id>/namespaces/<namespace>/prometheus/metrics
static_configs:
- targets:
- <base_url>
basic_auth:
username: <user_id>
password: <password>Specify:
<project_id>- Project ID. Can be copied in 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, e.g.compute;<base_url>- URL for accessing the API of the Metrics service. The list of URLs can be found in the instructions List of URLs;<user_id>- ID of the user you added in step 1;<password>- password of the user you 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 sending metrics to external storage or processing systems, such as VictoriaMetrics. To do this, add and complete the section
remote_writeto thevmagent.yamlconfiguration file. -
Exit the
nanotext editor with your changes saved: press Ctrl+X and then Y+Enter. -
Start 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 the metrics are 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)