Initial commit

main
Oystein Kristoffer Tveit 2023-10-10 16:48:03 +02:00
commit 39c5b05053
Signed by: oysteikt
GPG Key ID: 9F2F7D8250F35146
4 changed files with 99 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
promtail-linux-amd64.zip
promtail-linux-amd64
promtail

28
Makefile Normal file
View File

@ -0,0 +1,28 @@
LATEST_RELEASE = "v2.9.1"
all: reload
.PHONY: all reload install clean
reload: install
systemctl daemon-reload
systemctl enable --now promtail
systemctl restart promtail
install: promtail promtail.service generate-config
install -Dm755 promtail /usr/bin/promtail
install -Dm644 promtail.service /etc/systemd/system/
promtail:
curl -O -L "https://github.com/grafana/loki/releases/download/${LATEST_RELEASE}/promtail-linux-amd64.zip"
unzip -o "./promtail-linux-amd64.zip"
mv ./promtail-linux-amd64 ./promtail
chmod a+x ./promtail
generate-config:
mkdir -p /etc/promtail
ls /etc/promtail/config-promtail.yml || install -Dm600 config-promtail-template.yml /etc/promtail/config-promtail.yml
clean:
rm -f ./promtail-linux-amd64.zip
rm -f promtail

View File

@ -0,0 +1,33 @@
server:
disable: true
positions:
filename: /var/cache/promtail/positions.yaml
clients:
- url: 'https://ildkule.pvv.ntnu.no:3100/loki/api/v1/push'
# TODO: Add scrape configs here.
# See https://grafana.com/docs/loki/latest/send-data/promtail/configuration/#scrape_configs
scrape_configs:
- job_name: system
static_configs:
- targets:
- localhost
labels:
job: /var/logs
host: hostname
__path__: /var/log/**/**log
- job_name: systemd-journal
journal:
labels:
job: systemd-journal
max_age: 12h
relabel_configs:
- source_labels:
- __journal__systemd_unit
target_label: unit
- source_labels:
- __journal_priority_keyword
target_label: level

35
promtail.service Normal file
View File

@ -0,0 +1,35 @@
[Unit]
Description=Promtail log ingress
[Service]
X-StopIfChanged=false
CacheDirectory=promtail
CapabilityBoundingSet=
ExecStart=/usr/bin/promtail -config.file=/etc/promtail/config-promtail.yml --client.external-labels=host=%H
# Group=promtail
LockPersonality=true
MemoryDenyWriteExecute=true
NoNewPrivileges=true
PrivateDevices=true
PrivateMounts=true
PrivateTmp=true
PrivateUsers=true
ProtectClock=true
ProtectControlGroups=true
ProtectHome=true
ProtectHostname=true
ProtectKernelLogs=true
ProtectKernelModules=true
ProtectKernelTunables=true
ProtectSystem=strict
Restart=on-failure
RestrictRealtime=true
RestrictSUIDSGID=true
SupplementaryGroups=systemd-journal
SystemCallArchitectures=native
SystemCallFilter=@system-service
TimeoutStopSec=10
# User=promtail
[Install]
WantedBy=multi-user.target