Public repo to distribute scripts and config's
Nie możesz wybrać więcej, niż 25 tematów
Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
|
- #/bin/bash
- # This script will setup Promtail to push to https://int.loki.grid.tf
-
- ### Install Promtail
- mkdir -p /etc/apt/keyrings/
- wget -q -O - https://apt.grafana.com/gpg.key | gpg --dearmor > /etc/apt/keyrings/grafana.gpg
- echo "deb [signed-by=/etc/apt/keyrings/grafana.gpg] https://apt.grafana.com stable main" | tee /etc/apt/sources.list.d/grafana.list
- apt update && apt install promtail -y
- usermod -a -G adm promtail
-
- ### Set config
- cat << EOF > /etc/promtail/config.yml
- server:
- http_listen_port: 9080
- grpc_listen_port: 0
-
- positions:
- filename: /tmp/positions.yaml
-
- clients:
- - url: https://int.loki.grid.tf/loki/api/v1/push
-
- scrape_configs:
- - job_name: system
- static_configs:
- - targets:
- - localhost
- labels:
- host: \${HOSTNAME}
- job: varlogs
- __path__: /var/log/*log
- - job_name: journal
- journal:
- json: false
- max_age: 24h
- path: /var/log/journal
- labels:
- host: \${HOSTNAME}
- job: systemd-journal
- relabel_configs:
- - source_labels: ['__journal__systemd_unit']
- target_label: 'unit'
- EOF
-
- ### Edit service
- cat << EOF > /etc/systemd/system/promtail.service
- [Unit]
- Description=Promtail service
- After=network.target
-
- [Service]
- Type=simple
- User=promtail
- Environment="HOSTNAME=%H"
- ExecStart=/usr/bin/promtail -config.file /etc/promtail/config.yml -config.expand-env=true
- # Give a reasonable amount of time for promtail to start up/shut down
- TimeoutSec = 60
- Restart = on-failure
- RestartSec = 2
-
- [Install]
- WantedBy=multi-user.target
- EOF
-
- ### Reload and restart
- systemctl daemon-reload
- systemctl restart promtail
- systemctl status promtail
|