Monitoring Cells using the Elastic stack
In this how to, we are going to see how you can retrieve logs, system informations and more by setting up the ELK stack along Cells.
Elastic stack¶
"ELK" is the acronym for three open source projects: Elasticsearch, Logstash, and Kibana. Elasticsearch is a search and analytics engine. Logstash is a server‑side data processing pipeline that ingests data from multiple sources simultaneously, transforms it, and then sends it to a "stash" like Elasticsearch. Kibana lets users visualize data with charts and graphs in Elasticsearch.
Now with a new component the stack is most commonly referred as Elastic Stack.
There is a new component, Beats which is somewhat a lightweight logstash that has multiple variants for instance, Filebeat which is focused on files, logs, Metricbeat is focused on sending system and service statistics.
Install Kibana and Elasticsearch on the server that is going to process the data¶
Actually you could install them all in different machines for resources management but for our example Kibana and Elasticsearch are going to run on 1 server.
- Firstly, let's make sure that you have Java 8 by running
java -version
, otherwise to install java 8, use the following commands (for this example openjdk is used but you can use Oracle's Java).
then add the elastic repository,
debian users might need this:
sudo apt-get install apt-transport-https
- Now you are ready to install Kibana and Elasticsearch, let's proceed;
Once both installations are complete some settings have to be changed in the configuration.
You might require root rights to edit the config files.
For Kibana you must edit /etc/kibana/kibana.yml
:
- Change:
Then for Elasticsearch edit /etc/elasticsearch/elasticsearch.yml
and edit:
to the address where your elastic is running.
after all of the modifications lets start the services,
(if you want them to start automatically after a manual restart or if your server fails.)
Logstash and/or beats to fetch metrics¶
For this part you can use logstash as a standalone or use a lightweight version called Beats. Logstash has builtin all type of metrics whereas Beats depends on the type that you are going to use,of course you can use many beats at the same time.
Examples of beats:
-
Filebeat: which focuses solely on fetching from a log file (like a
tail -f <file>
) -
Metricbeat: can retrieve metrics (such as CPU, RAM, ....) from services or even application such as one in go (you will have to add some code to let the beat retrieve metrics from your application).
-
And many more.
In our case we just want to fetch logs from one instance of Cells so we are going to use Filebeat (a beat specialized in fetching files, in this case a log file written in JSON)
Basic configuration for Cells¶
First set a filebeat on the machine running Cells,
For debian/ubuntu machines use the following:
centos
once installed edit the /etc/filebeat/filebeat.yml
, and change the following lines according to your setup,
Now for the logs part add/edit the following settings,
What it does is read the json file(cells.log) and parse it so that elastic + kibana can use the data
Now lets test the config and start the beat,
You can use the test commands to make sure that everything is good, that the beat can reach kibana and elastic and that your filebeat.yaml
is correct.
You can setup and start your filebeat.
(do not forget to use systemctl enable filebeat
once your set to have it start automatically at each start)