Configure Elastic - jonatello/farmalytics GitHub Wiki
An Elastic Stack will be used to consume the data. A general guide to configure this on FreeBSD can be found here - https://github.com/jonatello/lab-musing/wiki/Elastic-Stack
Assuming the stack is already configured (version 6.4.2), we can customize the configuration for Farmalytics. This will assume a fairly simple single node back end, so we will configure the template for this.
Configure Logstash
Use the following logstash.conf file within the git repo which is already copied down for Logstash
cp ~/farmalytics/logstash.conf /usr/local/etc/logstash/logstash.conf
Configure ElasticSearch template
To be able to upload a template, the index needs to first exist. Log into Kibana and within Management create a "farmalytics-*" index.
Upload a template from a json file to be used with an index (farmalytics, which can be copied from ~/farmalytics/farmalytics.template.json). In this case the template is modified to set the number of shards to 1 and number of replicas to 0 (as we are using a single node setup with ElasticSearch)
curl -XPUT 'http://localhost:9200/_template/filebeat' -H 'Content-Type: application/json' -d@'~/farmalytics/farmalytics.template.json'
Verify the template has been uploaded
curl localhost:9200/_cat/templates
To reindex, delete the existing indices
curl -XDELETE 'localhost:9200/farmalytics-*'
Give it some time for documents to be written, then verify the number of shards/replicas is 1/0
curl localhost:9200/_cat/indices
Configure Kibana
Within Kibana it will be useful to configure some different visualizations and build out a dashboard. The fields for the sensors include the following:
- humidity_value
- temperature_value
- photoresistor_value
- moisture_value
Configure IPFW
Configure ipfw using the ipfw.rules file within this code repo
Troubleshooting
To delete an index (reindex), such as if fields get added/changed, run the following (assuming logstash-* as index name). It should return "acknowledged":true
curl -XDELETE 'localhost:9200/logstash-*'
You may also need to log into Kibana and within Management > Index Patterns, click the "refresh field list" to recognize new fields for visualizations