gsxryan / storj_telegraf_mon

StorJ V3 Node Health and Success Rates output | to custom Grafana Dashboard for continuous monitoring and alerts | using telegraf inputs.exec [TIG stack]
26 stars 6 forks source link

./tokens.sh not working with telegraf [UnRAID users] #26

Open dalekseevs opened 4 years ago

dalekseevs commented 4 years ago

Hi :)

I am having an issue with tokenes.sh.

When I run: telegraf --debug --config /etc/telegraf/telegraf.conf --input-filter exec --test I get: D! [inputs.exec] Error in plugin: metric parse error: expected tag at 1:7: "Error, Etherscan API returned: "

However when I run ./tokens.sh through terminal I get the correct response: e.g. StorJToken,stat=tokens,WalletAddress="0xXXXXXXXXXXXXXXXXXXXXXXXXX" BalanceSTORJ=10,BalanceUSD=1,BalanceEUR=1 1 StorJToken,stat=prices STORJPriceUSD=0.1221,STORJPriceEUR=0.1109 1

Also if I just run the query in browser I get the correct response with 'OK'

The other two plugins work as expected.

Am I missing something very obvious?

Thanks in advance guys, and thanks for doing this awesome work!

JeromeGillard commented 4 years ago

It seems that your token.sh is not edited. (if output really says: WalletAddress="0xXXXXXXXXXXXXXXXXXXXXXXXXX" )

Please follow the README of this repo:

In order to track your wallet balance, please create an Eterscan account and API token. Edit tokens.sh with your wallet address and your Etherscan API token.

dalekseevs commented 4 years ago

I did edit it :) I just edited out my address here. As I mentioned the API string works fine in browser and the output from the tokens.sh that is triggered from terminal is as expected.

JeromeGillard commented 4 years ago

Could you try to run it within the Telegraf container? Refer to the volume argument when running Telegraf -v "$PWD/scripts:/scripts". The script should be then located at /scripts/token.sh within the container. With standard config you should be able to:

jgi@K3:~/docker_apps/telegraf$ docker exec -i -t telegraf /bin/bash
root@K3:/# /scripts/tokens.sh
StorJToken,stat=tokens,WalletAddress="0xD71dE91105667aD9862eaddfb65CE9df3e7593a2" BalanceSTORJ=241.202,BalanceUSD=29.8608,BalanceEUR=27.1352 1574764557041666505
StorJToken,stat=prices STORJPriceUSD=0.1238,STORJPriceEUR=0.1125 1574764557042857451

The script uses curl. Could you see if this works within your Telegraf container:

curl -s 'https://api.etherscan.io/'

This should return the HTML code of their home page.

Another thing to double check: the output should come into two lines, beginning by StorJToken.

dalekseevs commented 4 years ago

Yep, its a curl issue... I don't have curl in my container. I am running under UnRaid, and docker compose is not so straightforward under this system, although I think I will try it out. Thank you for the prompt response:) I can remove the tokens.sh plugin from telegraf.conf and still run it, correct?

JeromeGillard commented 4 years ago

Sure, you can comment out the whole [[input.exec]] block dedicated to tokens in the telegraf.conf file. The dashboard will lack data but ill be still working.

JeromeGillard commented 4 years ago

Could your give a try to this fix? https://raw.githubusercontent.com/JeromeGillard/storj_telegraf_mon/avoid_curl/tokens.sh I've found a StackOverflow topic that talks about a way of doing curl, without curl...

(Do not forget to overwrite your wallet address and API key, or put them in a seperate tokens.sh.secrets)

dalekseevs commented 4 years ago

Oh cool, will try it out!

dalekseevs commented 4 years ago

Still cannot get it to run, still the curl error.

grep: unrecognized option: P
BusyBox v1.29.3 (2019-01-24 07:45:07 UTC) multi-call binary.

Usage: grep [-HhnlLoqvsriwFE] [-m N] [-A/B/C N] PATTERN/-e PATTERN.../-f FILE [FILE]...

Search for PATTERN in FILEs (or stdin)

        -H      Add 'filename:' prefix
        -h      Do not add 'filename:' prefix
        -n      Add 'line_no:' prefix
        -l      Show only names of files that match
        -L      Show only names of files that don't match
        -c      Show only count of matching lines
        -o      Show only the matching part of line
        -q      Quiet. Return 0 if PATTERN is found, 1 otherwise
        -v      Select non-matching lines
        -s      Suppress open and read errors
        -r      Recurse
        -i      Ignore case
        -w      Match whole words only
        -x      Match whole lines only
        -F      PATTERN is a literal (not regexp)
        -E      PATTERN is an extended regexp
        -m N    Match up to N times per file
        -A N    Print N lines of trailing context
        -B N    Print N lines of leading context
        -C N    Same as '-A N -B N'
        -e PTRN Pattern to match
        -f FILE Read pattern from file
/scripts/tokens.sh: line 56: curl: command not found
Error, Cryptocompare API returned: 
gsxryan commented 4 years ago

You'll have to find a way to get CURL to work on the unraid host (busybox). An alternative would be to get the docker-compose.yml working, so you can use telegraf within another container on your UnRAID. This setup is close on the github, but it's not quite ready for prime time yet.

0x1CED commented 4 years ago

In unraid, change the repository from telegraf:alpine to telegraf:latest. Fixed the issues I was having.