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)
Local Telegram Bot With FastAPI & Ngrok

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

Ömer Faruk Özdemir 7 Dec 25, 2022
REST API with FastAPI and JSON file.

FastAPI RESTAPI with a JSON py 3.10 First, to install all dependencies, in ./src/: python -m pip install -r requirements.txt Second, into the ./src/

Luis Quiñones Requelme 1 Dec 15, 2021
flask extension for integration with the awesome pydantic package

flask extension for integration with the awesome pydantic package

249 Jan 06, 2023
Sample project showing reliable data ingestion application using FastAPI and dramatiq

Create and deploy a reliable data ingestion service with FastAPI, SQLModel and Dramatiq This is the source code for the data ingestion service explain

François Voron 31 Nov 30, 2022
Code for my FastAPI tutorial

FastAPI tutorial Code for my video tutorial FastAPI tutorial What is FastAPI? FastAPI is a high-performant REST API framework for Python. It's built o

José Haro Peralta 9 Nov 15, 2022
A request rate limiter for fastapi

fastapi-limiter Introduction FastAPI-Limiter is a rate limiting tool for fastapi routes. Requirements redis Install Just install from pypi pip insta

long2ice 200 Jan 08, 2023
fastapi-cache is a tool to cache fastapi response and function result, with backends support redis and memcached.

fastapi-cache Introduction fastapi-cache is a tool to cache fastapi response and function result, with backends support redis, memcache, and dynamodb.

long2ice 551 Jan 08, 2023
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
Github timeline htmx based web app rewritten from Common Lisp to Python FastAPI

python-fastapi-github-timeline Rewrite of Common Lisp htmx app _cl-github-timeline into Python using FastAPI. This project tries to prove, that with h

Jan Vlčinský 4 Mar 25, 2022
API for Submarino store

submarino-api API for the submarino e-commerce documentation read the documentation in: https://submarino-api.herokuapp.com/docs or in https://submari

Miguel 1 Oct 14, 2021
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
FastAPI Auth Starter Project

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

Oluwaseyifunmi Oyefeso 6 Nov 13, 2022
Repository for the Demo of using DVC with PyCaret & MLOps (DVC Office Hours - 20th Jan, 2022)

Using DVC with PyCaret & FastAPI (Demo) This repo contains all the resources for my demo explaining how to use DVC along with other interesting tools

Tezan Sahu 6 Jul 22, 2022
Slack webhooks API served by FastAPI

Slackers Slack webhooks API served by FastAPI What is Slackers Slackers is a FastAPI implementation to handle Slack interactions and events. It serves

Niels van Huijstee 68 Jan 05, 2023
Prometheus integration for Starlette.

Starlette Prometheus Introduction Prometheus integration for Starlette. Requirements Python 3.6+ Starlette 0.9+ Installation $ pip install starlette-p

José Antonio Perdiguero 229 Dec 21, 2022
FastAPI Server Session is a dependency-based extension for FastAPI that adds support for server-sided session management

FastAPI Server-sided Session FastAPI Server Session is a dependency-based extension for FastAPI that adds support for server-sided session management.

DevGuyAhnaf 5 Dec 23, 2022
Пример использования GraphQL Ariadne с FastAPI и сравнение его с GraphQL Graphene FastAPI

FastAPI Ariadne Example Пример использования GraphQL Ariadne с FastAPI и сравнение его с GraphQL Graphene FastAPI - GitHub ###Запуск на локальном окру

ZeBrains Team 9 Nov 10, 2022
A utility that allows you to use DI in fastapi without Depends()

fastapi-better-di What is this ? fastapi-better-di is a utility that allows you to use DI in fastapi without Depends() Installation pip install fastap

Maxim 9 May 24, 2022
A fast and durable Pub/Sub channel over Websockets. FastAPI + WebSockets + PubSub == ⚡ 💪 ❤️

⚡ 🗞️ FastAPI Websocket Pub/Sub A fast and durable Pub/Sub channel over Websockets. The easiest way to create a live publish / subscribe multi-cast ov

8 Dec 06, 2022
京东图片点击验证码识别

京东图片验证码识别 本项目是@yqchilde 大佬的 JDMemberCloseAccount 识别图形验证码(#45)思路验证,若你也有思路可以提交Issue和PR也可以在 @yqchilde 的 TG群 找到我 声明 本脚本只是为了学习研究使用 本脚本除了采集处理验证码图片没有其他任何功能,也

AntonVanke 37 Dec 22, 2022