Raspberry Pi Grafana/Prometheus Chrony Exporter

Help with operating systems, apps, and software-related issues.
User avatar
ccb056
Site Administrator
Posts: 1003
Joined: January 14th, 2004, 11:36 pm
Location: Texas

Raspberry Pi Grafana/Prometheus Chrony Exporter

Post by ccb056 »

https://grafana.com/grafana/dashboards/19186-chrony/
https://github.com/SuperQ/chrony_exporter
https://linuxhit.com/prometheus-node-ex ... o-install/

Code: Select all

 wget https://github.com/SuperQ/chrony_exporter/releases/download/v0.12.1/chrony_exporter-0.12.1.linux-arm64.tar.gz 

Code: Select all

tar -xvzf chrony_exporter-0.12.1.linux-arm64.tar.gz

Code: Select all

cd chrony_exporter-0.12.1.linux-arm64

Code: Select all

sudo mv chrony_exporter /usr/local/bin
create /etc/systemd/system/chrony_exporter.service

Code: Select all

[Unit]
Description=Chrony Exporter
After=network.target

[Service]
ExecStart=/usr/local/bin/chrony_exporter \
  --web.listen-address=:9123 \
  --collector.sources \
  --collector.serverstats \
  --collector.chmod-socket \
  --chrony.address=unix:///run/chrony/chronyd.sock
Restart=always
User=root

[Install]
WantedBy=multi-user.target

Code: Select all

sudo systemctl daemon-reload

Code: Select all

sudo systemctl enable chrony_exporter

Code: Select all

sudo systemctl start chrony_exporter

Code: Select all

systemctl status chrony_exporter
add to /etc/prometheus/prometheus.yml

Code: Select all

  - job_name: 'chrony_exporter'
    static_configs:
      - targets: ['localhost:9123']   # or use the host IP/hostname
edit /etc/prometheus/prometheus.yml to add

Code: Select all

rule_files:
  - /etc/prometheus/rules/*.yml

Code: Select all

sudo mkdir -p /etc/prometheus/rules
create /etc/prometheus/rules/chrony.yml

Code: Select all

groups:
  - name: Chrony
    rules:
      - record: instance:chrony_clock_error_seconds:abs
        expr: >
          abs(chrony_tracking_last_offset_seconds)
          +
          chrony_tracking_root_dispersion_seconds
          +
          (0.5 * chrony_tracking_root_delay_seconds)

Code: Select all

promtool check config /etc/prometheus/prometheus.yml

Code: Select all

sudo systemctl restart prometheus
User avatar
ccb056
Site Administrator
Posts: 1003
Joined: January 14th, 2004, 11:36 pm
Location: Texas

How to update Chrony Exporter and add sourcestats

Post by ccb056 »

Code: Select all

wget https://github.com/SuperQ/chrony_exporter/releases/download/v0.13.1/chrony_exporter-0.13.1.linux-arm64.tar.gz

Code: Select all

tar -xvf chrony_exporter-0.13.1.linux-arm64.tar.gz

Code: Select all

sudo systemctl stop chrony_exporter

Code: Select all

cd chrony_exporter-0.13.1.linux-arm64

Code: Select all

sudo cp chrony_exporter /usr/local/bin/chrony_exporter

Code: Select all

sudo chmod 755 /usr/local/bin/chrony_exporter

Code: Select all

sudo vi  /etc/systemd/system/chrony_exporter.service
add:

Code: Select all

--collector.sourcestats \

Code: Select all

sudo systemctl daemon-reload

Code: Select all

sudo systemctl start chrony_exporter

Code: Select all

chrony_exporter --version