I found information about grafana-agent on the Grafana website. It shows how to run it in docker.
- linux
docker run \
-v WAL_DATA_DIRECTORY:/etc/agent/data \
-v CONFIG_FILE_PATH:/etc/agent/agent.yaml \
grafana/agent:v0.39.0
- Windows
docker run ^
-v WAL_DATA_DIRECTORY:C:\etc\grafana-agent\data ^
-v CONFIG_FILE_PATH:C:\etc\grafana-agent ^
grafana/agent:v0.39.0-windows
It turned out to expand like this (one line command):
docker run -v WAL_DATA_DIRECTORY:/etc/grafana-agent/data -v CONFIG_FILE_PATH:/etc/grafana-agent grafana/agent:v0.39.0
Can you do that?
docker-compose.yaml
version: "3.8"
services:
grafana-agent:
container_name: grafana-agent
image: grafana/agent:v0.39.0
environment:
WAL_DATA_DIRECTORY: "/etc/agent/data"
CONFIG_FILE_PATH: "/etc/agent/agent.yaml"
volumes:
- ./data/:/etc/agent/data
- ./agent.yaml/:/etc/agent/agent.yaml
restart: unless-stopped
networks:
- grafana
networks:
grafana:
driver: bridge
But why is the port not specified?
- agent.yaml
metrics:
wal_directory: /etc/agent/data
global:
remote_write:
- url: http://localhost:9009/api/prom/push
integrations:
agent:
enabled: true
I don't quite understand why there is such a difference for Windows and Linux (except because of the differences in mounting directories on the host system inside the docker container).
I tried to run this command on a Windows system, but it didn't work. However, the question is how to make a universal docker-compose configuration file, by running which you could deploy grafana-agent. In addition, I did not understand on which port grafana-agent should be deployed and how to transfer the configuration file to it for integrations with various systems (for example, for prometheus).
The above configuration, through linking a directory and a file in the host system inside the container, seems to be supposed to accomplish the task, but did I do it right?