From bd0dd7d83f3f077140c780b0d8161bfa35589a0c Mon Sep 17 00:00:00 2001 From: Kaviraj Date: Mon, 18 Dec 2023 12:39:56 +0100 Subject: [PATCH 1/9] chore(promtail): Use minimal init config in npm/deb packaging. Related issue: https://github.com/grafana/loki/issues/11398 This minimal config scrape only single file thus not overloading the systems as described in the issue Signed-off-by: Kaviraj --- .../cmd/promtail/promtail-minimal-config.yaml | 23 +++++++++++++++++++ tools/packaging/nfpm.jsonnet | 8 +++---- 2 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 clients/cmd/promtail/promtail-minimal-config.yaml diff --git a/clients/cmd/promtail/promtail-minimal-config.yaml b/clients/cmd/promtail/promtail-minimal-config.yaml new file mode 100644 index 0000000000000..24a7aeba5ead7 --- /dev/null +++ b/clients/cmd/promtail/promtail-minimal-config.yaml @@ -0,0 +1,23 @@ +# This minimal config scrape only single log file. +# Primarily used in npm/deb packaging where promtail service can be started during system init process. +# And too much scraping during init process can overload the complete system. +# https://github.com/grafana/loki/issues/11398 + +server: + http_listen_port: 9080 + grpc_listen_port: 0 + +positions: + filename: /tmp/positions.yaml + +clients: + - url: http://localhost:3100/loki/api/v1/push + +scrape_configs: +- job_name: system + static_configs: + - targets: + - localhost + labels: + job: varlogs + __path__: /var/log/messages diff --git a/tools/packaging/nfpm.jsonnet b/tools/packaging/nfpm.jsonnet index b313cf0e48eb3..bde22624ac657 100644 --- a/tools/packaging/nfpm.jsonnet +++ b/tools/packaging/nfpm.jsonnet @@ -13,8 +13,8 @@ local overrides = { loki: { description: ||| - Loki is a horizontally-scalable, highly-available, multi-tenant log aggregation system inspired by Prometheus. - It is designed to be very cost effective and easy to operate. + Loki is a horizontally-scalable, highly-available, multi-tenant log aggregation system inspired by Prometheus. + It is designed to be very cost effective and easy to operate. It does not index the contents of the logs, but rather a set of labels for each log stream. |||, contents+: [ @@ -35,7 +35,7 @@ local overrides = { promtail: { description: ||| - Promtail is an agent which ships the contents of local logs to a private Grafana Loki instance or Grafana Cloud. + Promtail is an agent which ships the contents of local logs to a private Grafana Loki instance or Grafana Cloud. It is usually deployed to every machine that has applications needed to be monitored. |||, license: 'Apache-2.0', @@ -45,7 +45,7 @@ local overrides = { dst: '/etc/systemd/system/promtail.service', }, { - src: './clients/cmd/promtail/promtail-local-config.yaml', + src: './clients/cmd/promtail/promtail-minimal-config.yaml', dst: '/etc/promtail/config.yml', type: 'config|noreplace', }, From a3ab311f33a7476f13304e53504acab0a9ce7ad2 Mon Sep 17 00:00:00 2001 From: Kaviraj Date: Mon, 18 Dec 2023 12:43:58 +0100 Subject: [PATCH 2/9] add changelog Signed-off-by: Kaviraj --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ee05edfb42b2..317b8839fd2c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -60,6 +60,7 @@ #### Promtail * [10752](https://github.com/grafana/loki/pull/10752) **gonzalesraul**: structured_metadata: enable structured_metadata convert labels +* [11511](https://github.com/grafana/loki/pull/11511) **kavirajk**: chore(promtail): Use minimal init config in npm/deb packaging. ##### Enhancements From cb4a91376dd17895cb653efc9b4d8cc69b73d1c3 Mon Sep 17 00:00:00 2001 From: Kaviraj Date: Mon, 18 Dec 2023 14:22:55 +0100 Subject: [PATCH 3/9] move it to `tools/packaging` Signed-off-by: Kaviraj --- tools/packaging/nfpm.jsonnet | 2 +- .../promtail => tools/packaging}/promtail-minimal-config.yaml | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename {clients/cmd/promtail => tools/packaging}/promtail-minimal-config.yaml (100%) diff --git a/tools/packaging/nfpm.jsonnet b/tools/packaging/nfpm.jsonnet index bde22624ac657..aff88fe658741 100644 --- a/tools/packaging/nfpm.jsonnet +++ b/tools/packaging/nfpm.jsonnet @@ -45,7 +45,7 @@ local overrides = { dst: '/etc/systemd/system/promtail.service', }, { - src: './clients/cmd/promtail/promtail-minimal-config.yaml', + src: './tools/packaging/promtail-minimal-config.yaml', dst: '/etc/promtail/config.yml', type: 'config|noreplace', }, diff --git a/clients/cmd/promtail/promtail-minimal-config.yaml b/tools/packaging/promtail-minimal-config.yaml similarity index 100% rename from clients/cmd/promtail/promtail-minimal-config.yaml rename to tools/packaging/promtail-minimal-config.yaml From f8cee7a195eb17a93ff50f1276da8706b733cbaf Mon Sep 17 00:00:00 2001 From: Kaviraj Kanagaraj Date: Mon, 18 Dec 2023 15:07:59 +0100 Subject: [PATCH 4/9] Update CHANGELOG.md Co-authored-by: Christian Haudum --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 317b8839fd2c1..125b2921b921f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -60,7 +60,7 @@ #### Promtail * [10752](https://github.com/grafana/loki/pull/10752) **gonzalesraul**: structured_metadata: enable structured_metadata convert labels -* [11511](https://github.com/grafana/loki/pull/11511) **kavirajk**: chore(promtail): Use minimal init config in npm/deb packaging. +* [11511](https://github.com/grafana/loki/pull/11511) **kavirajk**: chore(promtail): Use minimal init config in rpm/deb packaging. ##### Enhancements From 6c000c6ae7ae2a331de8a6765a570d4daa8f65e5 Mon Sep 17 00:00:00 2001 From: Kaviraj Kanagaraj Date: Mon, 18 Dec 2023 15:08:06 +0100 Subject: [PATCH 5/9] Update tools/packaging/promtail-minimal-config.yaml Co-authored-by: Christian Haudum --- tools/packaging/promtail-minimal-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/packaging/promtail-minimal-config.yaml b/tools/packaging/promtail-minimal-config.yaml index 24a7aeba5ead7..553b15765bfdf 100644 --- a/tools/packaging/promtail-minimal-config.yaml +++ b/tools/packaging/promtail-minimal-config.yaml @@ -1,5 +1,5 @@ # This minimal config scrape only single log file. -# Primarily used in npm/deb packaging where promtail service can be started during system init process. +# Primarily used in rpm/deb packaging where promtail service can be started during system init process. # And too much scraping during init process can overload the complete system. # https://github.com/grafana/loki/issues/11398 From c4f52a3b13b73d540b62e694235a1f457ac5565b Mon Sep 17 00:00:00 2001 From: Kaviraj Kanagaraj Date: Wed, 10 Jan 2024 20:19:07 +0530 Subject: [PATCH 6/9] Update CHANGELOG.md Co-authored-by: Christian Haudum --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a58e4d185f36..f3c35651550ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -68,7 +68,7 @@ #### Promtail * [10752](https://github.com/grafana/loki/pull/10752) **gonzalesraul**: structured_metadata: enable structured_metadata convert labels -* [11511](https://github.com/grafana/loki/pull/11511) **kavirajk**: chore(promtail): Use minimal init config in rpm/deb packaging. +* [11511](https://github.com/grafana/loki/pull/11511) **kavirajk**: chore(promtail): Improve default configuration that is shipped with rpm/deb packages to avoid possible high CPU utilisation if there are lots of files inside `/var/log`. ##### Enhancements From b452796391fe08b60f27437ef59653870dd31c6f Mon Sep 17 00:00:00 2001 From: Kaviraj Date: Wed, 10 Jan 2024 20:24:43 +0530 Subject: [PATCH 7/9] indendation fix Signed-off-by: Kaviraj --- tools/packaging/promtail-minimal-config.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/packaging/promtail-minimal-config.yaml b/tools/packaging/promtail-minimal-config.yaml index 553b15765bfdf..d2270ccb9a278 100644 --- a/tools/packaging/promtail-minimal-config.yaml +++ b/tools/packaging/promtail-minimal-config.yaml @@ -11,7 +11,7 @@ positions: filename: /tmp/positions.yaml clients: - - url: http://localhost:3100/loki/api/v1/push +- url: http://localhost:3100/loki/api/v1/push scrape_configs: - job_name: system @@ -20,4 +20,5 @@ scrape_configs: - localhost labels: job: varlogs + #NOTE: Need to be changed to scrape any additional logs of the system. __path__: /var/log/messages From c6dfb85d6a568d254915b0db8b3d9521da98728e Mon Sep 17 00:00:00 2001 From: Kaviraj Date: Thu, 11 Jan 2024 07:34:56 +0530 Subject: [PATCH 8/9] change rpm and deb packages testing log file name Previously we are writing logs to /var/log/test.log. But with minimal config we scrape only /var/log/messages. So write to /var/log/messages instead Signed-off-by: Kaviraj --- tools/packaging/verify-deb-install.sh | 4 ++-- tools/packaging/verify-rpm-install.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/packaging/verify-deb-install.sh b/tools/packaging/verify-deb-install.sh index c9d75e8c89e91..59a11f59fe50a 100755 --- a/tools/packaging/verify-deb-install.sh +++ b/tools/packaging/verify-deb-install.sh @@ -21,7 +21,7 @@ cat < /var/log/test.log + echo "blablabla" >> /var/log/messages # Install logcli dpkg -i ${dir}/dist/logcli_*_amd64.deb @@ -31,4 +31,4 @@ cat < /var/log/test.log + echo "blablabla" >> /var/log/messages # Install logcli rpm -i ${dir}/dist/logcli-*.x86_64.rpm @@ -34,4 +34,4 @@ cat < Date: Thu, 11 Jan 2024 08:10:07 +0530 Subject: [PATCH 9/9] Some dummy commit to force re-run CLA check Signed-off-by: Kaviraj --- tools/packaging/promtail-minimal-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/packaging/promtail-minimal-config.yaml b/tools/packaging/promtail-minimal-config.yaml index d2270ccb9a278..442b33d0d4bcd 100644 --- a/tools/packaging/promtail-minimal-config.yaml +++ b/tools/packaging/promtail-minimal-config.yaml @@ -20,5 +20,5 @@ scrape_configs: - localhost labels: job: varlogs - #NOTE: Need to be changed to scrape any additional logs of the system. + #NOTE: Need to be modified to scrape any additional logs of the system. __path__: /var/log/messages