Public repo to distribute scripts and config's
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

69 lignes
1.6 KiB

  1. #/bin/bash
  2. # This script will setup Promtail to push to https://int.loki.grid.tf
  3. ### Install Promtail
  4. mkdir -p /etc/apt/keyrings/
  5. wget -q -O - https://apt.grafana.com/gpg.key | gpg --dearmor > /etc/apt/keyrings/grafana.gpg
  6. echo "deb [signed-by=/etc/apt/keyrings/grafana.gpg] https://apt.grafana.com stable main" | tee /etc/apt/sources.list.d/grafana.list
  7. apt update && apt install promtail -y
  8. usermod -a -G adm promtail
  9. ### Set config
  10. cat << EOF > /etc/promtail/config.yml
  11. server:
  12. http_listen_port: 9080
  13. grpc_listen_port: 0
  14. positions:
  15. filename: /tmp/positions.yaml
  16. clients:
  17. - url: https://int.loki.grid.tf/loki/api/v1/push
  18. scrape_configs:
  19. - job_name: system
  20. static_configs:
  21. - targets:
  22. - localhost
  23. labels:
  24. host: \${HOSTNAME}
  25. job: varlogs
  26. __path__: /var/log/*log
  27. - job_name: journal
  28. journal:
  29. json: false
  30. max_age: 24h
  31. path: /var/log/journal
  32. labels:
  33. host: \${HOSTNAME}
  34. job: systemd-journal
  35. relabel_configs:
  36. - source_labels: ['__journal__systemd_unit']
  37. target_label: 'unit'
  38. EOF
  39. ### Edit service
  40. cat << EOF > /etc/systemd/system/promtail.service
  41. [Unit]
  42. Description=Promtail service
  43. After=network.target
  44. [Service]
  45. Type=simple
  46. User=promtail
  47. Environment="HOSTNAME=%H"
  48. ExecStart=/usr/bin/promtail -config.file /etc/promtail/config.yml -config.expand-env=true
  49. # Give a reasonable amount of time for promtail to start up/shut down
  50. TimeoutSec = 60
  51. Restart = on-failure
  52. RestartSec = 2
  53. [Install]
  54. WantedBy=multi-user.target
  55. EOF
  56. ### Reload and restart
  57. systemctl daemon-reload
  58. systemctl restart promtail
  59. systemctl status promtail