a person playing a drum set

I thought it was about time, as I had some to spare today, to have a play with one of the new feature of the Elastic family of products I have yet to try.

Beats is the platform for single-purpose data shippers. They install as lightweight agents and send data from hundreds or thousands of machines to Logstash or Elasticsearch.

I have used an ELK stack before↗ but never for metrics, it always been for more traditional log files and tools such as Zabbix↗ have been my goto for metrics.

Before going any further it should be pointed out that this is in no way a production configuration, there is no high availability, storage volumes used or any thought around security, it is just a proof of concept.

Launching an ElasticĀ Stack

As I needed somewhere to send my metrics to I decided to use Docker Machine (Docker again, now there is a surprise) to launch three Docker hosts in DigitalOcean↗ , configure a Swarm and then create an Elasticsearch & Kibana service.

To do this, I first launched a manager host;

Trying out Elastic Beats 1/21
dockemr----a-ddddnmriiiaaiggggcviiiehetttriraaanllledoooiccccgeeeriaaaetnnnaa---tlarseoceiccgz\eeieasonsn2-gtlbkne1n\your-do-token-goes-here\

Then two workers;

Trying out Elastic Beats 2/21
ddoocckkewewr----or----o-ddddr-ddddrmriiikmriiikaigggeaigggecviiircviiirhettt0hettt0iraaa1iraaa2nlllnllledoooedoooiccciccccgeeecgeeeriaaariaaaetnnnetnnnaa---aa---tlarstlarseoceieoceiccgzccgz\eeie\eeieasoasonsn2nsn2-g-gtlbtlbknkne1e1nn\\yyoouurr--ddoo--ttookkeenn--ggooeess--hheerree\\

Once I had all three Docker hosts online I ran the following to make sure that the Elasticseach container would launch;

Trying out Elastic Beats 3/21
ddoocckkeerr--mmaacchhiinneesssshhwwoorrkkeerr0012ssuuddoossyyssccttll--wwvvmm..mmaaxx__mmaapp__ccoouunntt==226622114444

Notice that I only ran the commands on the two worker nodes, I am going to keep my Elastic stack on just these two hosts.

Now that my three Docker hosts are available and configured I created the Docker Swarm cluster by running the following commands;

Trying out Elastic Beats 4/21
dSddoWoocMcckTkkeKeerNrr=$$$$((((ddddoooocccckkkkeeeerrrr---m$mma(aacdcchohhiciinknneeeerc-ccomoonannfcffihiigiggnmewwaooncrraokkgneeefrrri00)g12))smwassanwwraaamgrremmirn)jjiootsiiwnna-r$$am((dddvjooeoccrikktneei-rrst--eomm-kaaaeccdnhhdiir-nnqee$(wiidopporckmmkeaaernnr)aa-ggmeearrc))h::i22n33e7777ip--mttaoonkkaeegnner$$)SS:WW2MM3TT7KK7NN-listen-addr$(docker-machineipmanager):2377

text

I checked that all three Docker hosts were correctly in the cluster;

Trying out Elastic Beats 5/21
docker$(docker-machineconfigmanager)nodels

a screenshot of a computer

Everything was as expected, it was time to launch the Elasticsearch and Kibana services. I started by creating an overlay network called elk;

Trying out Elastic Beats 6/21
docker$(docker-machineconfigmanager)networkcreate-driververlayelk

graphical user interface, text

Then I created the Elasticsearch service;

Trying out Elastic Beats 7/21
docek-----lennpcearaeuonsmtbnvt$ewlsi(oitEcdersrSsolkha_ecaiJakse9nAretl2tVcrik0Ah-c0"_ms\:nOae9oPca2dThr0eSic0.=nhr"e\o-\lXcemosn=5f=1i2gwmomr-akXnemarxg"5e1r\2)m"se\rvicecreate\

Followed by the Kibana service;

Trying out Elastic Beats 8/21
dockk-----iennpcebraeuonamtbnvn$ewlsa(oitEdkrsrLoikhaAcbiSkae5nTenl6tIrak0C-1"Sm\\:nEa5oAc6dRh0eCi1.Hnr_e\oUlRceLo=n=hf=titgwpo:mr/ak/neearlg"aesr\t)icsseeravricche:9c2r0e0at\e\

text

After a minute I checked that the two services were running as expected using;

Trying out Elastic Beats 9/21
docker$(docker-machineconfigmanager)servicels

text

I now had my Elastic stack up and running.

Installing Metricbeats

Now that I had my three hosts running and an Elastic stack ready to ingest data I need to install some Beats on the host. Looking at the available Beats I decided to go with the Metricbeat↗ as this covered all of the basics I wanted;

System-Level Monitoring, Simplified; Deploy Metricbeat on all your Linux, Windows, and Mac hosts, connect it to Elasticsearch and voila: you get system-level CPU usage, memory, file system, disk IO, and network IO statistics, as well as top-like statistics for every process running on your systems.

As Docker Machine provides an SSH command, I decided to continue to use that to install and configure the service. Before installing I grabbed the IP address of the Manager node so I could use it when configuring Metricbeat, to do this I ran the following;

Trying out Elastic Beats 10/21
SWMIP=$(docker-machineipmanager)

I should be able to use $SWMIP where I need to need to use the IP address of a host within the Swarm Cluster. Remember, as I launched the Elastic stack as a service hosted on an overlay network I should be able to hit any of my three nodes to be routed to the correct container.

I started by installing Metricbeats on worker01, first of all by downloading and installing the deb package;

Trying out Elastic Beats 11/21
ddoocckkeerr--mmaacchhiinneesssshhwwoorrkkeerr0011csuurdlo-dLpk-gO-hittmpest:r/i/cabretaitf-a5c.t1s..1e-laamsdt6i4c..dceob/downloads/beats/metricbeat/metricbeat-5.1.1-amd64.deb

Once I had installed the deb package I configured Elasticbeat by running the following command which overwrote the default configuration file;

Trying out Elastic Beats 12/21
dm--oMoeuEctmmeppmmhepthTkroeneroeonepoReidt---------arodt------sarusIrcurbicurtbittC-bliclcdffmnploelicimndcslo.sBmeecpooiiseeredsecpneeio:ede:Eaa:suarslsmtod:s:sufmtsnd:lActedeketowc:eeoowktu:a[Th.stisaroe1sdtroian1s'_imysoytyrst0:osyroiit0t$Cnos:sksrsc:knxrsiSOedttu[ke:ucWNueee'er/esMFslmm.r/eIIse*/aPGhs'vr:":]ac9wrh2o/:0rr0ku'en]r/0d1ocbkaesrh.s-occk"cat>/etc/metricbeat/metricbeat.ymlMETRICBEAT_CONFIG

The configuration file enables two Metricbeat modules;

  • system; this is the default module which collects host metrics such as the ones listed under ā€œmetricsetsā€.
  • docker; this is an experimental module which gathers metrics on both the Docker hosts and the containers running on them, notice that I have configured it to use the socket file rather connecting to the Docker API using a network socket.

Also, at the end of the configuration, we tell Metricbeat where our Elasticsearch container is accessible for it to send data.

Once the configuration file was in place I started the service by running;

Trying out Elastic Beats 13/21
docker-machinesshworker01sudo/etc/init.d/metricbeatstart

text

I then repeated the process on worker02 and manager by replacing worker01 in the docker-machine ssh commands.

Before I logging into Kibana there are two more things that I needed to do, first of all, import the Metricbeat template, to do this I ran;

Trying out Elastic Beats 14/21
docker-machinesshmanagercurl-XPUT"http://$SWMIP:9200/_template/metricbeat"-d@/etc/metricbeat/metricbeat.template.json

Then, I ran a script to import the pre-built Kibana Dashboards by running;

Trying out Elastic Beats 15/21
docker-machinesshmanagersudo/usr/share/metricbeat//scripts/import_dashboards-eshttp://$SWMIP:9200

Viewing the Metrics Dashboard

Now that I had installed and configured Metricbeat on all three hosts and readied Elasticsearch and Kibana it was time to open the Kibana dashboard.

To do this, I ran the following command;

Trying out Elastic Beats 16/21
openhttp://$(docker-machineipmanager):5601

Like all other Kibana installations, the first thing I needed to do was configure an index pattern, to do this I entered metricbeat-*and selected @timestampfrom the drop-down list;

graphical user interface, text, application, email

Once that index pattern had been configured clicking on Discover took me to the following view, as you can see, I was receiving metrics from my three hosts;

graphical user interface, text, application, table

Clicking on Dashboard, and then selecting Metricbeat-overview gave me the following view;

graphical user interface, table

From there I clicked on Load/CPU and Processes gave me the following dashboards;

graphical user interfacechart

So far, so good. Before moving onto the Docker dashboards, I decided to launch a few more services. To do this, I ran the following;

Trying out Elastic Beats 17/21
ddooccrkk----ueenrpnsrraeuesmpbtm$$ellwc((iiokddccsreoolahknccusdkks8creet30lirre:uc--r\8skmm\0t/aa/eccctrlhhcnuiipesnntteewerccrooknnff\iiggmmaannaaggeerr))nseetrwvoirckeccrreeaattee-\dverlayclusternetwork

This created a service which launched three basic containers using the image from russmckendrick/cluster↗ and then made them available on port 80 on all three hosts.

Then I launched a service using manomarks/visualizer↗ , this gives you a visual representation of your Docker Swarm cluster. To this I ran;

Trying out Elastic Beats 18/21
docmk----aenpcmnrauooombnum$elsna(ittrdvsrkoihatscziy/k8npve\0teir8=s-0nbum:oiaa8dnlc0edih8.,zi0rsenorre\lce=c=/o=vnmafarin/gargumenar/nda\ogcekre)r.sseorcvki,cdestc=r/evaatre/r\un/docker.sock\

text

Running the following showed me my cluster

Trying out Elastic Beats 19/21
openhttp://$(docker-machineipmanager)/

Then running;

Trying out Elastic Beats 20/21
openhttp://$(docker-machineipmanager):8080

Opened my browsers and showed me how my Swarm cluster was organised;

chart, treemap chart

Going back to Kibana, I selected the Metricbeat Docker dashboard and was greeted by the following;

graphical user interface

The dashboard is exactly what I was expecting to see, selecting the container from the list on the top left shows just the metrics for the selected container. At this point, my time ran out, so I tore down the cluster by running;

Trying out Elastic Beats 21/21
docker-machinermmanagerworker01worker02

After dipping my toe in the water I think it is something I am going to be looking into more, there are plenty of other Beats available;

The following talk from OSDC 2016 gives a good idea about the sort of things you can use Beats for;