@gusgonnet,
Thank you for that pointer. I was able to get this working (though still a lot to learn) using the following steps:
-
Get an Elastic account and the necessary permissions (these were provided to me). Here is the Elastic API reference which you will need to send data: https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html
-
Define the JSON payload you intend to send but don’t send it yet).
-
Add these two fields to the payload in the Particle Webhook Integration (saves you from sending this data from the Particle device over cellular):
"timestamp": "{{PARTICLE_PUBLISHED_AT}}",
"device": "{{PARTICLE_DEVICE_ID}}",
Refer to the Elastic API for mapping: https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html
- Take that payload and use the Elastic mapping API to define the data types for each data element. Mine looked like this. I used Postman to send this command and got a 201 response.
{
"mappings": {
"properties": {
"timestamp": {"type":"date"},
"device": {"type": "keyword"},
"Temperature": {"type": "float"},
"Humidity": {"type": "float"},
"LightLevel": {"type": "integer"},
"Soilmoisture1": {"type": "float"},
"Soilmoisture2": {"type": "float"},
"waterPressure": {"type": "integer"},
"Solenoid": {"type": "integer"},
"Battery": {"type": "float"},
"Resets": {"type": "integer"},
"Alerts": {"type": "integer"}
}
}
}
- Finish the Particle Webhook Integration and send your first data set. My JSON payload looked like this:
{
"timestamp": "{{PARTICLE_PUBLISHED_AT}}",
"device": "{{PARTICLE_DEVICE_ID}}",
"Temperature": "{{Temperature}}",
"Humidity": "{{Humidity}}",
"LightLevel": "{{LightLevel}}",
"Soilmoisture1": "{{Soilmoisture1}}",
"Soilmoisture2": "{{Soilmoisture2}}",
"waterPressure": "{{waterPressure}}",
"Solenoid": "{{Solenoid}}",
"Battery": "{{Battery}}",
"Resets": "{{Resets}}",
"Alerts": "{{alerts}}"
}
This creates an “index” in Elastic.
- In order to see your data you log into Kabana (the dashboard / visualization engine that is typically installed with Elastic) and create an index pattern. This will take the data you just sent via webhook and map it using the mapping API call you made. Be sure to identify your timestamp in this process. Once this is done, it is hard to change.
Here is the reference for Kibana: https://www.elastic.co/guide/en/kibana/7.6/index.html
The end result will be an “index” of your data which can be searched, visualized and made into dashboards. I am still working on the dashboard part but will share once done.
Still to do:
-
Figure out how to map the Particle Device ID to a more “human friendly” name - perhaps with some lookup table?
-
Figure out how to form a “response template” so I can validate that the data was received by elastic in my sketch.
-
Figure out how to “reindex” data if I add, modify or change the mappings in the future.
Any tips and tricks would be helpful and I hope this helps folks get started.
Thanks, Chip