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)
Reusable utilities for FastAPI

Reusable utilities for FastAPI Documentation: https://fastapi-utils.davidmontague.xyz Source Code: https://github.com/dmontagu/fastapi-utils FastAPI i

David Montague 1.3k Jan 04, 2023
FastAPI Socket.io with first-class documentation using AsyncAPI

fastapi-sio Socket.io FastAPI integration library with first-class documentation using AsyncAPI The usage of the library is very familiar to the exper

Marián Hlaváč 9 Jan 02, 2023
CLI and Streamlit applications to create APIs from Excel data files within seconds, using FastAPI

FastAPI-Wrapper CLI & APIness Streamlit App Arvindra Sehmi, Oxford Economics Ltd. | Website | LinkedIn (Updated: 21 April, 2021) fastapi-wrapper is mo

Arvindra 49 Dec 03, 2022
Instrument your FastAPI app

Prometheus FastAPI Instrumentator A configurable and modular Prometheus Instrumentator for your FastAPI. Install prometheus-fastapi-instrumentator fro

Tim Schwenke 441 Jan 05, 2023
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
Boilerplate code for quick docker implementation of REST API with JWT Authentication using FastAPI, PostgreSQL and PgAdmin ⭐

FRDP Boilerplate code for quick docker implementation of REST API with JWT Authentication using FastAPI, PostgreSQL and PgAdmin ⛏ . Getting Started Fe

BnademOverflow 53 Dec 29, 2022
The template for building scalable web APIs based on FastAPI, Tortoise ORM and other.

FastAPI and Tortoise ORM. Powerful but simple template for web APIs w/ FastAPI (as web framework) and Tortoise-ORM (for working via database without h

prostomarkeloff 95 Jan 08, 2023
Code Specialist 27 Oct 16, 2022
Starlette middleware for Prerender

Prerender Python Starlette Starlette middleware for Prerender Documentation: https://BeeMyDesk.github.io/prerender-python-starlette/ Source Code: http

BeeMyDesk 14 May 02, 2021
Flask-Bcrypt is a Flask extension that provides bcrypt hashing utilities for your application.

Flask-Bcrypt Flask-Bcrypt is a Flask extension that provides bcrypt hashing utilities for your application. Due to the recent increased prevelance of

Max Countryman 310 Dec 14, 2022
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
Local Telegram Bot With FastAPI & Ngrok

An easy local telegram bot server with python, fastapi and ngrok.

Ömer Faruk Özdemir 7 Dec 25, 2022
Hyperlinks for pydantic models

Hyperlinks for pydantic models In a typical web application relationships between resources are modeled by primary and foreign keys in a database (int

Jaakko Moisio 10 Apr 18, 2022
An alternative implement of Imjad API | Imjad API 的开源替代

HibiAPI An alternative implement of Imjad API. Imjad API 的开源替代. 前言 由于Imjad API这是什么?使用人数过多, 致使调用超出限制, 所以本人希望提供一个开源替代来供社区进行自由的部署和使用, 从而减轻一部分该API的使用压力 优势

Mix Technology 450 Dec 29, 2022
Run your jupyter notebooks as a REST API endpoint. This isn't a jupyter server but rather just a way to run your notebooks as a REST API Endpoint.

Jupter Notebook REST API Run your jupyter notebooks as a REST API endpoint. This isn't a jupyter server but rather just a way to run your notebooks as

Invictify 54 Nov 04, 2022
A dynamic FastAPI router that automatically creates CRUD routes for your models

⚡ Create CRUD routes with lighting speed ⚡ A dynamic FastAPI router that automatically creates CRUD routes for your models

Adam Watkins 950 Jan 08, 2023
cookiecutter template for web API with python

Python project template for Web API with cookiecutter What's this This provides the project template including minimum test/lint/typechecking package

Hitoshi Manabe 4 Jan 28, 2021
fastapi-mqtt is extension for MQTT protocol

fastapi-mqtt MQTT is a lightweight publish/subscribe messaging protocol designed for M2M (machine to machine) telemetry in low bandwidth environments.

Sabuhi 144 Dec 28, 2022
MS Graph API authentication example with Fast API

MS Graph API authentication example with Fast API What it is & does This is a simple python service/webapp, using FastAPI with server side rendering,

Andrew Hart 4 Aug 11, 2022
A Python framework to build Slack apps in a flash with the latest platform features.

Bolt for Python A Python framework to build Slack apps in a flash with the latest platform features. Read the getting started guide and look at our co

SlackAPI 684 Jan 09, 2023