InfluxDB Logger Support

I added a second instance of the app to use advanced attribute selection for hub info. At first, I selected 3 attributes for temp including C and F. Then I started seeing this in the logs:

So I went back in and changed that attributes to only be:
image
but I still get the warn log entries. How do I clear that?

The warning comes from the value of this custom event, which is a string that contains an unescaped space character between the numerical value and the unit. I think it's there mostly to make the creation of html tile templates more straightforward.

Hmm strange. Maybe double-check your attribute selection (in both instances?) and make sure you hit "Done".

It's driver brokenness. The strings "temperatureC" and "temperatureF" are not valid Hubitat event types. The correct event type would be "temperature", along with unit="°F" or unit="°C".

[Edit: never mind, I see what driver it is]

@JamesTX10

Strike that. My bad. Apologies to everyone, particularly @thebearmay.

I looked at the Hub Information driver, and it is absolutely not broken. I should have looked at it before posting. As noted by @hubitrep, the attributes "temperatureF" and "temperatureC" are formatted for browser presentation and should not be used for InfluxDB loggering. There is a standard temperature attribute which has the value and unit in separate fields as expected.

Remove attributes "temperatureF" and "temperatureC" from InfluxDB-logger, and use attribute "temperature" instead. Alternatively, you can just turn off individual attribute selection and select Hub Information in the Temperature Sensors section. You probably want to delete or convert your prior records for "temperatureF" and "temperatureC" as Grafana is not going to deal with these particularly well.

Sorry I mislead you earlier!

3 Likes

Vision 2.5 has just been pushed. Changes of interest are:

  • Fix button and thermostat fan mode event handling
  • Fix threeAxis event encoding
  • Add device event handling for filters, gas detectors, power source
  • Move unnecessary info messages to debug
  • Disable debug logging of post data which drives hubs into the ground
  • Provide info logging of event data to replace post data logging
  • Allow backlog to be set as low as 1, allowing bad records to be cleared

The last bullet is particularly useful if you should find yourself with bad data in your queue like this. If you end up with bad data in your queue, you can use the following steps to clear it:

  1. Go into the configuration for InfluxDB Logger and remove whatever device and/or attibute is creating the bad data from the Devices To Monitor list.
  2. Set both the "Batch size limit" and "Backlog size limit" to 1.
  3. Save the configuration.
  4. Let the queue process. Depending upon the size of the backlog, this may take a while. Expect to see a bunch of warnings and errors in the log--a warning on every post about the amount of data remaining in the backlog, and an error for every piece of bad data in the backlog.
  5. Once the backlog has been processed and the errors have stopped (the warnings will continue), go back into the configuration and change the "Batch size limit" and "Backlog size limit" back to normal values and save the configuration.

InfluxDB on Synology with HE - Step By Step:

[details="InfluxDB Steps"] UPDATE _ Docker changed to Container Manager Instructions are different as of 10/10/23 **

Access your NAS web screen usually http://{NASName}:5000 or http://xxx.xxx.xxx.xxx:5000
I have to assume you've already created a pool/shared folder for Docker - mine is simply called 'docker'.
Open File Station
Select the storage location you've setup - in my case its SynologyNAS1 'docker'
Select Create folder from the Create dropdown
Enter a folder name - I put a name 'influxdb'. I suggest all lower case - unix case sensitivity etc.
Right click the folder, select Properties and change owner to 'admin' if needed. Also check the 'apply to sub-folders'. Save
Close File Station
Back on main screen select 'Docker'
On left menu select Registry.
on right side, enter 'influxdb' in search and hit enter.
Hilight The influxdb option at the top with the largest quantity of rating stars. This is the latest open source.
Select Download above it.
When prompted for Tag choose 'latest' - then 'Select'.
On the left menu, select Image. You should see the influxdb - if the Disk icon next to its name is changing - it is still downloading. wait for it to complete.
Highlight influxdb:latest and click 'Launch'
The first prompt is networks - select 'same as docker host then Next
Change the Container name to 'influxdb'.
click 'Enable auto-restart'. Then Next. do not be tempted to click the web portal via web station! Click Next
Click 'Add Folder'. In the popup - drill to your folder name created above mine was 'SynologyNAS1 : docker : influxdb' highlight it and click 'Select'.
Enter a mount path - use ' /var/lib/influxdb ' and click 'Next'.
Review and click 'Done'.
On the left menu - select Container - influxdb should say 'running'.
Close Docker

From your browser, access InfluxDB portal - http://{NASName}:8086 or http://xxx.xxx.xxx.xxx:8086
Click 'Getting Started'
on Setup Initial User - put admin (lower case) then a password - remember this info!
confirm the password, and add an Initial Org Name - I put my city. I use an uppercase first later as it is a proper name.
For Initial Bucket Name I put Hubitat. Like City - it is a name, so first character is Uppercase. Click Continue
Select 'Advanced'.
On the Load Data screen - select API Tokens at the top
Select Generate API Token button on the right
Choose All Access API Token
Give the Token a description - I use 'TOKEN_FOR_HE' - COPY THE TOKEN CREATED and save it to a text file or something!

Open your hubitat webpage
On the left - select Apps
On the right - select Hubitat Package Manager
Click Install
Select Search By Keywords
Enter 'Influxdb' for search criteria then select 'Next'.
I get TWO identical responses - I cannot see a difference but I take the second one.
the Install from Repository screen appears - click Next and Next again.
Shortly, the app should be installed - click Next then Done at the bottom to leave HPM app.
At the top of the Hubitat window you've returned to - select 'Add User App'.
Scroll popup to find InfluxDB Logger. Shortly, you should be IN the setup of InfluxDB Logger app
Leave all values alone for now - but select 'InfluxDB Connection' button.
Enter Host* as IP address for the SynologyNAS. Hostname {NASName} requires a DNS entry and HE is bad at DNS names(no host.etc file).
I set log to 'error' initially, then to Info after I verify it works.
Leave the port at 8086
Change Influx Version from 1.x to 2.x
For Org put what you entered in the Influxdb page - remember I had suggested your city.
For Bucket enter 'Hubitat'.
For Authorization Type select Token. Put the Token we created previously and saved - here. Click done
Back on the app main setup page -
Click 'Advanced Attribute selection' - its easier to see your devices.
Pick ONE easy thing to test with.
I selected a Humidity Sensor.
Pick an attribute or two - I chose temperatre, battery, and humidity.
Open Logs - and look for 'InfluxDB Logger: Updated' and 'InfluxDB URI: http://xxx.xxx.xxx.xxx:8086/api/v2/write?org={cityname}&bucket=Hubitat
It could take a few minutes - depending on what your update value in the logger was set to.

Open the InfluxDB webpage. If you had it open from before, be SURE to refresh it!
After logging into Influxdb page, select the 'graph' icon - called Data Explorer from the Left menu
On the right, look for the query1 and below that you should see 'Hubitat' and 2 other buckets that Influx makes automatically.
Select Hubitat.
To the right, a new popup of 'Filter' appears. It should show you the attributes you had previously selected on the HE Influx DB Logger app.
Check mark one of them and over to the left select 'Submit'.
Viola! You should see the beginnings of a graph from the incoming data. Have fun.

[/details]
Grafana step by step - includes anonymous access, and add to web tile!

Grafana steps

Access nas web screen usually http://{NASName}:5000 or http://xxx.xxx.xxx.xxx:5000
I have to assume you've already created a pool/shared folder for Docker - mine is simply called 'docker'.
Open File Station
Select the storage location you've setup - in my case its SynologyNAS1 'docker'
Select Create folder from the Create dropdown
Enter a folder name - I put a name 'grafana'. I suggest all lower case - unix case sensitivity etc.
Right click the folder, select properties and change owner to 'admin' if needed. also check the 'apply to sub-folders'. Save
Close File Station
Back on main screen select 'Docker'
On left menu select Registry.
on right side, enter 'grafana' in search and hit enter.
Hilight The grafana option at the top with the largest quantity of rating stars. This is the latest open source.
Select Download above it.
When prompted for Tag choose 'latest' - then 'Select'.
On the left menu, select Image. You should see the grafana/grafana - if the Disk icon next to its name is changing - it is still downloading. wait for it to complete. (the grafana/grafana:latest - I can't explain the redundancy but that is what you get)
Highlight grafana/grafana:latest and click 'Launch'
The first prompt is networks - select 'use the selected networks' and 'bridge' should be checked. then Next
Change the Container name to 'grafana'.
click 'Enable auto-restart'. Then Next. do not be tempted to click the web portal via web station!
Click the Advanced Settings button.
Under Environment, click Add
under variables column - in the blank put ' GF_AUTH_ANONYMOUS_ENABLED '. Under value put ' true ', and click Save.
Click Next.
On Port Settings screen enter 3000 under local port, then Next
Click 'Add Folder'. In the popup - drill to your folder name created above mine was 'SynologyNAS1 : docker : grafana' highlight it and click 'Select'.
Enter a mount path - use ' /var/lib/grafana ' and click 'Next'.
Review and uncheck 'Run the container after wizard finishes'. Click Done.
I'm on a windows machine - so I'll use a cmd window to run ssh. I open a cmd window and issue the following text commands:
ssh {NASIPAddr} -p22
The result will be a prompt for a password (look at the prompt for what user account it defaulted too) and enter the correct PW.
enter "sudo -i"
then "cd /volume1/docker" (or whatever volume/folder you're using) and enter
then "sudo chown 472 grafana" and enter
close your cmd window
Back on the NAS webpage, in Docker - go to 'Container' on the left.
Select the grafana on the right and change the toggle switch at the far right to 'on' (blue).

On the left menu - select Container - grafana should say 'running'.
choose Overview on the left, you should see grafana, and influxdb (and I also have Echo speaks from some other work!)
Close Docker

Access grafana on the NAS web screen usually http://{NASName}:3000 or http://xxx.xxx.xxx.xxx:3000
Since this is the first time, we have to put the default user/password, which is 'admin / admin'.
The next screen is to change the password - make note! - you should now see the Welcome screen.

To hook influxdb is next.
Go to your influxdb web page usually http://{NASName}:8086 or http://xxx.xxx.xxx.xxx:8086
On the left menu select the Load Data, and select 'API Tokens'.
On the right, select Generate API Token.
Select All Access API Token in the drop down - IMPORTANT. you only get to see this once! copy it somewhere!
For description I put 'TOKEN_FOR_GRAFANA' and click save.
COPY THIS STRING AND SAVE IT!

Access grafana on the NAS again usually http://{NASName}:3000 or http://xxx.xxx.xxx.xxx:3000
Select the Add Data Sources box near the middle of the screen.
Find 'InfluxDB' and select it.
The Data Sources/Influxdb opens: No need to change the name unless you want/need to.
For Query language, select Flux
For HTTP / URL put "http://xxx.xxx.xxx.xxx:8086" (Docker / DNS is easier to workaround by just using IP address)
Change all Auth options to OFF.
Under InfluxDB Details enter the you used with your Influxdb install organization. From the influx instructions before, I suggested city name, Capitlaized.
Get that copied token you made for grafana now and paste it in the Token field.
Now enter Hubitat or whatever you called the bucket from the Influxdb.
Click save and test.
If all has gone well - you get a green check mark and 'datasource is working. 3 buckets found' message.

Let's not stop! Let's get a dashboard showing data.
Click the top left Grafana icon, and return to the home page.
Select Dashboards - create your first ..'
Select Add a new panel
Flip back to your InfluxDB web page, and on the left select 'data explorer'
Select Hubitat (or whatever you called your bucket) and it should pop a 'filter' to the right, which shows your attributes you are logging.
Select one for now.
Click Submit on the right, middle of screen. You should see a basic graph.
Good so far? I hope. Next to Submit is 'Script Editor'. click that and you see a text version of your graph query. Copy this text.
Back now to grafana web page.
Paste the query string onto line 1 of your query and press enter.
Do you get a Graph? Save it by pushing the save file icon at the top right.

Lets test output on a tile - I use Hubitat Dashboard for Android which allows me to add a web tile and I just enter a URL.
Click the Share icon above your panel. I don't lock time range. Copy the Link URL into your dashboard tile.
et Viola!

2 Likes

Caveat: I've been using Influx v1.8 for several years and I'm having a hard time migrating my brain to v2.x.

My 1.8 instance runs natively on Arch Linux. The 2.6.1 instance I'm playing with is in Docker on the same hardware. I changed the config.yml line to "http-bind-address: :9086" to allow them in parallel.

I'm running version
image
of the logger on
image
with this config

It connects to my v2 instance just fine but the payload is not getting into the database due to a "204 No Content" error (token intentionally left out)
image

Here is the HE log of the transaction

Am I the bug here?

A response code of 204 from Influx DB is a success response. Where is that output coming from?

No errors are showing in that HE Log output. I suspect that the "No Content" message is that there is no body in the response.

So then the question is why is the data not showing up. If you go into the InfluxDB 2.x gui and pull the information from the "_monitoring" bucket to see what is shown.

I guess you're asking about the network traffic capture in Wireshark?

Neither of the battery or motion measurements are present in the list when I add a cell to a dashboard in the InfluxDB GUI
image

So it appears to me that the write didn't happen. :man_shrugging:

I'd like to query the database in a terminal to see what is actually there but I haven't figured out how to do that withe v2x yet. It's a piece of cake with v1.8.

Unfortunately, I don't think any of the data you provided points to a problem. It looks like for some reason InfluxDB 2.x isn't importing the data for some reason, but responding with a success to the HE. The No Content message is just that there is no response data being provided by influx other then the successful response code. I will do some testing with my instance since i am on Influxdb 2.6 myself and see what if i can figure out what is happening.

Is the database used with InfluxDB 2.x migrated data from the 1.x instance, or is it a completely new load?

Yeah, and that's where I'm confused as to what is going on.

:crossed_fingers:

Completely new. I'll worry about migration of v1.8 data after I get all the kinks worked out.

can you try running this older code and see if the problem still happens.

No difference as far as I can see.

I just checked my database and the data is there and i am getting new data so My instance isn't dropping it..

1 Like

Thanks for checking.

EDIT: Now the data is in the database! I wasn't even here to change anything so :man_shrugging:

Sorry for the false alarm.

I'm guessing the "no content" means that the 204 response has nothing to add. Earlier I thought it was Influx saying that the write request had no content. :man_shrugging:

Hi, I was running an older version of the logger (the Jan 12 2023 version), against my Influx database (v2.6.1). I tried upgrading the logger to the current v3, but now I get 422 errors when it tries to post the data to Influx:

Post of 150 events failed - elapsed time 0.068 seconds - Status: 422, Error: Unprocessable Entity, Headers: [X-Influxdb-Build:OSS, X-Platform-Error-Code:unprocessable entity, X-Influxdb-Version:v2.6.1, Content-Length:218, Date:Mon, 13 Mar 2023 00:16:34 GMT, Content-Type:application/json; charset=utf-8], Data: null

I'm not quite sure what this error means, and whether it's on the Hubitat or InfluxDB side... sounds like it might something to do with the formatting of the data being posted to Influx?

For now I switched back to the old version and everything is working again. Figured I'd ask here to see what might have changed in the logger.

Thanks!

Clearly a problem. Can you to set the batch size to a small value like 1 or 10 and then once the error happens again you could go into the app status (gear icon on the app page) and capture the state viable "loggerQueue" variable?

That will give some indication what is happening. Thanks!

Btw, just to clarify: By "Jan 12 2023 version" do you mean "2023-01-12 Denny Page Automatic migration of Influx 1.x settings." is the last modification you see listed in the source file?

'Apologies if this is a silly question but I can't seem to find a way to send hub variables to influxDB from within the community app. Is this indeed not supported or have I overlooked a section in the 'Devices to Monitor' selector somehow? I have a few daily counters (INTs) for appliance cycles that I'd like to trend. Thanks in advance.

:edit: Okay so it seems I have to have checked "Get Access to All Attributes" to see my Variables. However I assume this means that for my previously selected devices I'm forced to send all device attributes, probably trippling my dataset? (for example instead of strictly sending a motion's lux, I'm now sending the motion state, battery life, etc, etc). If this is the case, could we possibly add a 'Variable' sub-section which is available when 'Get Access to All Attributes' is unchecked?

Hi Denny,
Yes, that's the version. I think it was v2.00? It is possible I might have updated to one of the minor versions after that via HPM, but I'd held out a while. So when I upgraded via HPM today, I didn't note what old version I was on. I did save a copy of the 2023-01-12 code locally, so that's what I manually rolled back to.

OK, looks like I have 800+ items built up in LoogerQueue from earlier, based on the timestamps. It just added the new entries to the end. I won't post it here at this time given the length (or maybe I can PM it to you). I'm presuming the issue could likely be in the older/existing queued items that it is trying to re-post. Is there an easy way to clear out the LoggerQueue variable?

I guess the harder approach would be to completely uninstall and reinstall, to clear everything out, then slowly add devices back for logging. Will probably have to wait until next weekend before trying that. Oh, actually maybe I can try and create a new instance of v300 and run it against a new test InfluxDB instance so I can leave the old one running.

Given the error message mentions "Data:null" at the end, I did look through the LoggerQueue and noticed that I have a couple devices where "unit=null", but this includes system variables like sunrise and sunset.

Thanks!
PS forgot to mention, I'm on a C7 hub running 2.3.4.132 right now. But I don't think I'm behind enough to be an issue.