Prometheus exporter for several chia node statistics

Overview

prometheus-chia-exporter

Prometheus exporter for several chia node statistics It's assumed that the full node, the harvester and the wallet run on the same system.

dashboard

# HELP chia_netspace_total Current total netspace
# TYPE chia_netspace_total gauge
chia_netspace_total 3.555581383124895e+18
# HELP chia_average_block_time Average time between blocks
# TYPE chia_average_block_time gauge
chia_average_block_time 31.812749003984063
# HELP chia_block_height Current highest block
# TYPE chia_block_height gauge
chia_block_height 255143.0
# HELP chia_sync_state Current sync state
# TYPE chia_sync_state gauge
chia_sync_state{chia_sync_state="synced"} 1.0
chia_sync_state{chia_sync_state="syncing"} 0.0
# HELP chia_wallet_balance Balance of wallets
# TYPE chia_wallet_balance gauge
chia_wallet_balance{id="1",name="Chia Wallet"} 1.899905e+012
# HELP chia_node_connections Currently open connections to node
# TYPE chia_node_connections gauge
chia_node_connections{type="3"} 1.0
chia_node_connections{type="1"} 22.0
chia_node_connections{type="6"} 1.0
# HELP chia_plots_count Total plots farmed by harvester
# TYPE chia_plots_count gauge
chia_plots_count 130.0
# HELP chia_plots_size Total plot size farmed by harvester
# TYPE chia_plots_size gauge
chia_plots_size 1.4148014850864e+013
# HELP chia_farmed_amount Total XCH farmed by harvester
# TYPE chia_farmed_amount gauge
chia_farmed_amount 2e+012
# HELP chia_farmed_last_block Last height a farm reward was farmed
# TYPE chia_farmed_last_block gauge
chia_farmed_last_block 206883.0
# HELP chia_time_to_win Expected time to win 
# TYPE chia_time_to_win gauge
chia_time_to_win 7.99496e+06
# HELP chia_reward_address_info Farming rewards go to this address 
# TYPE chia_reward_address_info gauge
chia_reward_address_info{farmer_target="farmer_address",pool_target="pool_address"} 1.0
# HELP chia_difficulty Current blockchain difficulty 
# TYPE chia_difficulty gauge
chia_difficulty 3.044624155857344e+18

Requirements

The exporter is meant to be run from your chia-blockchain venv. Additionally you need prometheus-client as specified in requirements.txt

cd chia-blockchain
. ./activate
cd ../prometheus-chia-exporter
pip install -r requirements.txt

Installation

Copy the needed files to their locations as described below

# Copy the systemd unit file
sudo cp systemd/chia_exporter.service /etc/systemd/system
# Edit the unit file to have correct chia blockchain path and username
# Copy the environment file
sudo cp systemd/chia_exporter.env /etc/default/
# If the node you want to monitor does not run on the same host as the exporter, edit the env file
# copy the exporter to /usr/local/bin/
sudo cp prometheus-chia-exporter/chia-exporter.py /usr/local/bin/
# Reload systemd to have access to the new service
sudo systemctl daemon-reload
# Make sure the service is started on system boot
sudo systemctl enable chia_exporter
# Start the service
sudo systemctl start chia_exporter

Custom config

You can monitor remote nodes by editing /etc/default/chia_exporter.env and changing the settings there

Usage

Start the systemd service Import grafana/dashboard.json to your grafana The exporter will listen on port 9824 Add prometheus config

scrape_configs:
  - job_name: 'chia'
    static_configs:
      - targets: ['nodeip:9824']

Overriding hostnames

If you are running the full node on a different host or container, you can override the hostnames used for connecting to the daemons by setting one or all of the following environment variables: FULL_NODE_HOST, WALLET_HOST, HARVESTER_HOST, FARMER_HOST. All hostnames default to localhost.

Updating

To update just copy the chia-exporter.py file to /usr/local/bin/chia-exporter.py again and restart the service sodo systemctl restart chia_exporter

Donation

If you like this work and it helps you to monitor your farm please consider donating XCH to xch1z026zx5a7xask0srznwnv9ktllc96flvcsk9ly7k06dhnje0asfsym8xuc It will be really appreciated and help me keeping this exporter working

Comments
  • Grafana dashboard does not displace correct data for farmer and pool addresses

    Grafana dashboard does not displace correct data for farmer and pool addresses

    The prometheus exporter shows this:

    # HELP chia_reward_address_info Farming rewards go to this address 
    # TYPE chia_reward_address_info gauge
    chia_reward_address_info{farmer_target="<redacted>",pool_target="<redacted>"} 1.0
    

    but the grafana dashboard shows the 1.0 rather than the label values? I think this is an issue in the Grafana dashboard JSON?

    opened by sbates130272 5
  • "self_hostname" referenced but not used?

    The README.md mentions a "self_hostname" in the exporter but this string is not in the exporter? Am I missing something?

    Also, "sudo not sudp" in one spot in the README.

    opened by sbates130272 5
  • README does not inform user to place chai_exporter in /usr/local/bin/

    README does not inform user to place chai_exporter in /usr/local/bin/

    The systemd service file expects the chai_exporter.py to be in /usr/local/bin in the chia venv but there is no instruction to do this in the README. Update README to include this step.

    opened by sbates130272 2
  • Request a default port for the chai-exporter

    Request a default port for the chai-exporter

    The port used for chia_exporter is currently 8000 which I do not think is a safe port. Instead update the default Prometheus port wiki to allocate a new port for this exporter and then update the port used by the exporter.

    https://github.com/prometheus/prometheus/wiki/Default-port-allocations

    opened by sbates130272 2
  • Allow overriding hostnames via ENV

    Allow overriding hostnames via ENV

    Hey, thanks for creating this! I'm running chia in a docker container and would like to run this in a separate container, so I modified the code a bit to allow overriding the default hostname to something set by the environment. A quick test showed that this would work by using something like this, for example:

    docker run --rm \
      --network chia-node_chia-node \
      -e FULL_NODE_HOST=chia \
      -e WALLET_HOST=chia \
      -e HARVESTER_HOST=chia \
      -e FARMER_HOST=chia \
      -v <somewhere>/chia/home/:/root/.chia/:ro \
      -p 12345:8000 \
      strayer/chia-exporter-test
    

    I didn't add any environment for the RPC ports, since the config will need to be included anyway for the certificates and whatever else the Python chia library needs.

    opened by strayer 1
  • On restart the exporter reports 0 for all values

    On restart the exporter reports 0 for all values

    On restart the exporter reports 0 for all values for almost 30-50 seconds. This messes up the metrics display in grafana.

    The exporter should report either no metrics at all or null values for all metrics

    opened by speedmann 1
  • Add support for multiple harvesters/farmers in Grafana dashboard and prometheus scrape config

    Add support for multiple harvesters/farmers in Grafana dashboard and prometheus scrape config

    Right now we can run the chia-exporter on multiple machines but there is no example prometheus or Grafana code to either view the data on each machine or add up stats (like plots) across all machines. Can we look at adding this?

    opened by sbates130272 1
Releases(v0.0.1)
  • v0.0.1(May 12, 2021)

    This is the initial release to setup for better visibility in the future. WARNING The listen port changed from 8000 to 9824. This will create new metrics and your dashboard will look broken. Sorry for that. But now the port is official and not likely to be changed any more

    Source code(tar.gz)
    Source code(zip)
A basic JSON-RPC implementation for your Flask-powered sites

Flask JSON-RPC A basic JSON-RPC implementation for your Flask-powered sites. Some reasons you might want to use: Simple, powerful, flexible and python

Cenobit Technologies 273 Dec 01, 2022
A rate limiter for Starlette and FastAPI

SlowApi A rate limiting library for Starlette and FastAPI adapted from flask-limiter. Note: this is alpha quality code still, the API may change, and

Laurent Savaete 562 Jan 01, 2023
Fetching Cryptocurrency Prices from Coingecko and Displaying them on Grafana

cryptocurrency-prices-grafana Fetching Cryptocurrency Prices from Coingecko and Displaying them on Grafana About This stack consists of: Prometheus (t

Ruan Bekker 7 Aug 01, 2022
FastAPI Skeleton App to serve machine learning models production-ready.

FastAPI Model Server Skeleton Serving machine learning models production-ready, fast, easy and secure powered by the great FastAPI by Sebastián Ramíre

268 Jan 01, 2023
Adds integration of the Chameleon template language to FastAPI.

fastapi-chameleon Adds integration of the Chameleon template language to FastAPI. If you are interested in Jinja instead, see the sister project: gith

Michael Kennedy 124 Nov 26, 2022
Single Page App with Flask and Vue.js

Developing a Single Page App with FastAPI and Vue.js Want to learn how to build this? Check out the post. Want to use this project? Build the images a

91 Jan 05, 2023
Prometheus exporter for Starlette and FastAPI

starlette_exporter Prometheus exporter for Starlette and FastAPI. The middleware collects basic metrics: Counter: starlette_requests_total Histogram:

Steve Hillier 225 Jan 05, 2023
A FastAPI Framework for things like Database, Redis, Logging, JWT Authentication and Rate Limits

A FastAPI Framework for things like Database, Redis, Logging, JWT Authentication and Rate Limits Install You can install this Library with: pip instal

Tert0 33 Nov 28, 2022
Complete Fundamental to Expert Codes of FastAPI for creating API's

FastAPI FastAPI is a modern, fast (high-performance), web framework for building APIs with Python 3 based on standard Python type hints. The key featu

Pranav Anand 1 Nov 28, 2021
FastAPI Auth Starter Project

This is a template for FastAPI that comes with authentication preconfigured.

Oluwaseyifunmi Oyefeso 6 Nov 13, 2022
A FastAPI Plug-In to support authentication authorization using the Microsoft Authentication Library (MSAL)

FastAPI/MSAL - MSAL (Microsoft Authentication Library) plugin for FastAPI FastAPI - https://github.com/tiangolo/fastapi FastAPI is a modern, fast (hig

Dudi Levy 15 Jul 20, 2022
FastAPI IPyKernel Sandbox

FastAPI IPyKernel Sandbox This repository is a light-weight FastAPI project that is meant to provide a wrapper around IPyKernel interactions. It is in

Nick Wold 2 Oct 25, 2021
Cookiecutter template for FastAPI projects using: Machine Learning, Poetry, Azure Pipelines and Pytests

cookiecutter-fastapi In order to create a template to FastAPI projects. 🚀 Important To use this project you don't need fork it. Just run cookiecutter

Arthur Henrique 225 Dec 28, 2022
Voucher FastAPI

Voucher-API Requirement Docker Installed on system Libraries Pandas Psycopg2 FastAPI PyArrow Pydantic Uvicorn How to run Download the repo on your sys

Hassan Munir 1 Jan 26, 2022
Docker image with Uvicorn managed by Gunicorn for high-performance FastAPI web applications in Python 3.6 and above with performance auto-tuning. Optionally with Alpine Linux.

Supported tags and respective Dockerfile links python3.8, latest (Dockerfile) python3.7, (Dockerfile) python3.6 (Dockerfile) python3.8-slim (Dockerfil

Sebastián Ramírez 2.1k Dec 31, 2022
Town / City geolocations with FastAPI & Mongo

geolocations-api United Kingdom Town / City geolocations with FastAPI & Mongo Build container To build a custom image or extend the api run the follow

Joe Gasewicz 3 Jan 26, 2022
🐞 A debug toolbar for FastAPI based on the original django-debug-toolbar. 🐞

Debug Toolbar 🐞 A debug toolbar for FastAPI based on the original django-debug-toolbar. 🐞 Swagger UI & GraphQL are supported. Documentation: https:/

Dani 74 Dec 30, 2022
Formatting of dates and times in Flask templates using moment.js.

Flask-Moment This extension enhances Jinja2 templates with formatting of dates and times using moment.js. Quick Start Step 1: Initialize the extension

Miguel Grinberg 358 Nov 28, 2022
Feature rich robust FastAPI template.

Flexible and Lightweight general-purpose template for FastAPI. Usage ⚠️ Git, Python and Poetry must be installed and accessible ⚠️ Poetry version must

Pavel Kirilin 588 Jan 04, 2023
Opinionated authorization package for FastAPI

FastAPI Authorization Installation pip install fastapi-authorization Usage Currently, there are two models available: RBAC: Role-based Access Control

Marcelo Trylesinski 18 Jul 04, 2022