taler-docs

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

grafana-loki.rst (4886B)


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