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)
Farlimit - FastAPI rate limit with python

FastAPIRateLimit Contributing is F&E (free&easy) Y Usage pip install farlimit N

omid 27 Oct 06, 2022
Stac-fastapi built on Tile38 and Redis to support caching

stac-fastapi-caching Stac-fastapi built on Tile38 to support caching. This code is built on top of stac-fastapi-elasticsearch 0.1.0 with pyle38, a Pyt

Jonathan Healy 4 Apr 11, 2022
Utils for fastapi based services.

Installation pip install fastapi-serviceutils Usage For more details and usage see: readthedocs Development Getting started After cloning the repo

Simon Kallfass 31 Nov 25, 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 Documentation: https://fast

Adam Watkins 943 Jan 01, 2023
Minecraft biome tile server writing on Python using FastAPI

Blocktile Minecraft biome tile server writing on Python using FastAPI Usage https://blocktile.herokuapp.com/overworld/{seed}/{zoom}/{col}/{row}.png s

Vladimir 2 Aug 31, 2022
Simple example of FastAPI + Celery + Triton for benchmarking

You can see the previous work from: https://github.com/Curt-Park/producer-consumer-fastapi-celery https://github.com/Curt-Park/triton-inference-server

Jinwoo Park (Curt) 37 Dec 29, 2022
Prometheus exporter for several chia node statistics

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

30 Sep 19, 2022
Simple notes app backend using Python's FastAPI framework.

my-notes-app Simple notes app backend using Python's FastAPI framework. Route "/": User login (GET): return 200, list of all of their notes; User sign

José Gabriel Mourão Bezerra 2 Sep 17, 2022
Pagination support for flask

flask-paginate Pagination support for flask framework (study from will_paginate). It supports several css frameworks. It requires Python2.6+ as string

Lix Xu 264 Nov 07, 2022
A RESTful API for creating and monitoring resource components of a hypothetical build system. Built with FastAPI and pydantic. Complete with testing and CI.

diskspace-monitor-CRUD Background The build system is part of a large environment with a multitude of different components. Many of the components hav

Nick Hopewell 67 Dec 14, 2022
FastAPI Project Template

The base to start an openapi project featuring: SQLModel, Typer, FastAPI, JWT Token Auth, Interactive Shell, Management Commands.

A.Freud 4 Dec 05, 2022
Cube-CRUD is a simple example of a REST API CRUD in a context of rubik's cube review service.

Cube-CRUD is a simple example of a REST API CRUD in a context of rubik's cube review service. It uses Sqlalchemy ORM to manage the connection and database operations.

Sebastian Andrade 1 Dec 11, 2021
Keepalive - Discord Bot to keep threads from expiring

keepalive Discord Bot to keep threads from expiring Installation Create a new Di

Francesco Pierfederici 5 Mar 14, 2022
FastAPI with Docker and Traefik

Dockerizing FastAPI with Postgres, Uvicorn, and Traefik Want to learn how to build this? Check out the post. Want to use this project? Development Bui

51 Jan 06, 2023
Opinionated set of utilities on top of FastAPI

FastAPI Contrib Opinionated set of utilities on top of FastAPI Free software: MIT license Documentation: https://fastapi-contrib.readthedocs.io. Featu

identix.one 543 Jan 05, 2023
Twitter API monitor with fastAPI + MongoDB

Twitter API monitor with fastAPI + MongoDB You need to have a file .env with the following variables: DB_URL="mongodb+srv://mongodb_path" DB_URL2=

Leonardo Ferreira 3 Apr 08, 2022
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
Easy and secure implementation of Azure AD for your FastAPI APIs 🔒

FastAPI-Azure-auth Azure AD Authentication for FastAPI apps made easy. 🚀 Description FastAPI is a modern, fast (high-performance), web framework for

Intility 216 Dec 27, 2022
Browse JSON API in a HTML interface.

Falcon API Browse This project provides a middleware for Falcon Web Framework that will render the response in an HTML form for documentation purpose.

Abhilash Raj 4 Mar 16, 2022
FastAPI Auth Starter Project

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

Oluwaseyifunmi Oyefeso 6 Nov 13, 2022