Skip to main content

VMAgent

Last update:

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.
  2. Configure the agent to retrieve metrics.

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

  1. Open the CLI.

  2. Create the vmagent.yaml configuration file:

    nano /etc/vmagent/vmagent.yaml
  3. In the vmagent.yaml configuration file, fill in the scrape_configs block:

    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.
  4. Optional: you can configure metrics collection from multiple pools or projects. To add a new pool or project, repeat step 3.

  5. Optional: add sending metrics to external storage or processing systems, such as VictoriaMetrics. To do this, add and complete the section remote_write to the vmagent.yaml configuration file.

  6. Exit the nano text editor with your changes saved: press Ctrl+X and then Y+Enter.

  7. 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/write

    Specify <storage_path> - the address of your custom metrics storage.

  8. Optional: make sure that the metrics are collected. To do this, check the agent's connection to the Metrics service:

    curl localhost:8429/targets

    The command output should display the up status. Example output:

    job=test_scrape (1/1 up)