nanocurrency / nano-prom-exporter

Prometheus Exporter for nano_node
MIT License
4 stars 6 forks source link

KeyError #6

Open tsg-l opened 3 years ago

tsg-l commented 3 years ago

When attempting to install the pushgateway with the following command, I get the below KeyError.

nano-prom --rpchost ::1 --rpc_port 55000 --datapath /NanoBeta/NanoBeta:/root --push_gateway http://localhost:9091 --hostname nanobeta

loaded config, None Traceback (most recent call last): File "/usr/local/bin/nano-prom", line 8, in sys.exit(main()) File "/usr/local/lib/python3.8/dist-packages/nano_prom_exporter/main.py", line 70, in main stats = statsCollection.gatherStats(rpcLatency) File "/usr/local/lib/python3.8/dist-packages/nano_prom_exporter/nanoRPC.py", line 106, in gatherStats stats = nanoStats(self.lastData) File "/usr/local/lib/python3.8/dist-packages/nano_prom_exporter/nanoRPC.py", line 26, in init self.ActiveDifficulty = collection['active_difficulty']['multiplier'] KeyError: 'active_difficulty'

zhyatt commented 3 years ago

Which version of the beta build are you running? The active_difficulty RPC was temporarily removed in V22.0DB15 which could have caused this error. It was subsequently added back in as deprecated in V22.0DB16 so upgrading to that version should resolve the issue.

tsg-l commented 3 years ago

I'm running 22.0.0.16.

zhyatt commented 3 years ago

Are you running the latest version of nano-prom?

tsg-l commented 3 years ago

Just did the pip install last week and I'm not showing any upgrades available so I believe it is current.

zhyatt commented 3 years ago

@argakiig Do you know what the cause might be?

argakiig commented 3 years ago

it likely has to do with the rpchost being ipv6 vs hostname or ipv4, can you try either 127.0.0.1 or localhost or ensure you have rpc listening on the expected port, also --data-path should reference the datapath of the running process, if your running a docker node, you will need to use the container path, if running natively use host path. another note do you have a push gateway setup and listening on localhost:9091?

argakiig commented 3 years ago

Basically though the error is due to the response from rpc not being json as expected, which if host or port were incorrect would appear as such

tsg-l commented 3 years ago

I've tried both 127.0.0.1 and localhost and neither worked. I've assumed that the datapath would reference the location of the ldb data file (now the rockdb database). If it's supposed to be referencing the running process where would that be located in the container?

/var/lib/docker/overlay2/c251d569f10346f8b4fe58c0c44559a49af03c7fe68d6186992e809d95bd64c2/diff/usr/bin/nano_rpc /var/lib/docker/overlay2/9e8135b54542ffd0e244e2e975780c674b46109ef970f07331c4090852afe304/diff/usr/share/nano /var/lib/docker/overlay2/9b672721925bad78d2d8390cc1b655bc76bf40035e31f7b58e35cf4e1c43ad72/diff/usr/bin/api/flatbuffers/nanoapi.fbs /var/lib/docker/overlay2/6b73ecd644b61ad7411a61696fd54c48386f86becc684f6bfd80f5843ea8efb3/diff/usr/bin/nano_node /var/lib/docker/overlay2/45e45f74bb72556f63fe88ce10bc40595f1d4c91fdbb206afe6f523278ff1de2/diff/usr/bin/nano_pow_server /var/lib/docker/overlay2/0e3d5b71acd1b1a81f0b064a551e29418480c94bac56ad2f51e04507c6cdca0a/diff/etc/nano-network /var/lib/docker/overlay2/2099e66e47114be33ed9181c4245b8213d9ba62bcaa67e49c9792bdc9ee88768/merged/etc/nano-network /var/lib/docker/overlay2/2099e66e47114be33ed9181c4245b8213d9ba62bcaa67e49c9792bdc9ee88768/merged/usr/share/nano /var/lib/docker/overlay2/2099e66e47114be33ed9181c4245b8213d9ba62bcaa67e49c9792bdc9ee88768/merged/usr/bin/api/flatbuffers/nanoapi.fbs /var/lib/docker/overlay2/2099e66e47114be33ed9181c4245b8213d9ba62bcaa67e49c9792bdc9ee88768/merged/usr/bin/nano_pow_server /var/lib/docker/overlay2/2099e66e47114be33ed9181c4245b8213d9ba62bcaa67e49c9792bdc9ee88768/merged/usr/bin/nano_rpc /var/lib/docker/overlay2/2099e66e47114be33ed9181c4245b8213d9ba62bcaa67e49c9792bdc9ee88768/merged/usr/bin/nano_node /var/lib/docker/overlay2/2099e66e47114be33ed9181c4245b8213d9ba62bcaa67e49c9792bdc9ee88768/merged/home/nanocurrency /var/lib/docker/overlay2/fe32e96b19d26ec8f1ad1fd861bdb116175b49fe1a31efec6dae4e7ea3fee9fc/diff/home/nanocurrency

nbeard49 commented 2 years ago

I had the same issue with the KeyError exception being thrown and the fix was to pass the correct datapath value based on my docker setup. You can either grab this from the docker-compose file where the volume is defined or check the volume bind from the running docker container with the following command:

docker inspect | grep -A1 'Binds'

tsg-l commented 2 years ago

Inspect on the docker looking for the 'Binds' variable is returning "/NanoBeta:/root", but I'm still getting the error utilizing that datapath.

nbeard49 commented 2 years ago

OK - if the datapath is correct then I would assume an issue with RPC communication to the node. You can run a manual curl command to check directly on your node:

curl -d '{ "action": "active_difficulty" }' localhost:55000

That should return something like the following if communication is working:

{
    "deprecated": "1",
    "network_minimum": "fffff00000000000",
    "network_receive_minimum": "ffffe00000000000",
    "network_current": "fffff00000000000",
    "network_receive_current": "ffffe00000000000",
    "multiplier": "1"
}

If the call fails then please verify your RPC configs in the config-rpc.toml file and make sure that you have the 'enable_control' variable set to 'true'. If all else fails you'll need to check your docker configuration to make sure that you've got the beta RPC port mapped correct to the host OS. The following example is from my docker-compose file that is working:

    ports:
     - "54000:54000"       #tcp network traffic
     - "127.0.0.1:55000:55000" #rpc to localhost only
     - "127.0.0.1:57000:57000" #websocket to localhost only