taler-docs

Documentation for GNU Taler components, APIs and protocols
Log | Files | Refs | README | LICENSE

grafana-promtail.rst (3783B)


      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 .. contents:: Table of Contents
     26   :depth: 1
     27   :local:
     28 
     29 
     30 Download promtail
     31 =================
     32 
     33 * Download
     34 * Extract
     35 * Copy to /usr/bin
     36 * Set ownership and permissions
     37 
     38 .. code-block::
     39 
     40    # cd /tmp
     41    # wget https://github.com/grafana/loki/releases/download/v3.0.0/promtail-linux-amd64.zip
     42    # unzip promtail-linux-amd64.zip -d .
     43    # mv promtail-linux-amd64 promtail
     44    # cp promtail /usr/local/bin
     45 
     46 Create system user
     47 ==================
     48 
     49 .. code-block:: console
     50 
     51    # useradd --system --no-create-home --shell /bin/false promtail
     52    # usermod -G adm -a promtail # Add the "promtail" user, to the "adm" group if necessary.
     53 
     54 Promtail configuration file
     55 ===========================
     56 
     57 .. code-block:: yaml
     58 
     59    # Path: /etc/promtail/config.yml
     60 
     61    server:
     62      http_listen_port: 9080
     63      grpc_listen_port: 0
     64 
     65    positions:
     66      filename: /tmp/positions.yaml
     67 
     68    clients:
     69      - url: http://localhost:3100/loki/api/v1/push
     70 
     71    # Example for log file
     72 
     73    scrape_configs:
     74    - job_name: system
     75      static_configs:
     76      - targets:
     77          - localhost
     78        labels:
     79          job: nginx
     80          __path__: /var/log/nginx/*log # List here your log files
     81 
     82    # Example for Systemd journald
     83 
     84    scrape_configs:
     85    - job_name: journal
     86      journal:
     87       json: true
     88       path: /var/log/journal
     89       labels:
     90         job: systemd-journal
     91     relabel_configs:
     92       - source_labels: ['__journal__systemd_unit']
     93         target_label: 'unit'
     94 
     95 Promtail systemd service file
     96 =============================
     97 
     98 .. code-block:: systemd
     99 
    100    # Path: /etc/systemd/system/promtail.service
    101 
    102    [Unit]
    103    Description=Promtail service
    104    After=network.target
    105 
    106    [Service]
    107    Type=simple
    108    User=promtail
    109    ExecStart=/usr/local/bin/promtail -config.file /etc/promtail/config.yml
    110    # Give a reasonable amount of time for promtail to start up/shut down
    111    TimeoutSec = 60
    112    Restart = on-failure
    113    RestartSec = 2
    114 
    115    [Install]
    116    WantedBy=multi-user.target
    117 
    118 
    119 Start and enable Promtail
    120 -------------------------
    121 
    122 .. code-block:: console
    123 
    124     # systemctl enable --now promtail.service
    125     # systemctl status promtail.service
    126 
    127 
    128 Promtail temporary files
    129 ========================
    130 
    131 .. code-block:: console
    132 
    133    # cd /tmp
    134    # touch positions.yaml
    135    # chown promtail:promtail /tmp/positions.yaml
    136 
    137 Grafana control panel
    138 =====================
    139 
    140 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.
    141 If you see this is working (you can see the chunks of the big log files),
    142 you can convert this temporary query into a real Grafana "dashboard", to continue working later with additional filtering options.
    143 
    144