Prometheus exporter for AntMiner
System dependencies
sudo apt install python3.9 python3.9-dev -y
Virtual Environment
pip3 install pipenv
Install python dependencies
pipenv install --dev
Activate virtual environment
pipenv shell
Reload VS Code and set Python Interpretor for it
- Docker required
- Fill up
config.yaml
with your machine IP address
Build and run image
docker build -f tests/antminer_emulator/Dockerfile -t antminer_exporter/antminer_emulator tests/antminer_emulator
docker run -d -p 80:80 antminer_exporter/antminer_emulator
- Run app
- Go to
http://localhost:8000/
# HELP antminer_uptime_seconds General uptime of miner in seconds
# TYPE antminer_uptime_seconds summary
antminer_uptime_seconds_count 1.0
antminer_uptime_seconds_sum 9000.0
# HELP antminer_uptime_seconds_created General uptime of miner in seconds
# TYPE antminer_uptime_seconds_created gauge
antminer_uptime_seconds_created 1.6174733872678773e+09
All functions and metrics should have tests for them.
tests/test_metrics.py
import requests
def get_metrics() -> requests.Response:
return requests.request('GET', 'http://localhost:8000')
def test_get_metrics():
assert get_metrics().status_code == 200
class TestAntminerUptimeSeconds:
def test_antminer_uptime_seconds_count(self):
r = get_metrics().text.split('\n')
subs = 'antminer_uptime_seconds_count'
res = [i for i in r if subs in i]
assert subs in res[0]