# Vmagent

> Send data to Last9 via VictoriaMetrics vmagent using Prometheus Remote Write protocol

Source: https://last9.io/docs/integrations/others/vmagent/

We make use of the VictoriaMetrics' vmagent [remote-write](https://docs.victoriametrics.com/vmagent.html) to write to an external remote endpoint i.e. Last9's remote-write endpoint.

## Prerequisites

Create a Last9 cluster by following [Getting Started](/docs/onboard/).

Keep the following information handy after creating the cluster:

- `$levitate_remote_write_url` - Last9's Remote write endpoint
- `$levitate_remote_write_username` - Cluster ID
- `$levitate_remote_write_password` - Write token created for the cluster

## Sending data to Last9

The information flow is as follows:

![Sending metrics to Last9 via vmagent](../../../../../assets/content/docs/integrations/others/vmagent/d1b7624-image.png)

## Setup

Here is a sample`docker-compose.yaml` for the `vmagent` setup:

```yaml
version: "3.5"
services:
  vmagent:
    container_name: vmagent
    image: victoriametrics/vmagent
    ports:
      - 8429:8429
    volumes:
      - vmagentdata:/vmagentdata
      - /var/tmp:/var/tmp
      - ./vmagent.yaml:/etc/vmagent/vmagent.yaml
    command:
      - "--promscrape.config=/etc/vmagent/vmagent.yaml"
      - "--remoteWrite.tmpDataPath=/var/tmp/vmagent/"
      - "--remoteWrite.maxDiskUsagePerURL=10737418240"
      - "--remoteWrite.url=$levitate_remote_write_url"
      - "--remoteWrite.basicAuth.username=$levitate_remote_write_username"
      - "--remoteWrite.basicAuth.password=$levitate_remote_write_password"
    restart: always
    network_mode: "host"
volumes:
  vmagentdata: {}
```

Create `vmagent.yaml` to add a sample scrape config. Replace this scrape config with your desired config:

```yaml
global:
  scrape_interval: 1m
  scrape_timeout: 20s

# Check https://prometheus.io/docs/prometheus/latest/configuration/configuration for more details
scrape_configs:
  - job_name: "vmagent"
    static_configs:
      - targets: ["localhost:8429"]
```

This will run the `vmagent` container, scrape the desired targets, and remote write metrics to Last9.

## Verification

The Last9 Cluster will start showing a summary of ingested samples.

![Last9 Cluster's Performance metrics](../../../../../assets/content/docs/integrations/others/vmagent/aa8922c-image.png)

:::tip
Check out how to install VMAgent on Ubuntu as standalone serivce [here](/docs/how-to-setup-vmagent-on-ubuntu/).
:::

## Next steps

Create a read token for your Last9 Cluster and follow our guide to [Configure Grafana](/docs/grafana-config/) to visualize the time series data getting sent to Last9.

---

## Troubleshooting

Please get in touch with us on [Discord](https://discord.com/invite/Q3p2EEucx9) or [Email](mailto:support@last9.io) if you have any questions.
