grafana-promtail.rst (3727B)
1 .. 2 This file is part of GNU TALER. 3 Copyright (C) 2014-2023 Taler Systems SA 4 5 TALER is free software; you can redistribute it and/or modify it under the 6 terms of the GNU Affero General Public License as published by the Free Software 7 Foundation; either version 2.1, or (at your option) any later version. 8 9 TALER is distributed in the hope that it will be useful, but WITHOUT ANY 10 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 11 A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. 12 13 You should have received a copy of the GNU Affero General Public License along with 14 TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> 15 16 @author Javier Sepulveda 17 18 Grafana Promtail 19 ################ 20 21 Official documentation website can be found `here <https://grafana.com/docs/loki/latest/send-data/promtail/>`_. 22 23 Promtail can read two different types of logs. Regular log files, or information from the Systemd journald. 24 25 Download promtail 26 ================= 27 28 * Download 29 * Extract 30 * Copy to /usr/bin 31 * Set ownership and permissions 32 33 .. code-block:: 34 35 # cd /tmp 36 # wget https://github.com/grafana/loki/releases/download/v3.0.0/promtail-linux-amd64.zip 37 # unzip promtail-linux-amd64.zip -d . 38 # mv promtail-linux-amd64 promtail 39 # cp promtail /usr/local/bin 40 41 Create system user 42 ================== 43 44 .. code-block:: console 45 46 # useradd --system --no-create-home --shell /bin/false promtail 47 # usermod -G adm -a promtail # Add the "promtail" user, to the "adm" group if necessary. 48 49 Promtail configuration file 50 =========================== 51 52 .. code-block:: yaml 53 54 # Path: /etc/promtail/config.yml 55 56 server: 57 http_listen_port: 9080 58 grpc_listen_port: 0 59 60 positions: 61 filename: /tmp/positions.yaml 62 63 clients: 64 - url: http://localhost:3100/loki/api/v1/push 65 66 # Example for log file 67 68 scrape_configs: 69 - job_name: system 70 static_configs: 71 - targets: 72 - localhost 73 labels: 74 job: nginx 75 __path__: /var/log/nginx/*log # List here your log files 76 77 # Example for Systemd journald 78 79 scrape_configs: 80 - job_name: journal 81 journal: 82 json: true 83 path: /var/log/journal 84 labels: 85 job: systemd-journal 86 relabel_configs: 87 - source_labels: ['__journal__systemd_unit'] 88 target_label: 'unit' 89 90 Promtail systemd service file 91 ============================= 92 93 .. code-block:: systemd 94 95 # Path: /etc/systemd/system/promtail.service 96 97 [Unit] 98 Description=Promtail service 99 After=network.target 100 101 [Service] 102 Type=simple 103 User=promtail 104 ExecStart=/usr/local/bin/promtail -config.file /etc/promtail/config.yml 105 # Give a reasonable amount of time for promtail to start up/shut down 106 TimeoutSec = 60 107 Restart = on-failure 108 RestartSec = 2 109 110 [Install] 111 WantedBy=multi-user.target 112 113 114 Start and enable Promtail 115 ------------------------- 116 117 .. code-block:: console 118 119 # systemctl enable --now promtail.service 120 # systemctl status promtail.service 121 122 123 Promtail temporary files 124 ======================== 125 126 .. code-block:: console 127 128 # cd /tmp 129 # touch positions.yaml 130 # chown promtail:promtail /tmp/positions.yaml 131 132 Grafana control panel 133 ===================== 134 135 To check if Promtail is reading properly either your log files or the systemd journald units, you can click on the "Explore" section in the Grafana control panel, choose the right Loki connector, choose your desired log file or journald unit, and execute the query. 136 If you see this is working (you can see the chunks of the big log files), 137 you can convert this temporary query into a real Grafana "dashboard", to continue working later with additional filtering options. 138 139