Home

Awesome

Substrate/PolkaDOT Prometheus scrapper with curl and custom logging to the journaled system to receive the metrics in Grafana with Promntail including new or changed fields.

A monitoring service on Grafana Cloud, Loki, Promtail, CURL

Dashboard


installation

#!/bin/bash

set -euf -o pipefail
exec 1> >(logger -s -t $(basename $0)) 2>&1

while true;
do
    curl -sb -S http://localhost:<PORT>/metrics | grep -v '#' | grep '_count' 
    sleep 15
done
[Unit]
Description=Prometheus Scrapper.
After=network.target 

[Service]
Type=simple 
ExecStart=/bin/bash /usr/sbin/metrics.sh

Restart=always
[Install]
WantedBy=multi-user.target
systemctl daemon-reload 
systemctl enable metrics.service
systemctl start metrics.service
systemctl status metrics.service

Promtail Installation

apt install sudo unzip -y \
&& sudo mkdir /opt/promtail \
&& cd /opt/promtail \
&& wget https://github.com/grafana/loki/releases/download/v2.2.1/promtail-linux-amd64.zip \
&& sudo unzip promtail-linux-amd64.zip

Promtail Configuration template, change the <DLOKI> URL

URL Can be taken from Grafana Cloud Pannel
server:
  http_listen_port: 0
  grpc_listen_port: 0
  log_level: error
clients:
  - url: <DLOKI>
positions:
  filename: /tmp/positions.yaml
  ignore_invalid_yaml: true
scrape_configs:
- job_name: journal
  journal:
    max_age: 60s
    labels:
      job: systemd-journal
  relabel_configs:
    - source_labels: ['__journal__systemd_unit']
      target_label: 'unit'
    - source_labels: ['__journal__hostname']
      target_label: 'hostname'
    - source_labels: ['__journal__host']
      target_label: 'host'
  pipeline_stages:
  # Get this logs
  - match:
      selector: '{job="systemd-journal", unit="metrics.service"}'
      stages:
      - regex:
          expression: '.*(<output>)'
      - labels:
          level:
          output: log
          stream: stream
          timestamp: time
      - timestamp:
          source: timestamp
          format: RFC3339Nano
      - output:
          source: output
./promtail-linux-amd64 -config.file ./substrate-metrics.yaml --dry-run 

Grafana Cloud

{unit="metrics.service"} | regexp "(?P<metric>^[a-zA-Z0-9_]+)(?P<json>\\{([^}]+)\\})\\W(?P<counter>[0-9]+)"
|= "polkadot_"
|= "substrate_"
|~ "substrate_.*kademlia"
{unit="metrics.service"} | regexp "(?P<metric>^[a-zA-Z0-9_]+)(?P<json>\\{([^}]+)\\})\\W(?P<counter>[0-9]+)" |~ "substrate_.*kademlia"

Dashboard download link, Granaba.com###

Download link


For Support && Nominations