Created
November 13, 2020 12:32
-
-
Save egeneralov/849d1785b08ef420bf748dd192f598f3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -xe | |
wget https://github.com/grafana/loki/releases/download/v2.0.0/promtail-linux-amd64.zip | |
unzip promtail-linux-amd64.zip | |
mv promtail-linux-amd64 /usr/local/bin/promtail | |
cat << EOF > /etc/systemd/system/promtail.service | |
[Unit] | |
Documentation=https://grafana.com/docs/loki/latest/ | |
After=network.target | |
ConditionPathExists=/etc/promtail.yaml | |
ConditionFileIsExecutable=/usr/local/bin/promtail | |
[Service] | |
ExecStart=/usr/local/bin/promtail -config.file /etc/promtail.yaml -log.level info | |
KillMode=process | |
Restart=on-failure | |
[Install] | |
WantedBy=multi-user.target | |
EOF | |
cat << EOF > /etc/promtail.yaml | |
server: | |
http_listen_port: 0 | |
grpc_listen_port: 0 | |
positions: | |
filename: /var/lib/promtail.yaml | |
clients: | |
- url: http://${ENDPOINT}/loki/api/v1/push | |
scrape_configs: | |
- job_name: ${HOSTNAME} | |
static_configs: | |
- targets: | |
- localhost | |
labels: | |
job: ${HOSTNAME}-var-log | |
__path__: /var/log/*log | |
EOF | |
systemctl daemon-reload | |
systemctl start promtail.service | |
systemctl enable promtail.service | |
systemctl status promtail.service | |
journalctl -u promtail.service -f | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment