From cc0b9015ec89c16d087fe89ac1096af5c76427aa Mon Sep 17 00:00:00 2001 From: Robert Oleynik Date: Thu, 18 Jul 2024 16:47:47 +0200 Subject: [PATCH 1/9] add custom promtail image --- promtail/Dockerfile | 5 +++++ promtail/README.md | 29 +++++++++++++++++++++++++++++ promtail/config.yml | 22 ++++++++++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 promtail/Dockerfile create mode 100644 promtail/README.md create mode 100644 promtail/config.yml diff --git a/promtail/Dockerfile b/promtail/Dockerfile new file mode 100644 index 0000000..6d04db2 --- /dev/null +++ b/promtail/Dockerfile @@ -0,0 +1,5 @@ +FROM grafana/promtail:main + +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..f7e9169 --- /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_PASSW="" \ + -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`) | +| `LOKI_PUSH_USER` | User for Basic Auth | +| `LOKI_PUSH_PASSW` | 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..7b4ae0a --- /dev/null +++ b/promtail/config.yml @@ -0,0 +1,22 @@ +server: + disable: true +clients: +- url: ${LOKI_PUSH_URL} + basic_auth: + username: ${LOKI_PUSH_USER} + password: ${LOKI_PUSH_PASSW} +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' + - source_labels: ['__meta_docker_container_label_gather_logs'] + regex: '.*' + target_label: 'instance' + replacement: ${INSTANCE_NAME} From fd43f6cf9ed86c90eeb52dd72613fc3214dfd7b8 Mon Sep 17 00:00:00 2001 From: Robert Oleynik Date: Thu, 25 Jul 2024 10:47:55 +0200 Subject: [PATCH 2/9] lock promtail version --- promtail/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/promtail/Dockerfile b/promtail/Dockerfile index 6d04db2..79b010c 100644 --- a/promtail/Dockerfile +++ b/promtail/Dockerfile @@ -1,4 +1,4 @@ -FROM grafana/promtail:main +FROM grafana/promtail:3.0.0 COPY ./config.yml /etc/promtail/config.yaml From ba673864c9d7ebcc64031eb236af381a5f7bedd4 Mon Sep 17 00:00:00 2001 From: Robert Oleynik Date: Thu, 1 Aug 2024 09:34:51 +0200 Subject: [PATCH 3/9] add promtail to github workflow --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) 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: From 90de3918297f650bd2d3ba9bf889a03e6ecfd487 Mon Sep 17 00:00:00 2001 From: Robert Oleynik Date: Thu, 1 Aug 2024 13:29:15 +0200 Subject: [PATCH 4/9] rename env to LOKI_PUSH_PASSWORD --- promtail/README.md | 4 ++-- promtail/config.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/promtail/README.md b/promtail/README.md index f7e9169..abbbe56 100644 --- a/promtail/README.md +++ b/promtail/README.md @@ -8,7 +8,7 @@ Run using docker: 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_PASSW="" \ + -e LOKI_PUSH_PASSWORD="" \ -e DOCKER_HOST="/var/run/docker.sock" \ -e INSTANCE_NAME="HelloWorld" \ scalableminds/promtail @@ -24,6 +24,6 @@ Environment Variables: |------|-------------| | `LOKI_PUSH_URL` | URL to push to (e.g. `/loki/api/v1/push`) | | `LOKI_PUSH_USER` | User for Basic Auth | -| `LOKI_PUSH_PASSW` | Password for Basic Auth | +| `LOKI_PUSH_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 index 7b4ae0a..9d52fc6 100644 --- a/promtail/config.yml +++ b/promtail/config.yml @@ -4,7 +4,7 @@ clients: - url: ${LOKI_PUSH_URL} basic_auth: username: ${LOKI_PUSH_USER} - password: ${LOKI_PUSH_PASSW} + password: ${LOKI_PUSH_PASSWORD} scrape_configs: - job_name: docker docker_sd_configs: From 5a43fa9211e480093f6c0bf5ae0a89115fe144bf Mon Sep 17 00:00:00 2001 From: Robert Oleynik Date: Tue, 6 Aug 2024 11:46:28 +0200 Subject: [PATCH 5/9] proimtail always add external labels --- promtail/config.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/promtail/config.yml b/promtail/config.yml index 9d52fc6..0bea076 100644 --- a/promtail/config.yml +++ b/promtail/config.yml @@ -5,6 +5,8 @@ clients: basic_auth: username: ${LOKI_PUSH_USER} password: ${LOKI_PUSH_PASSWORD} + external_labels: + instance: ${INSTANCE_NAME} scrape_configs: - job_name: docker docker_sd_configs: @@ -16,7 +18,3 @@ scrape_configs: - source_labels: ['__meta_docker_container_label_gather_logs'] regex: 'true' action: 'keep' - - source_labels: ['__meta_docker_container_label_gather_logs'] - regex: '.*' - target_label: 'instance' - replacement: ${INSTANCE_NAME} From e02fffb890f524835a8303242dfe77d7887fc3c1 Mon Sep 17 00:00:00 2001 From: Norman Rzepka Date: Thu, 8 Aug 2024 09:15:51 +0200 Subject: [PATCH 6/9] Update Dockerfile --- nginx-proxy/Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nginx-proxy/Dockerfile b/nginx-proxy/Dockerfile index 791ff2b..5423492 100644 --- a/nginx-proxy/Dockerfile +++ b/nginx-proxy/Dockerfile @@ -3,4 +3,6 @@ FROM nginxproxy/nginx-proxy RUN { \ echo 'proxy_read_timeout 3600s;'; \ echo 'client_max_body_size 0;'; \ + echo 'gzip on;' \ + echo 'gzip_types application/xml+rss application/atom+xml application/javascript application/x-javascript application/json application/rss+xml application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/svg+xml image/x-icon text/css text/plain text/x-component application/octet-stream application/x-protobuf;' } > /etc/nginx/conf.d/overwrites.conf From 8ff326b4729feca2d25d5b7edcdd3669487d0288 Mon Sep 17 00:00:00 2001 From: Norman Rzepka Date: Thu, 8 Aug 2024 09:16:46 +0200 Subject: [PATCH 7/9] Update Dockerfile --- nginx-proxy/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nginx-proxy/Dockerfile b/nginx-proxy/Dockerfile index 5423492..42b17b5 100644 --- a/nginx-proxy/Dockerfile +++ b/nginx-proxy/Dockerfile @@ -4,5 +4,5 @@ RUN { \ echo 'proxy_read_timeout 3600s;'; \ echo 'client_max_body_size 0;'; \ echo 'gzip on;' \ - echo 'gzip_types application/xml+rss application/atom+xml application/javascript application/x-javascript application/json application/rss+xml application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/svg+xml image/x-icon text/css text/plain text/x-component application/octet-stream application/x-protobuf;' + echo 'gzip_types application/xml+rss application/atom+xml application/javascript application/x-javascript application/json application/rss+xml application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/svg+xml image/x-icon text/css text/plain text/x-component application/octet-stream application/x-protobuf;' \ } > /etc/nginx/conf.d/overwrites.conf From 1afc290279caa3cec1b0c1104dd6385511e8e527 Mon Sep 17 00:00:00 2001 From: Norman Rzepka Date: Thu, 8 Aug 2024 09:19:28 +0200 Subject: [PATCH 8/9] Update Dockerfile --- nginx-proxy/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nginx-proxy/Dockerfile b/nginx-proxy/Dockerfile index 42b17b5..7af31cb 100644 --- a/nginx-proxy/Dockerfile +++ b/nginx-proxy/Dockerfile @@ -3,6 +3,6 @@ FROM nginxproxy/nginx-proxy RUN { \ echo 'proxy_read_timeout 3600s;'; \ echo 'client_max_body_size 0;'; \ - echo 'gzip on;' \ - echo 'gzip_types application/xml+rss application/atom+xml application/javascript application/x-javascript application/json application/rss+xml application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/svg+xml image/x-icon text/css text/plain text/x-component application/octet-stream application/x-protobuf;' \ + echo 'gzip on;'; \ + echo 'gzip_types application/xml+rss application/atom+xml application/javascript application/x-javascript application/json application/rss+xml application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/svg+xml image/x-icon text/css text/plain text/x-component application/octet-stream application/x-protobuf;'; \ } > /etc/nginx/conf.d/overwrites.conf From 17bfeb8e77e852e922c2b8500e9b272b48152f8e Mon Sep 17 00:00:00 2001 From: Robert Oleynik Date: Thu, 8 Aug 2024 09:56:56 +0200 Subject: [PATCH 9/9] promtail changed env to match common schema --- promtail/README.md | 4 ++-- promtail/config.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/promtail/README.md b/promtail/README.md index abbbe56..d6db8c6 100644 --- a/promtail/README.md +++ b/promtail/README.md @@ -23,7 +23,7 @@ Environment Variables: | Name | Description | |------|-------------| | `LOKI_PUSH_URL` | URL to push to (e.g. `/loki/api/v1/push`) | -| `LOKI_PUSH_USER` | User for Basic Auth | -| `LOKI_PUSH_PASSWORD` | Password for Basic Auth | +| `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 index 0bea076..c2ef9c8 100644 --- a/promtail/config.yml +++ b/promtail/config.yml @@ -3,8 +3,8 @@ server: clients: - url: ${LOKI_PUSH_URL} basic_auth: - username: ${LOKI_PUSH_USER} - password: ${LOKI_PUSH_PASSWORD} + username: ${AUTH_USER} + password: ${AUTH_PASSWORD} external_labels: instance: ${INSTANCE_NAME} scrape_configs: