Skip to content

Commit

Permalink
chore(promtail): Use minimal init config in rpm/deb packaging. (grafa…
Browse files Browse the repository at this point in the history
…na#11511)

Related issue: grafana#11398

This minimal config scrape only single file thus not overloading the
systems as described in the issue
  • Loading branch information
kavirajk authored and rhnasc committed Apr 12, 2024
1 parent 17caffb commit 428a448
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,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): 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

Expand Down
8 changes: 4 additions & 4 deletions tools/packaging/nfpm.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -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+: [
Expand All @@ -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',
Expand All @@ -45,7 +45,7 @@ local overrides = {
dst: '/etc/systemd/system/promtail.service',
},
{
src: './clients/cmd/promtail/promtail-local-config.yaml',
src: './tools/packaging/promtail-minimal-config.yaml',
dst: '/etc/promtail/config.yml',
type: 'config|noreplace',
},
Expand Down
24 changes: 24 additions & 0 deletions tools/packaging/promtail-minimal-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# This minimal config scrape only single log file.
# 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

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
#NOTE: Need to be modified to scrape any additional logs of the system.
__path__: /var/log/messages
4 changes: 2 additions & 2 deletions tools/packaging/verify-deb-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ cat <<EOF | docker exec --interactive "${image}" sh
# Write some logs
mkdir -p /var/log/
echo "blablabla" > /var/log/test.log
echo "blablabla" >> /var/log/messages
# Install logcli
dpkg -i ${dir}/dist/logcli_*_amd64.deb
Expand All @@ -31,4 +31,4 @@ cat <<EOF | docker exec --interactive "${image}" sh
labels_found=\$(logcli labels)
echo "Found labels: \$labels_found"
[ "\$labels_found" != "" ] || (echo "no logs found with logcli" && exit 1)
EOF
EOF
4 changes: 2 additions & 2 deletions tools/packaging/verify-rpm-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ cat <<EOF | docker exec --interactive "${image}" sh
# Write some logs
mkdir -p /var/log/
echo "blablabla" > /var/log/test.log
echo "blablabla" >> /var/log/messages
# Install logcli
rpm -i ${dir}/dist/logcli-*.x86_64.rpm
Expand All @@ -34,4 +34,4 @@ cat <<EOF | docker exec --interactive "${image}" sh
labels_found=\$(logcli labels)
echo "Found labels: \$labels_found"
[ "\$labels_found" != "" ] || (echo "no labels found with logcli" && exit 1)
EOF
EOF

0 comments on commit 428a448

Please sign in to comment.