oetiker/SmokePing

Configuring InfluxDB in SmokePing

Closed this issue · 7 comments

Hello.

I am looking to get SmokePing to push collected metrics into influxDB. I see there is functionality implemented to handle this, however it isn't clear how to configure SmokePing to connect to a running influxDB instance.

It isn't immediately clear where I need to configure influxDB in the already implemented functionality of this repo. I read through issue #201 and tried to extract value from this comment by asserting I should configure influxDB in the Targets file. This did not work. Smokeping pod logs don't show any attempt or result of a connection to influxDB, and influxDB logs show no connection attempts.

I tried using this comment's forked image, which yielded the same behavior.

  1. how/where do I configure influxDB in SmokePing?
  2. influxDB dependencies are commented out in this repo. They are listed as conditionally imported. I'm no perl dev but how does that work?

It looks like most of what's needed for this to work is in place. There is a popular dockerized version of this repo here. I'd prefer to keep using it than roll my own image off a forked version of this repo since building SmokePing isn't the most straightforward process and it has already been done. I'm more than happy to help push this along and open any necessary PRs. I'd like to

  • configure influxDB connection info
  • see smokeping connect to influxDB
  • see influxDB yield new data as smokeping yields new data and pushes to influxDB
  • experience joy

+1
If I add in the Database

*** InfluxDB ***

host = smokeping_db
database = smokeping
timeout = 10
port = 8086

i get an error:

Software error:
ERROR: Could not import InfluxDB modules, but InfluxDB host was configured: Can't locate InfluxDB/HTTP.pm in @INC (you may need to install the InfluxDB::HTTP module) (@INC contains: .. /usr/share/smokeping /usr/local/lib/perl5/site_perl /usr/local/share/perl5/site_perl /usr/lib/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib/perl5/core_perl /usr/share/perl5/core_perl) at /usr/share/smokeping/Smokeping.pm line 4169.

For help, please send mail to the webmaster ([you@example.com](mailto:you@example.com)), giving this error message and the time and date of the error.

I installed, it seems to me, all the necessary packages and perl modules:

apk add perl perl-dev perl-app-cpanminus build-base apkbuild-cpan 
cpanm InfluxDB::HTTP InfluxDB::LineProtocol Object::Result JSON::MaybeXS module

And now the smokeping works but doesn't pass any data to influexdb

I think the problem was that I used influxdb version 2. With version 1.7 everything worked.

I added to file Database in config directory of container smokeping:

*** InfluxDB ***

host = 192.168.21.131
database = smokeping
timeout = 10
port = 8086

I have installed the packages in a smokeping docker container:

apk add perl perl-dev perl-app-cpanminus build-base apkbuild-cpan 
cpanm InfluxDB::HTTP InfluxDB::LineProtocol Object::Result JSON::MaybeXS module

And created a container with influxdb. Run in a influxdb docker container:

influxdb
create database smokeping;
exit
exit

restart containers and thats all what you need.

jku209 commented

Today, I noticed that 2.x URL doesn't include parameter like the Bucket and the Org which is now mandatory. I also don't have the option to add authentication token

What smokeping is sending captured via wireshark:

POST /write?db=smokeping&precision=ms HTTP/1.1
TE: deflate,gzip;q=0.3
Connection: TE, close
Host: 192.168.3.92:8086
User-Agent: InfluxDB-HTTP/0.04
Content-Length: 286
Content-Type: application/x-www-form-urlencoded

What I should be using:

POST /api/v2/write?org=inettelescope&bucket=smokeping&precision=ms HTTP/1.1
Authorization: Token 9lkwg_6LAgoXkC2z1Y1pkWPUSKWqX3TvPR9GTULPdX_qmfE-5SrOUU9V_SOkthm1X-KKP6vOiTDgTL0iYTiixg==
Content-Type: application/json
User-Agent: PostmanRuntime/7.32.2
Accept: /
Postman-Token: 933f995f-c6eb-4c16-8863-c8a5b54bf6e6
Host: 192.168.3.92:8086
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Content-Length: 1774

This issue has become stale and will be closed automatically within 7 days. Comment on the issue to keep it alive.

Same here: Write to influxdb 2.x with client v1 url

Use of uninitialized value $error in concatenation (.) or string at /usr/local/share/perl5/site_perl/InfluxDB/HTTP.pm line 165. Error inserting measurement into influxdb: Error executing write: for $VAR1 = [ 'FPing,host=jupiterbroadcasting.com,loss=2,loss_percent=10,path=/InternetSites/JupiterBroadcasting,slave=master,title=JupiterBroadcasting loss=2i,loss_percent=10i,max=1.970000e-02,median=1.530000e-02,min=7.820000e-03,ping10=1.520000e-02,ping11=1.530000e-02,ping12=1.710000e-02,ping13=1.780000e-02,ping14=1.880000e-02,ping15=1.910000e-02,ping16=1.930000e-02,ping17=1.940000e-02,ping18=1.940000e-02,ping19=1.970000e-02,ping2=7.820000e-03,ping3=8.010000e-03,ping4=1.010000e-02,ping5=1.100000e-02,ping6=1.100000e-02,ping7=1.170000e-02,ping8=1.250000e-02,ping9=1.480000e-02 1708879653000' ]; Use of uninitialized value $error in concatenation (.) or string at /usr/local/share/perl5/site_perl/InfluxDB/HTTP.pm line 165. Error inserting measurement into influxdb: Error executing write: for $VAR1 = [ 'FPing,host=linuxserver.io,loss=0,loss_percent=0,path=/InternetSites/linuxserverio,slave=master,title=linuxserver.io loss=0i,loss_percent=0i,max=2.970000e-02,median=2.350000e-02,min=2.320000e-02,ping1=2.320000e-02,ping10=2.350000e-02,ping11=2.350000e-02,ping12=2.350000e-02,ping13=2.360000e-02,ping14=2.360000e-02,ping15=2.360000e-02,ping16=2.370000e-02,ping17=2.370000e-02,ping18=2.390000e-02,ping19=2.390000e-02,ping2=2.330000e-02,ping20=2.970000e-02,ping3=2.340000e-02,ping4=2.340000e-02,ping5=2.340000e-02,ping6=2.350000e-02,ping7=2.350000e-02,ping8=2.350000e-02,ping9=2.350000e-02 1708879653000' ]; Use of uninitialized value $error in concatenation (.) or string at /usr/local/share/perl5/site_perl/InfluxDB/HTTP.pm line 165. Error inserting measurement into influxdb: Error executing write: for $VAR1 = [ 'FPing,host=8.8.8.8,loss=0,loss_percent=0,path=/DNS/GoogleDNS1,slave=master,title=Google\\ DNS\\ 8.8.8.8 loss=0i,loss_percent=0i,max=2.870000e-03,median=2.680000e-03,min=2.400000e-03,ping1=2.400000e-03,ping10=2.680000e-03,ping11=2.680000e-03,ping12=2.680000e-03,ping13=2.680000e-03,ping14=2.680000e-03,ping15=2.690000e-03,ping16=2.720000e-03,ping17=2.730000e-03,ping18=2.740000e-03,ping19=2.790000e-03,ping2=2.410000e-03,ping20=2.870000e-03,ping3=2.450000e-03,ping4=2.530000e-03,ping5=2.590000e-03,ping6=2.600000e-03,ping7=2.630000e-03,ping8=2.640000e-03,ping9=2.650000e-03 1708879653000' ]; Use of uninitialized value $error in concatenation (.) or string at /usr/local/share/perl5/site_perl/InfluxDB/HTTP.pm line 165. Error inserting measurement into influxdb: Error executing write: for $VAR1 = [ 'FPing,host=4.2.2.2,loss=0,loss_percent=0,path=/DNS/L3-2,slave=master,title=Level3\\ DNS\\ 4.2.2.2 loss=0i,loss_percent=0i,max=1.180000e-02,median=1.140000e-02,min=1.110000e-02,ping1=1.110000e-02,ping10=1.140000e-02,ping11=1.140000e-02,ping12=1.140000e-02,ping13=1.140000e-02,ping14=1.150000e-02,ping15=1.150000e-02,ping16=1.150000e-02,ping17=1.150000e-02,ping18=1.160000e-02,ping19=1.160000e-02,ping2=1.120000e-02,ping20=1.180000e-02,ping3=1.130000e-02,ping4=1.130000e-02,ping5=1.130000e-02,ping6=1.130000e-02,ping7=1.140000e-02,ping8=1.140000e-02,ping9=1.140000e-02 1708879653000' ]; Use of uninitialized value $error in concatenation (.) or string at /usr/local/share/perl5/site_perl/InfluxDB/HTTP.pm line 165. Error inserting measurement into influxdb: Error executing write: for $VAR1 = [ 'FPing,host=4.2.2.1,loss=0,loss_percent=0,path=/DNS/L3-1,slave=master,title=Level3\\ DNS\\ 4.2.2.1 loss=0i,loss_percent=0i,max=1.830000e-02,median=1.140000e-02,min=1.100000e-02,ping1=1.100000e-02,ping10=1.130000e-02,ping11=1.140000e-02,ping12=1.140000e-02,ping13=1.140000e-02,ping14=1.140000e-02,ping15=1.150000e-02,ping16=1.150000e-02,ping17=1.150000e-02,ping18=1.160000e-02,ping19=1.230000e-02,ping2=1.110000e-02,ping20=1.830000e-02,ping3=1.110000e-02,ping4=1.110000e-02,ping5=1.110000e-02,ping6=1.120000e-02,ping7=1.120000e-02,ping8=1.130000e-02,ping9=1.130000e-02 1708879653000' ];
Has anybody found a solution?

I have tested it wit curl: from command line from windows (don't know if it works this way ....)
curl --request POST http://192.168.0.39:8072/write?db=smokeping --user "infping3:xyz" --data-binary "FPing,host=linuxserver.io,loss=0,loss_percent=0,path=/InternetSites/linuxserverio,slave=master,title=linuxserver.io loss=0i,loss_percent=0i,max=2.970000e-02,median=2.350000e-02,min=2.320000e-02,ping1=2.320000e-02,ping10=2.350000e-02,ping11=2.350000e-02,ping12=2.350000e-02,ping13=2.360000e-02,ping14=2.360000e-02,ping15=2.360000e-02,ping16=2.370000e-02,ping17=2.370000e-02,ping18=2.390000e-02,ping19=2.390000e-02,ping2=2.330000e-02,ping20=2.970000e-02,ping3=2.340000e-02,ping4=2.340000e-02,ping5=2.340000e-02,ping6=2.350000e-02,ping7=2.350000e-02,ping8=2.350000e-02,ping9=2.350000e-02 1708879653000"

but it works ...

@jku209 : have you found a solution?