Skip to main content

VMAgent

VMAgent is an agent that allows you to set up collecting and processing 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.
  2. Set up the agent to collect metrics.

1. Add a service user

Add a service user with permission in the Projects scope and the role:

The Account Owner or users with the iam.admin role can add users.

2. Set up the agent to collect 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> is the project ID. You can copy it in the Control Panel: in the top menu, click Products and select any product → open the project menu → in the line with the required project, click ;
    • <namespace> is the name of the selected namespace, for example, compute. You can find it in the Metrics Reference guide;
    • <base_url> is the URL for accessing the Metrics API. If you are setting up the 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 can be found in the Metrics section of the List of URLs guide;
    • <user_id> is the ID of the user you added in step 1;
    • <password> is the password of the user 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 populate the remote_write section in the vmagent.yaml configuration file.

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

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

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

  8. Optional: make sure that metrics are being 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)