Influx v2 integration - device metrics and problems with downlink

Hi, I recently setup a Chirpstack Server (chirpstack/chirpstack:4.1.1 + chirpstack/chirpstack-gateway-bridge:4.0.3) along with Kerlink Wirnet iFemtoCell-evolution and some end devices from MClimate (thermostatic radiator valve and HT sensor).

All devices are registered and send uplink keepalive data with configured intervals. The data is parsed correctly by the uplink codec, device metrics in Chirpstack GUI is displayed, I can also send downlink commands to TRVs and HT sensors. I’m attaching some exemplary logs:

2023-02-03T12:38:31.716506Z  INFO chirpstack::gateway::backend::mqtt: Message received from gateway region_name="eu868" topic="eu868/gateway/7076ff0064050e69/event/up" qos=0 json=false
2023-02-03T12:38:31.919358Z  INFO up{deduplication_id=d2742c50-11fe-442b-a8c1-37aee8a2181b}: chirpstack::uplink: Uplink received m_type="UnconfirmedDataUp"
2023-02-03T12:38:31.923757Z  INFO up{deduplication_id=d2742c50-11fe-442b-a8c1-37aee8a2181b}:data_up: chirpstack::storage::device_session: Device-session saved dev_eui=70b3d52dd300aa81 dev_addr=014aa673
2023-02-03T12:38:31.929096Z  INFO chirpstack::storage::device: Setting device lock dev_eui=70b3d52dd300aa81
2023-02-03T12:38:31.931242Z  INFO up{deduplication_id=d2742c50-11fe-442b-a8c1-37aee8a2181b}:data_up: chirpstack::storage::device: Data-rate updated dev_eui=70b3d52dd300aa81 dr=5
2023-02-03T12:38:31.932266Z  INFO up{deduplication_id=d2742c50-11fe-442b-a8c1-37aee8a2181b}:data_up: chirpstack::storage::device_gateway: Gateway rx-info saved dev_eui=70b3d52dd300aa81
2023-02-03T12:38:31.941233Z  INFO up{deduplication_id=d2742c50-11fe-442b-a8c1-37aee8a2181b}:data_up: chirpstack::integration::mqtt: Publishing event topic=application/3a64a5df-e310-43c4-ae1f-87521876ce37/device/70b3d52dd300aa81/event/up
2023-02-03T12:38:31.947178Z  INFO up{deduplication_id=d2742c50-11fe-442b-a8c1-37aee8a2181b}:data_up: chirpstack::storage::metrics: Metrics saved name=device:70b3d52dd300aa81:relativeHumidity aggregation=HOUR
2023-02-03T12:38:31.949443Z  INFO up{deduplication_id=d2742c50-11fe-442b-a8c1-37aee8a2181b}:data_up: chirpstack::storage::metrics: Metrics saved name=device:70b3d52dd300aa81:relativeHumidity aggregation=DAY
2023-02-03T12:38:31.949709Z  INFO up{deduplication_id=d2742c50-11fe-442b-a8c1-37aee8a2181b}:data_up: chirpstack::storage::metrics: Metrics saved name=device:70b3d52dd300aa81:relativeHumidity aggregation=MONTH
2023-02-03T12:38:31.949933Z  INFO up{deduplication_id=d2742c50-11fe-442b-a8c1-37aee8a2181b}:data_up: chirpstack::storage::metrics: Metrics saved name=device:70b3d52dd300aa81:batteryVoltage aggregation=HOUR
2023-02-03T12:38:31.950125Z  INFO up{deduplication_id=d2742c50-11fe-442b-a8c1-37aee8a2181b}:data_up: chirpstack::storage::metrics: Metrics saved name=device:70b3d52dd300aa81:batteryVoltage aggregation=DAY
2023-02-03T12:38:31.950338Z  INFO up{deduplication_id=d2742c50-11fe-442b-a8c1-37aee8a2181b}:data_up: chirpstack::storage::metrics: Metrics saved name=device:70b3d52dd300aa81:batteryVoltage aggregation=MONTH
2023-02-03T12:38:31.950532Z  INFO up{deduplication_id=d2742c50-11fe-442b-a8c1-37aee8a2181b}:data_up: chirpstack::storage::metrics: State saved state=false
2023-02-03T12:38:31.950724Z  INFO up{deduplication_id=d2742c50-11fe-442b-a8c1-37aee8a2181b}:data_up: chirpstack::storage::metrics: Metrics saved name=device:70b3d52dd300aa81:targetTemperature aggregation=HOUR
2023-02-03T12:38:31.950932Z  INFO up{deduplication_id=d2742c50-11fe-442b-a8c1-37aee8a2181b}:data_up: chirpstack::storage::metrics: Metrics saved name=device:70b3d52dd300aa81:targetTemperature aggregation=DAY
2023-02-03T12:38:31.951688Z  INFO up{deduplication_id=d2742c50-11fe-442b-a8c1-37aee8a2181b}:data_up: chirpstack::storage::metrics: Metrics saved name=device:70b3d52dd300aa81:targetTemperature aggregation=MONTH
2023-02-03T12:38:31.951874Z  INFO up{deduplication_id=d2742c50-11fe-442b-a8c1-37aee8a2181b}:data_up: chirpstack::storage::metrics: State saved state=false
2023-02-03T12:38:31.952050Z  INFO up{deduplication_id=d2742c50-11fe-442b-a8c1-37aee8a2181b}:data_up: chirpstack::storage::metrics: State saved state=false
2023-02-03T12:38:31.952225Z  INFO up{deduplication_id=d2742c50-11fe-442b-a8c1-37aee8a2181b}:data_up: chirpstack::storage::metrics: State saved state=false
2023-02-03T12:38:31.952974Z  INFO up{deduplication_id=d2742c50-11fe-442b-a8c1-37aee8a2181b}:data_up: chirpstack::storage::metrics: Metrics saved name=device:70b3d52dd300aa81:sensorTemperature aggregation=HOUR
2023-02-03T12:38:31.953217Z  INFO up{deduplication_id=d2742c50-11fe-442b-a8c1-37aee8a2181b}:data_up: chirpstack::storage::metrics: Metrics saved name=device:70b3d52dd300aa81:sensorTemperature aggregation=DAY
2023-02-03T12:38:31.953466Z  INFO up{deduplication_id=d2742c50-11fe-442b-a8c1-37aee8a2181b}:data_up: chirpstack::storage::metrics: Metrics saved name=device:70b3d52dd300aa81:sensorTemperature aggregation=MONTH
2023-02-03T12:38:31.954179Z  INFO up{deduplication_id=d2742c50-11fe-442b-a8c1-37aee8a2181b}:data_up: chirpstack::storage::metrics: State saved state=false
2023-02-03T12:38:31.954493Z  INFO up{deduplication_id=d2742c50-11fe-442b-a8c1-37aee8a2181b}:data_up: chirpstack::storage::device_session: Device-session saved dev_eui=70b3d52dd300aa81 dev_addr=014aa673
2023-02-03T12:38:31.954825Z  INFO up{deduplication_id=d2742c50-11fe-442b-a8c1-37aee8a2181b}:data_up: chirpstack::storage::metrics: Metrics saved name=device:70b3d52dd300aa81 aggregation=HOUR
2023-02-03T12:38:31.955075Z  INFO up{deduplication_id=d2742c50-11fe-442b-a8c1-37aee8a2181b}:data_up: chirpstack::storage::metrics: Metrics saved name=device:70b3d52dd300aa81 aggregation=DAY
2023-02-03T12:38:31.955336Z  INFO up{deduplication_id=d2742c50-11fe-442b-a8c1-37aee8a2181b}:data_up: chirpstack::storage::metrics: Metrics saved name=device:70b3d52dd300aa81 aggregation=MONTH

Everything looks fine so far.

But when I configure InfluxDB v2 integration in CS GUI, weird things happen. There’s an 422 error when CS tries to push the uplink parsed data to database (logs below). In consequence:

  • the uplink data is stored in influx anyway (I can see the data in Influx Explorer);
  • device metrics storage that should happen right after the data is sent to Influx won’t happen anymore, so I stop seeing any device metrics visualisation in CS GUI;
  • the LoRaWAN frames and decoded payloads from the device are still visible in CS GUI;
  • I can’t send downlink commands anymore as the commands stay in the queue;

It seems that any problem with the external database access causes problems with storing device metrics and sending downlinks. Could you be so helpful and give me any more hints on how to solve the integration problem?

2023-02-03T12:14:12.700177Z  INFO chirpstack::gateway::backend::mqtt: Message received from gateway region_name="eu868" topic="eu868/gateway/7076ff0064050e69/event/stats" qos=0 json=false
2023-02-03T12:14:12.701744Z  INFO stats{gateway_id=7076ff0064050e69}: chirpstack::storage::gateway: Gateway state updated gateway_id=7076ff0064050e69
2023-02-03T12:14:12.702007Z  INFO stats{gateway_id=7076ff0064050e69}: chirpstack::storage::metrics: Metrics saved name=gw:7076ff0064050e69 aggregation=HOUR
2023-02-03T12:14:12.702215Z  INFO stats{gateway_id=7076ff0064050e69}: chirpstack::storage::metrics: Metrics saved name=gw:7076ff0064050e69 aggregation=DAY
2023-02-03T12:14:12.702423Z  INFO stats{gateway_id=7076ff0064050e69}: chirpstack::storage::metrics: Metrics saved name=gw:7076ff0064050e69 aggregation=MONTH
2023-02-03T12:14:25.311751Z  INFO chirpstack::gateway::backend::mqtt: Message received from gateway region_name="eu868" topic="eu868/gateway/7076ff0064050e69/event/up" qos=0 json=false
2023-02-03T12:14:25.514049Z  INFO up{deduplication_id=d63f2d45-6848-4a76-a508-89bc0d163572}: chirpstack::uplink: Uplink received m_type="UnconfirmedDataUp"
2023-02-03T12:14:25.518845Z  INFO up{deduplication_id=d63f2d45-6848-4a76-a508-89bc0d163572}:data_up: chirpstack::storage::device_session: Device-session saved dev_eui=70b3d52dd300aa81 dev_addr=014aa673
2023-02-03T12:14:25.524277Z  INFO chirpstack::storage::device: Setting device lock dev_eui=70b3d52dd300aa81
2023-02-03T12:14:25.527597Z  INFO up{deduplication_id=d63f2d45-6848-4a76-a508-89bc0d163572}:data_up: chirpstack::storage::device: Data-rate updated dev_eui=70b3d52dd300aa81 dr=5
2023-02-03T12:14:25.527976Z  INFO up{deduplication_id=d63f2d45-6848-4a76-a508-89bc0d163572}:data_up: chirpstack::storage::device_gateway: Gateway rx-info saved dev_eui=70b3d52dd300aa81
2023-02-03T12:14:25.546263Z  INFO up{deduplication_id=d63f2d45-6848-4a76-a508-89bc0d163572}:data_up: chirpstack::integration::mqtt: Publishing event topic=application/3a64a5df-e310-43c4-ae1f-87521876ce37/device/70b3d52dd300aa81/event/up
2023-02-03T12:14:25.552246Z ERROR up{deduplication_id=d63f2d45-6848-4a76-a508-89bc0d163572}: chirpstack::uplink::data: Handle uplink error error=HTTP status client error (422 Unprocessable Entity) for url (http://influxdb.server:8086/api/v2/write?org=vsd&bucket=lora)
InfluxDB 2.6.1 (influxd --log-level=debug  2>&1 > /path/to/influxdb.log)

ts=2023-02-03T12:14:25.550033Z lvl=debug msg="buckets find" log_id=0fmn7m~l000 store=new took=0.061ms
ts=2023-02-03T12:14:25.551306Z lvl=debug msg=Request log_id=0fmn7m~l000 service=http method=POST host=influxdb.server:8086 path=/api/v2/write query="bucket=lora&org=vsd" proto=HTTP/1.1 status_code=422 response_size=241 content_length=2008 referrer= remote=172.24.0.6:43530 user_agent=unknown took=3.463ms error="unprocessable entity" error_code="unprocessable entity"
ts=2023-02-03T12:14:36.357924Z lvl=debug msg="user find by ID" log_id=0fmn7m~l000 store=new took=0.022ms
ts=2023-02-03T12:14:36.358057Z lvl=debug msg="org find" log_id=0fmn7m~l000 store=new took=0.042ms

I also noticed one more thing - when configuring Influx db v2 integration in CS GUI and saving it, coming back to edit the integration sends us to form for v1 integration.