Code Monkey home page Code Monkey logo

nicehash-exporter's Introduction

Build DockerImage Docker Hub

NiceHash exporter

A small service to expose miner stats from NH to Prometheus.

Running the app

Local install / dev

You need node 12, start with npm i and then node app.js. For setting the NH api keys you need to export NH_API_KEY="key" and export NH_API_SECRET="secret" before the service start.

You can reach the metrics on localhost:3000/metrics.

Docker and compose

For docker you can run;

docker run -e NH_API_KEY="key" -e NH_API_SECRET="secret" -e NH_API_ORG_ID="orgId" ghcr.io/tg44/nicehash-exporter

For docker compose;

version: '3.1'
services:
  nicehash-exporter:
    image: ghcr.io/tg44/nicehash-exporter
    restart: unless-stopped
    environment:
      - NH_API_KEY=key
      - NH_API_SECRET=secret
      - NH_API_ORG_ID=orgId
      - PORT=3000 #optionally you can override the port inside for dev reasons, default is 3000
      - REFRESH_RATE_SECONDS=30 #optionally you can override the api poll rate, default is 30
      - NODDE_METRICS_PREFIX=nh_ #optionally you can override the node system/app metrics prefix, default is empty
      - NH_METRICS_PREFIX=nh_ #optionally you can override the NH metrics prefix, default is nh_
      - NH_RATES=BTCUSDC,BTCEURS #optionally you can override the exported rates in a comma separated list of rates
    ports:
      - 3000:3000

Breaking changes

  • 2021.07.27.
    • nh_total_btc modified to actually show the total money in btc for the account and not only just the total btc amount
    • we will permanently move away from dockerhub, the latest images will be pushed, but the documentation and the other infos will only be updated here
      • DH freeze the free builds, while GH-Actions not only build free, but gives us public repositories too
  • 2021.06.19.
    • due to changes on NH end, the orgId mandatory from now
  • 2021.05.31.
    • btc_usd_rate get renamed to btcusdc_rate due to the configurable rate list option

Support

PRs are always welcome!

ETH: 0x58f2198cda7d6cac855dd3fa29abe67e98adb2cd

But, if you want to support my work in any way just send me an email ;) (You can find my email address in the git commit history.)

nicehash-exporter's People

Contributors

esille avatar tg44 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

nicehash-exporter's Issues

Version of miner software

congratulations for the tool, I have a small request, is it possible to also enter the version of the miner running the worker in the deviceStatusInfo? or on another tab that still has the rigname field

403 Forbidden on any auth'ed request

Hi,

I just started getting 403 Forbidden for any request that requires authentication. I've attached my docker logs to this ticket. Not sure if it's something that the authentication is wrong or I'm blocked by Cloudflare (I see some reference in the logs).

nicehashexporter.txt

Essentially, I'd like to know if anyone else is having this issue, or if it's just me.

Thanks!

Prometheus and data over periods of time

Hello,

I'm having issues with getting this data to be represented in Grafana properly, but I'm starting to think it's a Prometheus thing. When data is recorded, eg. if I mine for 5 minutes with a 3090, stop, and continue to graph data (even query in Prometheus), it'll continue to "extend" that value over the next few hours. I need to write some crazy queries that look up a devices current mining status to show it or not:

nh_device_power{rig_name=~"$rig", device_type!="CPU", device_name=~"$device"} + on(device_id, device_name) nh_device_status_info{status="MINING"}-1

Am I doing something stupid? I don't think other databases have an issue like this, and I'm tempted to port this to something else (like InfluxDB), but that's where my knowledge of the Nicehash API, and it's crazy requirements for nonce and stuff come in. Any tips?

support new release software

hi, i have a questions:

with the new release of nicehash the data structure is changed, your (fantastic) product still active and supported (I sincerely hope so)?

i show you the problem:
in older release the rig_name is here

"rigId": "0-ihfhdlifhsdfhsdl", "type": "MANAGED", "name": "THISNAMERIG", "statusTime": 1704889765925, "joinTime": 1704877919, "minerStatus": "MINING", "groupName": "", "unpaidAmount": "0.00000000", "softwareVersions": "NHM/3.0.9.2", "devices": [ {
in the new release

"rigId": "0-uaasdsdasdasdasg", "type": "MANAGED", "statusTime": 1704889772309, "minerStatus": "MINING", "groupName": "", "unpaidAmount": "0.00000004", "stats": [ { "statsTime": 1704889764000, "market": "EU", "algorithm": { "enumName": "KAWPOW", "description": "KAWPOW" }, "unpaidAmount": "0.00000004", "difficulty": 67108864, "proxyId": 1, "timeConnected": 1704886876794, "xnsub": true, "speedAccepted": 2.7332694653333336, "speedRejectedR1Target": 0, "speedRejectedR2Stale": 0, "speedRejectedR3Duplicate": 0, "speedRejectedR4NTime": 0, "speedRejectedR5Other": 0, "speedRejectedTotal": 0, "profitability": 0 } ], "profitability": 0, "localProfitability": 0.000002087076897842218, "v4": { "versions": [ "NHM/3.1.0.7", "Microsoft Windows NT 10.0.17763.0" ], "mdv": { "state": 2 }, "mmv": { "targetState": 2, "workerName": "THISNAMERIG" }, "osv": [], "odv": [ { "key": "Uptime", "unit": "s", "value": "11941" }, { "key": "IP address", "unit": "", "value": "ipaddremachine" }, { "key": "Profiles bundle id", "unit": "", "value": "" }, { "key": "Profiles bundle name", "unit": "", "value": "" } ], "omv": [ { "id": 370, "displayName": "User name", "displayGroup": 0, "defaultValue": { "type": "DataTypesString", "stringValue": "walletnumber" }, "range": [ { "type": "DataTypesInteger", "intValue": 64 }, { "type": "DataTypesString" } ], "value": { "type": "DataTypesString", "stringValue": "walletnumber" } }, { "id": 371, "displayName": "Worker name", "displayGroup": 0, "defaultValue": { "type": "DataTypesString", "stringValue": "THISNAMERIG" }, "range": [ { "type": "DataTypesInteger", "intValue": 64 }, { "type": "DataTypesString" } ], "value": { "type": "DataTypesString", "stringValue": "THISNAMERIG" } },

nh_total_btc and nh_btc_usd_rate are always 0

Hi,

I'm using docker image and noticed that nh_total_btc and nh_btc_usd_rate are always 0. After checking logs in container i see following error reported:

(node:1) UnhandledPromiseRejectionWarning: TypeError: Value is not a valid number: undefined                                  
    at Object.set (/home/node/app/node_modules/prom-client/lib/gauge.js:163:10)                                               
    at /home/node/app/app.js:124:45                                                                                           
    at Array.forEach (<anonymous>)                                                                                            
    at refreshMetrics (/home/node/app/app.js:122:19)                                                                          
    at runMicrotasks (<anonymous>)                                                                                            
    at processTicksAndRejections (internal/process/task_queues.js:97:5)                                                       
(node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an 
async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node pro
cess on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli
_unhandled_rejections_mode). (rejection id: 1133)          

Chould you please have a look?

Thanks!
Erik

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.