-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add basic auth support to InfluxDB connection #1
Conversation
I'm going to wait for you to try it first. I'm not 100% sure it will work. You're setting authentication for LWP, but InfluxDB::HTTP doesn't necessarily inherit the same parameters. |
@mad-ady InfluxDB::HTTP reuses the same LWP::UA object for it's connection, so pulling that out and setting the authentication details with the credentials method works fine. I've tested it now and I have measurements in my smokeping Influx database :) |
This reverts commit 4c379f7.
@mad-ady You may want to do a squash commit when you merge: I accidentally included a commit where my Vim setup did a bunch of clean ups on the file. I've reversed that, but the commit history is a little ugly. |
Thank you for your contribution |
@mad-ady I've also sent you a couple of pull requests for the docker image... One that speeds it up a lot, and another that makes it a bit more user friendly. |
@rloomans: add basic auth support to influx db connection
* Add debugging to see how configuration gets parsed * Add configuration parsing support for InfluxDB section * Load InfluxDB modules if the config demands it * Add support for writing to influxdb, if configured * Ignore debugging logs * Add missing variable declaration * Add missing commits * Forgot to add the influxdb initialization code * Add slave name as a Influx tag. Log influx insert errors * Send to influxdb probe parameters prefixed with influx_, as tags * Load InfluxDB modules unconditionally * Refactor foreach -> for Co-Authored-By: Tobias Oetiker <[email protected]> * Whitespace and or changes Co-Authored-By: Tobias Oetiker <[email protected]> * Whitespace Co-Authored-By: Tobias Oetiker <[email protected]> * Whitespace Co-Authored-By: Tobias Oetiker <[email protected]> * Whitespace Co-Authored-By: Tobias Oetiker <[email protected]> * Cosmetic changes Co-Authored-By: Tobias Oetiker <[email protected]> * Cosmetic changes Co-Authored-By: Tobias Oetiker <[email protected]> * Count from zero Co-Authored-By: Tobias Oetiker <[email protected]> * Adjust index since counting from zero Co-Authored-By: Tobias Oetiker <[email protected]> * Adjust index since counting from zero Co-Authored-By: Tobias Oetiker <[email protected]> * Adjust index since counting from zero Co-Authored-By: Tobias Oetiker <[email protected]> * Adjust index since counting from zero Co-Authored-By: Tobias Oetiker <[email protected]> * Whitespace Co-Authored-By: Tobias Oetiker <[email protected]> * Cosmetic changes Co-Authored-By: Tobias Oetiker <[email protected]> * Whitespace Co-Authored-By: Tobias Oetiker <[email protected]> * Cosmetic changes Co-Authored-By: Tobias Oetiker <[email protected]> * Refactor foreach -> for Co-Authored-By: Tobias Oetiker <[email protected]> * Add support for generic influxdb tags * Add more debugging for failed inserts, fix function definition * Tag the master when exporting to InfluxDB * Add basic auth support to InfluxDB connection (mad-ady#1) @rloomans: add basic auth support to influx db connection * Send the timestamp received from the slave instead of the current time (to support playback of slave cached data) * Remove generic tags and allow any names for tags Co-authored-by: Tobias Oetiker <[email protected]> Co-authored-by: Robert Loomans <[email protected]>
Update CHANGES
I'm not sure this still works, or perhaps it was initially designed for Influx 1, which doesn't work with influx 2. As I'm not a developer by any means, I've been hacking the code with the help of ChatGPT and I think I got it working with Authorized keys, but really not sure. Wanted to pass along the code, if you wanted to take a look and submit a MR if correct. /opt/smokeping/lib/InfluxDB/HTTP.pm Remove this line: my $response = $self->{lwp_user_agent}->post($uri->canonical(), Content => $measurement); And add: my $token = 'YourInfluxDBTokenHere'; # Replace with your actual InfluxDB token my $response = $self->{lwp_user_agent}->post( |
Sorry, I haven't been following this repo. Yes, I was using an older influxdb version. Didn't know it changed. My suggestion is to push this change upstream (to Influxdb::HTTP maintainer), because I'm no longer involved in Smokeping development. |
In theory, this is all that's needed to add Basic Auth support for the InfluxDB connections, but I won't get a chance to test it until tomorrow.