taler-docs

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

grafana-loki.rst (4830B)


      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 
     19 Grafana Loki
     20 ############
     21 
     22 Loki is an aggregation system really similar to Prometheus, but instead of reading metrics, it reads logs (via push).
     23 Please check the `official documentation website <https://grafana.com/docs/loki/latest/get-started/>`_ for additional information. 
     24  
     25 Create a system user
     26 ====================
     27 
     28 .. code-block:: console
     29 
     30    # useradd --system --no-create-home --shell /bin/false loki
     31    # useradd --system --no-create-home --shell /bin/false promtail
     32 
     33 Download Loki
     34 =============
     35 
     36 * Download
     37 * Extract
     38 * Copy to /usr/local/bin
     39 * Set ownership and permissions
     40 
     41 .. code-block:: console
     42 
     43    # cd /tmp
     44    # wget https://github.com/grafana/loki/releases/download/v3.0.0/loki-linux-amd64.zip
     45    # unzip loki-linux-amd64.zip -d .
     46    # mv loki-linux-amd64 loki
     47    # cp loki /usr/local/bin/
     48 
     49 Loki configuration file
     50 =========================================
     51 
     52 .. code-block:: yaml
     53 
     54    auth_enabled: false
     55 
     56    server:
     57      http_listen_port: 3100
     58      grpc_listen_port: 9096
     59 
     60    common:
     61      instance_addr: 127.0.0.1
     62      path_prefix: /tmp/loki
     63      storage:
     64        filesystem:
     65           chunks_directory: /tmp/loki/chunks
     66           rules_directory: /tmp/loki/rules
     67      replication_factor: 1
     68      ring:
     69        kvstore:
     70          store: inmemory
     71 
     72    query_range:
     73      results_cache:
     74        cache:
     75          embedded_cache:
     76            enabled: true
     77            max_size_mb: 100
     78 
     79    schema_config:
     80      configs:
     81        - from: 2020-10-24
     82          store: tsdb
     83          object_store: filesystem
     84          schema: v13
     85          index:
     86            prefix: index_
     87            period: 24h
     88 
     89 Systemd service file
     90 ====================
     91 
     92 .. code-block:: systemd
     93 
     94    # Path: /etc/systemd/system/loki.service
     95 
     96    [Unit]
     97    Description=Loki service
     98    After=network.target
     99 
    100    [Service]
    101    Type=simple
    102    User=loki
    103    ExecStart=/usr/local/bin/loki -config.file /etc/loki/config.yml
    104    # Give a reasonable amount of time for the server to start up/shut down
    105    TimeoutSec = 120
    106    Restart = on-failure
    107    RestartSec = 2
    108 
    109    [Install]
    110    WantedBy=multi-user.target
    111 
    112 Refresh systemd and restart
    113 ===========================
    114 
    115 .. code-block:: console
    116 
    117    # systemctl daemon-reload
    118    # systemctl enable --now loki
    119    # systemctl status loki
    120    # systemctl restart prometheus
    121 
    122 Check
    123 -----
    124 
    125 http://ip:3100
    126 
    127 Close the 3100 port with Nginx
    128 ==============================
    129 
    130 .. code-block:: nginx
    131 
    132    # Path: /etc/nginx/sites-available/loki.conf
    133 
    134    upstream loki {
    135     server 127.0.0.1:3100; # Loopback
    136     keepalive 15;
    137    }
    138 
    139    server {
    140     listen 80;
    141     listen [::]:80;
    142 
    143    server_name loki.taler-ops.ch;
    144    root /dev/null;
    145 
    146    # LOKI
    147 
    148    location / {
    149     proxy_read_timeout 1800s;
    150     proxy_connect_timeout 1600s;
    151     proxy_pass http://loki;
    152     }
    153 
    154    location /ready {
    155     proxy_pass http://loki;
    156     proxy_http_version 1.1;
    157     proxy_set_header Connection "Keep-Alive";
    158     proxy_set_header Proxy-Connection "Keep-Alive";
    159     proxy_redirect off;
    160     auth_basic "off";
    161     }
    162 
    163    }
    164 
    165 - Enable in Nginx the new virtualhost file
    166 
    167 .. code-block:: console
    168 
    169    # ln -s /etc/nginx/sites-available/loki.conf /etc/nginx/sites-enabled/loki.conf
    170    # nginx -t
    171    # systemctl reload nginx
    172 
    173 Edit the loki configuration file
    174 ================================
    175 
    176 .. code-block:: yaml
    177 
    178   #Path: /etc/loki/config.yml
    179   server:
    180     http_listen_port: 3100
    181     grpc_listen_port: 9096
    182     # Add this to close the 3100 port
    183     http_listen_address: 127.0.0.1
    184 
    185 Refresh systemd and restart
    186 ===========================
    187 
    188 .. code-block:: console
    189 
    190    # systemctl restart nginx 
    191    # systemctl restart loki
    192    # systemctl restart prometheus
    193 
    194 Check
    195 -----
    196 
    197 Check that the 3100 port is publicly closed by typing in your Web browser http://ip:3100. At
    198 the same time change through the Grafana control panel, your loki data source server URL field,
    199 so it can connect now through the specified subdomain in the nginx virtualhost file (in our test case
    200 loki.taler-ops.ch). 
    201 
    202 Grafana control panel
    203 =====================
    204 
    205 You can now to go the `Grafana control panel <https://grafana.taler.net>`_ and easily
    206 add the new Loki data source.
    207 
    208