Help newbie with influxdb2

I just got my iotawatt installed and the Graph+ and PVOutput uploader is working but I can’t seem to get the InfluxDB_v2 uploader working.

Admittedly, I’m new to Influx and IotaWatt but hoping for some help.

I’m running InfluxDB v2.7.10 locally on a VM on same subnet as the iotawatt.

When I start the uploader, the influxdb logs show it querying my bucket for the last values:

Oct 27 11:22:34 rocky influxd-systemd-start.sh[477726]: ts=2024-10-27T15:22:34.594658Z lvl=debug msg=Request log_id=0sVbZ68G000 service=http method=POST host=192.168.254.74:8086 path=/api/v2/query query="orgID=161dc560fa1093c3" proto=HTTP/1.1 status_code=200 response_size=2 content_length=600 referrer= remote=192.168.254.119:49805 user_agent=unknown authenticated_id=0ddf9b063a8da000 user_id=0ddc4c2bc343e000 took=17.568ms body="from(bucket: \"iotawatt\")\n  |> range(start: 1730001600, stop: 1730006550)\n  |> filter(fn: (r) =>\n    (r._measurement == \"electric\" and r.device == \"IotaWatt\" and r.input == \"Consumption\" and r._field == \"Watts\") or\n    (r._measurement == \"electric\" and r.device == \"IotaWatt\" and r.input == \"TotalAmps\" and r._field == \"Amps\") or\n    (r._measurement == \"electric\" and r.device == \"IotaWatt\" and r.input == \"TotalPower\" and r._field == \"Volts\"))\n  |> last()\n  |> map(fn: (r) => ({_measurement: r._measurement, _time: (uint(v:r._time)) / uint(v:1000000000)}))\n  |> sort (columns: [\"_time\"], desc: true)\n"

but then the write fails 5 seconds later

Oct 27 11:22:39 rocky influxd-systemd-start.sh[477726]: ts=2024-10-27T15:22:39.730897Z lvl=debug msg=Request log_id=0sVbZ68G000 service=http method=POST host=192.168.254.74:8086 path=/api/v2/write query="bucket=iotawatt&orgID=161dc560fa1093c3&precision=s" proto=HTTP/1.1 status_code=499 response_size=107 content_length=4116 referrer= remote=192.168.254.119:49805 user_agent=unknown authenticated_id=0ddf9b063a8da000 user_id=0ddc4c2bc343e000 took=4106.247ms error="internal error" error_code="internal error"

I verified the org,bucket, and user_id are correct.
Also made sure the token has write permission on the bucket.
Here the relevant config on influxdb server:

[root@rocky influxd-installation]# influx org list
ID                      Name
161dc560fa1093c3        alanmiller

[root@rocky influxd-installation]# influx bucket list |egrep "(^ID)|iotawatt"
ID                      Name                    Retention       Shard group duration    Organization ID         Schema Type
05f6c2772994ca51        iotawatt                8760h0m0s       168h0m0s                161dc560fa1093c3        implicit

[root@rocky influxd-installation]# influx auth  list  |egrep "^(ID|0ddf9b063a8da000)"
ID                      Description                                     Token                                                                           User Name       User ID                 Permissions
0ddf9b063a8da000        iotawatt                                        gNqX4MgN-hUEVnMq4ZvLSy3Rvb3NO34au9Q2KqbrMATVPzQIsWMQQhjo9E5eVODIeQYdKIWCq7bMFU3yDjMJmA==        admin           0ddc4c2bc343e000        [read:orgs/161dc560fa1093c3/buckets/05f6c2772994ca51 write:orgs/161dc560fa1093c3/buckets/05f6c2772994ca51]

Here is my config screen ( I verified the same is present in config.txt)

What does the IoTaWatt status display indicate and can you post the message log?

It shows POST failed -11

Screen Shot 2024-10-27 at 13.44.00 PM

and can you post the message log?

Sure, here’s the log since the last restart:

** Restart **

SD initialized.
10/27/24 15:47:02z Real Time Clock is running. Unix time 1730044022 
10/27/24 15:47:02z Reset reason: Software/System restart
10/27/24 15:47:02z Trace:  29:64, 29:64, 29:65, 29:63, 29:64, 29:64, 29:65, 31:1, 1:6[6], 1:1[6], 1:2, 9:0, 9:0, 8:4, 8:6, 8:8, 1:3, 1:3, 1:1, 1:2[1], 9:0[1], 9:0, 9:1, 8:4, 8:6, 8:8, 9:3, 9:5, 9:9, 1:3, 10:2, 10:3
10/27/24 15:47:02z ESP8266 ID: 14636923, RTC PCF8523 (68)
10/27/24 15:47:02z IoTaWatt 5.0, Firmware version 02_08_03
10/27/24 15:47:02z SPIFFS mounted.
10/27/24 11:47:02 Local time zone: -4:00
10/27/24 11:47:02 device name: IotaWatt
10/27/24 11:47:02 HTTP server started
10/27/24 11:47:02 influxDB_v2: Starting, interval:10, url:http://192.168.254.74:8086
10/27/24 11:47:02 timeSync: service started.
10/27/24 11:47:02 statService: started.
10/27/24 11:47:02 dataLog: service started.
10/27/24 11:47:02 dataLog: Last log entry 10/27/24 11:46:55
10/27/24 11:47:07 historyLog: service started.
10/27/24 11:47:07 historyLog: Last log entry 10/27/24 11:46:00
10/27/24 11:47:08 WiFi connected. SSID=IByte, IP=192.168.254.119, channel=6, RSSI -70db
10/27/24 11:47:08 Updater: service started. Auto-update class is MINOR
10/27/24 11:47:08 influxDB_v2: Resume posting 10/27/24 00:03:40
10/27/24 11:47:10 Updater: Auto-update is current for class MINOR.
10/27/24 11:47:12 PVoutput: started
10/27/24 11:47:14 PVoutput: System iotawatt-alanmiller, interval 5, freeload mode  
10/27/24 11:47:14 PVoutput: Start status beginning 10/27/24 11:45:00

The last update query apparently succeeded as the last update was at 10/27/2024 12:03:30 AM. This snippet of the log was at 11:47:02. I’d like to see the message log covering 12:03:30 AM to see if there is anything that might have happened then ort since then to cause the subsequent writes to fail.

Well I tried multiple times prior to the last restart. Couldnt get anything to work.
Here’s the log entries prior to the ones last posted:

** Restart **

SD initialized.
10/26/24 14:20:42z Real Time Clock is running. Unix time 1729952442 
10/26/24 14:20:42z Reset reason: Software/System restart
10/26/24 14:20:42z Trace:  1:3, 1:3, 1:3, 1:3, 1:3, 1:1, 1:2[1], 9:0[1], 9:0, 9:1, 8:4, 8:6, 8:8, 9:3, 9:5, 9:9, 1:3, 1:3, 1:1[1], 1:2[2], 9:0[2], 9:0, 9:1, 8:4, 8:6, 8:8, 9:3, 9:5, 9:9, 1:3, 10:2, 10:3
10/26/24 14:20:42z ESP8266 ID: 14636923, RTC PCF8523 (68)
10/26/24 14:20:42z IoTaWatt 5.0, Firmware version 02_08_03
10/26/24 14:20:42z SPIFFS mounted.
10/26/24 10:20:42 Local time zone: -4:00
10/26/24 10:20:42 device name: IotaWatt
10/26/24 10:20:42 HTTP server started
10/26/24 10:20:42 influxDB_v2: Starting, interval:10, url:http://192.168.254.74:8086
10/26/24 10:20:42 timeSync: service started.
10/26/24 10:20:42 statService: started.
10/26/24 10:20:42 dataLog: service started.
10/26/24 10:20:42 dataLog: Last log entry 10/26/24 10:20:40
10/26/24 10:20:46 WiFi connected. SSID=IByte, IP=192.168.254.119, channel=6, RSSI -73db
10/26/24 10:20:46 Updater: service started. Auto-update class is MINOR
10/26/24 10:20:47 historyLog: service started.
10/26/24 10:20:47 historyLog: Last log entry 10/26/24 10:20:00
10/26/24 10:21:07 Updater: Auto-update is current for class MINOR.
10/26/24 14:24:41 WiFi disconnected.
10/26/24 14:24:44 WiFi connected. SSID=IByte, IP=192.168.254.119, channel=6, RSSI -79db
10/26/24 16:01:45 WiFi disconnected.
10/26/24 16:01:49 WiFi connected. SSID=IByte, IP=192.168.254.119, channel=6, RSSI -73db
10/26/24 17:38:08 WiFi disconnected.
10/26/24 17:38:11 WiFi connected. SSID=IByte, IP=192.168.254.119, channel=6, RSSI -79db
10/26/24 18:03:33 WiFi disconnected.
10/26/24 18:03:36 WiFi connected. SSID=IByte, IP=192.168.254.119, channel=6, RSSI -78db
10/26/24 18:37:51 WiFi disconnected.
10/26/24 18:37:55 WiFi connected. SSID=IByte, IP=192.168.254.119, channel=6, RSSI -80db
10/27/24 03:40:31 WiFi disconnected.
10/27/24 03:42:43 WiFi connected. SSID=IByte, IP=192.168.254.119, channel=6, RSSI -74db
10/27/24 08:40:59 influxDB_v2: stopped, Last post 02/06/06 02:28:16
10/27/24 08:44:16 influxDB_v2: stopped, Last post 02/06/06 02:28:16
10/27/24 09:12:24 PVoutput: started
10/27/24 09:12:25 PVoutput: System iotawatt-alanmiller, interval 5, freeload mode  
10/27/24 09:12:25 PVoutput: Start status beginning 10/27/24 00:05:00
10/27/24 09:39:03 influxDB_v2: Start posting 10/27/24 09:39:10
10/27/24 09:45:11 influxDB_v2: stopped, Last post 10/27/24 09:39:00
10/27/24 09:57:20 influxDB_v2: Start posting 10/27/24 00:00:10
10/27/24 10:04:15 influxDB_v2: stopped, Last post 10/27/24 00:00:00
10/27/24 10:11:18 influxDB_v2: Start posting 10/27/24 00:00:10
10/27/24 10:41:28 influxDB_v2: stopped, Last post 10/27/24 00:00:00
10/27/24 10:46:04 influxDB_v2: Start posting 10/27/24 00:00:10
10/27/24 10:51:55 influxDB_v2: stopped, Last post 10/27/24 00:00:00
10/27/24 10:53:02 influxDB_v2: Resume posting 10/27/24 00:02:40
10/27/24 11:17:47 influxDB_v2: stopped, Last post 10/27/24 00:02:30
10/27/24 11:22:34 influxDB_v2: Start posting 10/27/24 00:00:10
10/27/24 11:46:59 Restart command received.

I feel like this isnt an iotawatt issue but an Influxdb2 issue.

I installed latest v2 version on a different machine, created a bucket and token.
And when I try to write data to the bucket I just get an “internal error”.

example data

cat testdata.csv
Type,Shelter,Age,Description,DateTime
Cat,A,1.0,Tabby,2024-10-27T12:47:16Z
Cat,A,3.0,Calico,2024-10-27T12:47:16Z

influx cli write test

influx write -c rwtest --bucket testdata -f testdata.csv --header "#constant measurement,Animals"  --header "#datatype tag,tag,double,string,time:RFC3339"
Error: failed to write data: Post "http://192.168.254.109:8086/api/v2/write?bucket=testdata&org=alanmiller&precision=ns": EOF

error on server

Oct 27 15:26:45 ol9 influxdb[1870]: ts=2024-10-27T19:26:45.683603Z lvl=debug msg=Request log_id=0sVqjyCl000 service=http method=POST host=192.168.254.109:8086 path=/api/v2/write query="bucket=testdata&org=alanmiller&precision=ns" proto=HTTP/1.1 status_code=500 response_size=90 content_length=-1 referrer= remote=192.168.254.36:58984 user_agent=Sha authenticated_id=0ddfdb29798c4000 user_id=0ddfd764134c4000 took=20001.781ms error="internal error" error_code="internal error"

OK, I’m not really up to speed on writing with CSV. I had looked at it a few years ago but never saw an advantage for IoTaWatt. IoTaWatt uses the the line protocol.

The query does appear to have worked, but I can’t be sure. The “Post failed -11” message in the IoTaWatt status indicates that the write timed out without a response, so yeah, it looks like a problem with your influx server. Sorry can’t be more helpful.

thanks for trying. I will try the influx forums.
Next question will be how to plot the data (from influx) in Grafana.

I haven’t seen any posts showing example Grafana json models for plotting data from an Influxdb data source.

Haven’t been paying close attention to influx development, but I believe there is an influx3 with an OSS releasing soon or already. From what I have read, influx is pretty much abandoning the flux query system in favor of the old influx query from influxDB1, which I found to be much easier to use and well integrated into grafana.

Might be worth studying up on to be sure you are on the best path.

I found a corrupt wal file in my influx

Oct 27 16:35:29 rocky influxd[485297]: ts=2024-10-27T20:35:29.978811Z lvl=info msg="File corrupt" log_id=0sVvu8fl000 service=storage-engine engine=tsm1 service=cacheloader error="snappy: corrupt input" path=/var/lib/influxdb/engine/wal/3e7c5de42dc2ab95/autogen/1/_00009.wal pos=1176735

I couldnt find a command to repair it so I just stopped the service, deleteed the file and started the service and it looks like iotawatt finished loading data.

Screen Shot 2024-10-27 at 16.55.46 PM

At least I see something in flux now

1 Like