diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ec75899..ecf33fe 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -20,6 +20,7 @@ jobs: - slurm-docker-cluster - wklink - om-bistro + - promtail runs-on: ubuntu-latest steps: diff --git a/promtail/Dockerfile b/promtail/Dockerfile new file mode 100644 index 0000000..79b010c --- /dev/null +++ b/promtail/Dockerfile @@ -0,0 +1,5 @@ +FROM grafana/promtail:3.0.0 + +COPY ./config.yml /etc/promtail/config.yaml + +ENTRYPOINT ["promtail", "--config.file=/etc/promtail/config.yaml", "--config.expand-env=true"] diff --git a/promtail/README.md b/promtail/README.md new file mode 100644 index 0000000..d6db8c6 --- /dev/null +++ b/promtail/README.md @@ -0,0 +1,29 @@ +# Promtail + +## Usage + +Run using docker: + +```sh +docker run -v /var/run/docker.sock:/var/run/docker.sock \ + -e LOKI_PUSH_URL="/loki/api/v1/push" \ + -e LOKI_PUSH_USER="" \ + -e LOKI_PUSH_PASSWORD="" \ + -e DOCKER_HOST="/var/run/docker.sock" \ + -e INSTANCE_NAME="HelloWorld" \ + scalableminds/promtail +``` + +This will scrape all containers with label `gather.logs=true`. + +## Configuration + +Environment Variables: + +| Name | Description | +|------|-------------| +| `LOKI_PUSH_URL` | URL to push to (e.g. `/loki/api/v1/push`) | +| `AUTH_USER` | User for Basic Auth | +| `AUTH_PASSWORD` | Password for Basic Auth | +| `DOCKER_HOST` | Path to docker host (e.g. `unix:///var/run/docker.sock`) | +| `INSTANCE_NAME` | Name of the instance | diff --git a/promtail/config.yml b/promtail/config.yml new file mode 100644 index 0000000..c2ef9c8 --- /dev/null +++ b/promtail/config.yml @@ -0,0 +1,20 @@ +server: + disable: true +clients: +- url: ${LOKI_PUSH_URL} + basic_auth: + username: ${AUTH_USER} + password: ${AUTH_PASSWORD} + external_labels: + instance: ${INSTANCE_NAME} +scrape_configs: +- job_name: docker + docker_sd_configs: + - host: ${DOCKER_HOST} + relabel_configs: + - source_labels: ['__meta_docker_container_name'] + regex: '/(.*)' + target_label: 'container' + - source_labels: ['__meta_docker_container_label_gather_logs'] + regex: 'true' + action: 'keep'