Storing device events into PostgreSQL database

When did you start doing that? Lora-app-server version 3.1.0 was released yesterday so try this:

sudo apt-get update
sudo apt-get install lora-app-server

They should install the latest version which you can verify by typing:

lora-app-server version

I’m doing several Loraserver videos as well but truthfully you really need to read the documentation. I got this integration going within 5 minutes and you can as well.

It’s great that you’re measuring in home water consumption. I hope you get everything up and running smoothly with lopy4 and loraserver.

1 Like

thanks for your answer @bryansmith

the part of the configuration with postgresql as it would be because I have reviewed the documentation itself and I have made all the changes and then I do not know what I am really failing I put the command version lora-app-server but it does not work since if I could enter postgresql and I created the tables according to how it says @ brocaar

You run this command in the terminal, it has to work :blush:

I should also update what it is:
lora-gateway-bridge
loraserver

since I already updated you lora-app-server

I managed to configure the with postgresql in the file:

nano lora-app-server.toml.

but another file appeared when I updated it

nano lora-app-server.toml

I will load the code into toml.

but when I go to the website of lora server only this integration appears more
HTTP Integration
Influxdb integration

I do not get postgresql

what could be the problem nose if they could help me since the version of the lora-app-server is 3.1

@GustavoLema1988 I think you have a slight misunderstanding.

The postgresql integration isn’t a per application level integration.

ALL of the lora related events will be logged to the postrgres database that you define in the lora-app-server.toml

If you followed the instructions appropriately your data is currently being written to your postgresql database. This is all happening in the background. Look at your database and you should see events being logged.

1 Like

thanks for the information @bryansmith

one more query, the moment to add the integration with postgresql it is possible to integrate it with grafana to visualize the data that arrive from the sensors, since I am using as an example the LM35 where the data arrive like:

Value: 12 ° C

since when integrating lora server with influxdb I was created automatically the tables and could make queries of two tables like:

  • device_frm_payload_data_temperature

  • device_uplink

I want to see more tables to be able to make queries, where I see that postgresql allows creating tables where I think we can visualize:

  • uplink
  • device status
    join
  • ack
    *error
    *Location

I do not know if I’m wrong with that, they recommend me to integrate lora server with influxdb or with postgresql, since my work is based on measuring water consumption

Thank you…

This works fine with the current tables :slight_smile: You can select from the object field, which is a jsonb type field. For documentation, see: https://www.postgresql.org/docs/current/functions-json.html.

Thanks for your help @brocaar

then it is possible to integrate postgresql with grafana because in grafana there is a tab that says postgresql as influxdb but that is done automatically when choosing postgresql the values ​​read by the sensors would pass to grafana when I choose postgresql or should do some command nose if you could help me with that ?

What you need to do is:

  • Configure PostgreSQL as a Grafana data-source
  • Use that data-source and write a SQL query, which will then be visualized by Grafana

Like the questions of the friends above, I follow the configuration of the routines.
[application_server.integration]
Enabled = [“mqtt”, “postgresql”]
Cannot open the web page of port 8080.
My version is also the latest lora-app-server 3.1
If you remove “postgresql”, it will be normal again. But there is always no postgresql integration option, only three integration options in the picture.
Modified lora-app-server.toml configuration
image

thanks for the information @brocaar

but I do not know what happened but now I get this in portal-gateway-bridge already reboots but when I see the status of the server returns to this error and the same happens with loraserver that could be wrong

12 12:50:23 iot-Satellite-S55-A lora-gateway-bridge[27369]: time=“2019-07-12T12:50:23-05:00” level=error msg=“apply gateway-configuration error” error=“gateway does not exist”
jul 12 12:50:24 iot-Satellite-S55-A lora-gateway-bridge[27369]: time=“2019-07-12T12:50:24-05:00” level=info msg=“integration/mqtt: publishing event” event=up qos=0 topic=gateway/30aea4fffe786954/event/up
jul 12 12:50:24 iot-Satellite-S55-A lora-gateway-bridge[27369]: time=“2019-07-12T12:50:24-05:00” level=info msg=“integration/mqtt: downlink frame received” topic=gateway/30aea4fffe786954/command/down
jul 12 12:50:24 iot-Satellite-S55-A lora-gateway-bridge[27369]: time=“2019-07-12T12:50:24-05:00” level=error msg=“backend/semtechudp: could not handle packet” addr=“192.168.0.9:49154” data_base64="AhzrBDCupP/+eG
jul 12 12:50:35 iot-Satellite-S55-A lora-gateway-bridge[27369]: time=“2019-07-12T12:50:35-05:00” level=info msg=“integration/mqtt: publishing event” event=up qos=0 topic=gateway/30aea4fffe786954/event/up
jul 12 12:50:35 iot-Satellite-S55-A lora-gateway-bridge[27369]: time=“2019-07-12T12:50:35-05:00” level=info msg=“integration/mqtt: downlink frame received” topic=gateway/30aea4fffe786954/command/down
jul 12 12:50:35 iot-Satellite-S55-A lora-gateway-bridge[27369]: time=“2019-07-12T12:50:35-05:00” level=error msg=“backend/semtechudp: could not handle packet” addr=“192.168.0.9:49154” data_base64="AtxSBDCupP/+eG
jul 12 12:50:46 iot-Satellite-S55-A lora-gateway-bridge[27369]: time=“2019-07-12T12:50:46-05:00” level=info msg=“integration/mqtt: publishing event” event=up qos=0 topic=gateway/30aea4fffe786954/event/up
jul 12 12:50:46 iot-Satellite-S55-A lora-gateway-bridge[27369]: time=“2019-07-12T12:50:46-05:00” level=info msg=“integration/mqtt: downlink frame received” topic=gateway/30aea4fffe786954/command/down
jul 12 12:50:46 iot-Satellite-S55-A lora-gateway-bridge[27369]: time=“2019-07-12T12:50:46-05:00” level=error msg=“backend/semtechudp: could not handle packet” addr=“192.168.0.9:49154” data_base64="Aq9qBDCupP/+eG
~
~
maybe you could help me with this

[quote=“GustavoLema1988, post:41, topic:4724, full:true”]
thanks for the information @brocaar

but I do not know what happened but now I get this in portal-gateway-bridge already reboots but when I see the status of the server returns to this error and the same happens with loraserver that could be wrong

hello @bryansmith

the file that I believe you with the code
lora-app-server configuration file> lora-app-server.toml.
it is like this with the point at the end,
or so

lora-app-server configuration file> lora-app-server.toml

no point as shown in the loraserver.io document

You are correct Gustavo. I was using proper punctuation. I changed my post and made it a block quote so that no one else is mistaken. Thanks

@brocaar @bryansmith @GustavoLema1988
Hello everyone, after I configured the lora-app-server.toml file, I still can’t see the postgesql integration option. I didn’t find the reason. I reinstalled the latest components of the ubuntu operating system and the latest loraserver server. But still not successful.
1:
Application_server.integration]
Enabled=[“mqtt”, “postgresql”]
If I join postgresql, then lora-app-server fails to open web 8080 port, delete postgreql will open normally, I don’t know why?
2:
[application_server.integration.mqtt]
Server=“tcp://localhost:1883”
The second item has not changed since the originally installed configuration file has the option configuration of this port 1883 by default.
3:
[application_server.integration.postgresql]
Dsn=“postgres://loraserver_as:loraserver_as@localhost/loraserver_as_events?sslmode=disable”
My postgresql database server is also configured on another computer, for example: dsn=“postgres://usernamdb:mypassword@192.168.1.15/loraserver_as_events?sslmode=disable”

Other creations of database and table names, etc., are based on the default and default values ​​recommended by the author.
Same as the screenshot in front of me.
I don’t know why the postgrsql integration option still does not appear? Can anyone answer me? First, thank you.

The answer is here in this post:

@bryansmith
Thank you very much for your reply: 1: That is to say, even if the configuration is correct under the integration project option, you can’t see the postgresql option? 2: According to the author’s instructions, why do I join the Enabled = [“mqtt”, “postgresql”] character, the original normal website page 8080 port can not open? Thanks again.

In English please :grinning:

@bryansmith
Thank you very much for your reply: 1: That is to say, even if the configuration is correct under the integration project option, you can’t see the postgresql option? 2: According to the author’s instructions, why do I join the Enabled = [“mqtt”, “postgresql”] character, the original normal website page 8080 port can not open? Thanks again.