Best Way To Read/Write To External DB

We are using chirpstackv4 as our main lorawan network server. We would like to connect it to our main database(s) to allow the information to be distributed to our front end application. There are several ways to do this inside the chirpstack application, but we are looking to connect the data in a more scalable way as well as not manually creating the deployments in the chirpstack application.

What approaches has everyone used to do this type of work? Think about only using the application for engineering checks, but automating deployments and devices from the front end.

Check out the Integrations list, there are many to choose from:

https://www.chirpstack.io/docs/chirpstack/integrations/index.html

I like the MQTT integration when incorporating ChirpStack with other IoT components in a larger platform. The HTTP and PostgreSQL integrations are also very popular.

1 Like

Currently I’m working on building a user portal for easy device onboarding, alerts and viewing device metrics. The way I’m leaning towards to retrieve Chirpstack data is using the MQTT integration to push events to an MQTT broker on the portals server, where then I can receive the events in real time, process them and store the relevant info into a database on the portal. Alternatively I’ve tested the postgreSQL integration and it seems like a viable option aswell. If you really want to get your hands dirty, using the redis integration streams themselves comes with the added bonus of viewing API call history.

If MQTT is used - have you been able to write to the LNS? I see many ways to read from the LNS. The goal hear is to have a single interface for our team versus using our interface and the chirpstack interface.

You need to use the API to interact with LNS. By using the MQTT integration to listen to events and the API to control the network you should have you all the functionality you need.

2 Likes

As noted, integrations are for receiving data not stored perpetually by the network server. gRPC API is the preferred way for configuration of the LNS.

The documentation on Postgresql is not very clear in terms of the purpose.

Is this to write information directly to the chirpstack db so that the data is stored and used by the LNS or does this copy all data from the existing chirpstack db to the new db? Maybe something different?

The postgresql integration pushes events to an external database. Integrations in general are for the large part only to retrieve data, not to interact with Chripstack. So it can’t write to the database, nor does the integration copy any previous information. Instead when events occur, Chirpstack will write those to the external database. From inspecting my own postgres integration database these are the tables:

postgres_integration-> \dt
List of relations
-[ RECORD 1 ]----------------------
Schema | public
Name   | __diesel_schema_migrations
Type   | table
Owner  | postgres_integration
-[ RECORD 2 ]----------------------
Schema | public
Name   | event_ack
Type   | table
Owner  | postgres_integration
-[ RECORD 3 ]----------------------
Schema | public
Name   | event_integration
Type   | table
Owner  | postgres_integration
-[ RECORD 4 ]----------------------
Schema | public
Name   | event_join
Type   | table
Owner  | postgres_integration
-[ RECORD 5 ]----------------------
Schema | public
Name   | event_location
Type   | table
Owner  | postgres_integration
-[ RECORD 6 ]----------------------
Schema | public
Name   | event_log
Type   | table
Owner  | postgres_integration
-[ RECORD 7 ]----------------------
Schema | public
Name   | event_status
Type   | table
Owner  | postgres_integration
-[ RECORD 8 ]----------------------
Schema | public
Name   | event_tx_ack
Type   | table
Owner  | postgres_integration
-[ RECORD 9 ]----------------------
Schema | public
Name   | event_up
Type   | table
Owner  | postgres_integration

But if your curious you should just set it up yourself, takes about 5 lines and less than 5 minutes.

1 Like

To add to the answer you’ve already received, an important point of clarification is that ChirpStack does not store any gateway or device payloads, other than a few recent entries to display in the UI (Events, LoRaWAN frames).

You need to decide what ChirpStack should do with your incoming data and where it should go. That is where integrations come in.

1 Like

Thanks @Liam_Philipp for the details. I was playing around and just reconfigured Postgres and was able to insert info into the DB.

I think the API is going to be the way to fully engage with chirpstack. I honestly need to R/W to it for multiple reasons.