{"id":3278,"date":"2019-01-10T07:00:53","date_gmt":"2019-01-10T01:30:53","guid":{"rendered":"http:\/\/www.upnxtblog.com\/?p=3278"},"modified":"2020-12-21T19:04:21","modified_gmt":"2020-12-21T13:34:21","slug":"how-to-aggregate-docker-container-logs-and-analyse-with-elk-stack","status":"publish","type":"post","link":"https:\/\/www.upnxtblog.com\/index.php\/2019\/01\/10\/how-to-aggregate-docker-container-logs-and-analyse-with-elk-stack\/","title":{"rendered":"How to aggregate Docker Container logs and analyse with ELK stack ?"},"content":{"rendered":"<div class='booster-block booster-read-block'><\/div><p>Today we are going to learn about how to aggregate Docker container logs and analyze the same centrally using <strong><a href=\"http:\/\/www.upnxtblog.com\/index.php\/2018\/08\/09\/tutorial-visualize-historical-data-with-elk-stack\/\">ELK stack<\/a>.<\/strong>\u00a0<strong>ELK<\/strong>\u00a0stack comprises of <strong>Elasticsearch, Logstash, and Kibana <\/strong>tools. <strong><a href=\"https:\/\/www.elastic.co\" target=\"_blank\" rel=\"noopener\">Elasticsearch<\/a> <\/strong>is a highly scalable open-source full-text search and analytics engine.<\/p>\n<p>It allows you to store, search, and analyze big volumes of data quickly and in near real-time. <strong><a href=\"https:\/\/www.elastic.co\" target=\"_blank\" rel=\"noopener\">Kibana<\/a> <\/strong>is like a window into the Elastic Stack. It enables visual exploration and real-time analysis of your data in Elasticsearch. <strong><a href=\"https:\/\/www.elastic.co\" target=\"_blank\" rel=\"noopener\">Logstash<\/a> <\/strong>is the central dataflow engine in the Elastic Stack for gathering, enriching, and unifying all of your data regardless of format or schema. If you want to learn more about key concepts of the ELK stack, please check out earlier posts <a href=\"http:\/\/www.upnxtblog.com\/index.php\/2018\/08\/09\/tutorial-visualize-historical-data-with-elk-stack\/\">here<\/a>.<\/p>\n<p>As your container volume increases, it&#8217;s difficult to manage them and their logs. There is a need for a centralized solution to take care of log aggregation, monitoring, and analysis. Luckily we already have ELK stack which does Log aggregation well but Docker container logs need to be routed to Logstash.<\/p>\n<p>For log routing from each of the containers, we are going to use <strong><a href=\"https:\/\/github.com\/gliderlabs\/logspout\" target=\"_blank\" rel=\"noopener\">Logspout<\/a>\u00a0<\/strong>utility that attaches to all containers on a host, then routes their logs wherever we want. Here in our case, we are going to push it to Logstash and let it handle shipping, transformation, etc., In this article, we are going to use <strong>ElasticSearch<\/strong> to store, index the logs. <strong>Logstash<\/strong> ships manage to transform logs into a consistent format and use <strong>Kibana<\/strong> to visualize the logs.<\/p>\n<p>This quickstart assumes a basic understanding of Docker <a href=\"http:\/\/www.upnxtblog.com\/index.php\/2018\/09\/12\/how-to-install-docker-on-ubuntu\/\">concepts<\/a>, please refer to earlier posts for understanding Docker &amp; how to <a href=\"http:\/\/www.upnxtblog.com\/index.php\/2018\/09\/12\/how-to-install-docker-on-ubuntu\/\">install<\/a> and containerize <a href=\"http:\/\/www.upnxtblog.com\/index.php\/2018\/09\/19\/docker-tutorial-build-docker-image-for-your-angular-6-application\/\">applications<\/a>.<\/p>\n<p>With this context now, let&#8217;s check out how to aggregate Docker Container logs and analyze the same.<\/p>\n\n<h2>Log Aggregation Architecture<\/h2>\n<p>Before we head to the tutorial, below is what we want to achieve. All logs from the Docker containers will be routed to Logstash using Logspout over <em>UDP protocol. <\/em>Logstash will then serve as a Data collection engine, pushes it to Elasticsearch for indexing, making it available for searching. Post which using Kibana, we can analyze the logs, create visualizations as we want.<\/p>\n<figure id=\"attachment_3280\" aria-describedby=\"caption-attachment-3280\" style=\"width: 758px\" class=\"wp-caption aligncenter\"><img data-recalc-dims=\"1\" decoding=\"async\" data-attachment-id=\"3280\" data-permalink=\"https:\/\/www.upnxtblog.com\/index.php\/2019\/01\/10\/how-to-aggregate-docker-container-logs-and-analyse-with-elk-stack\/docker\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/12\/Docker.png?fit=1570%2C516&amp;ssl=1\" data-orig-size=\"1570,516\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Docker\" data-image-description=\"&lt;p&gt;Docker Log aggregation using Logspout,ELK stack&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Image &amp;#8211; Docker Log aggregation using Logspout,ELK stack&lt;\/p&gt;\n\" data-large-file=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/12\/Docker.png?fit=1024%2C337&amp;ssl=1\" class=\"wp-image-3280 lazyload\" data-src=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/12\/Docker.png?resize=758%2C249\" alt=\"Docker Log aggregation using Logspout,ELK stack\" width=\"758\" height=\"249\" data-srcset=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/12\/Docker.png?w=1570&amp;ssl=1 1570w, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/12\/Docker.png?resize=300%2C99&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/12\/Docker.png?resize=768%2C252&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/12\/Docker.png?resize=1024%2C337&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/12\/Docker.png?resize=1100%2C362&amp;ssl=1 1100w\" data-sizes=\"auto, (max-width: 758px) 100vw, 758px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 758px; --smush-placeholder-aspect-ratio: 758\/249;\" \/><figcaption id=\"caption-attachment-3280\" class=\"wp-caption-text\">Image &#8211; Docker Log aggregation using Logspout,ELK stack<\/figcaption><\/figure>\n<p>Next, we head over to the implementation of the same, here is an overview of the steps involved<\/p>\n<ol class=\"itemizedlist\" type=\"disc\">\n<li>Prepare Docker Compose scripts for ELK stack and Logspout configuration<\/li>\n<li>Launch Docker Containers<\/li>\n<li class=\"listitem\">Define an index pattern<\/li>\n<li class=\"listitem\">Visualize the data<\/li>\n<\/ol>\n<h2>Step #1. Prepare Docker Compose scripts for ELK stack and Logspout configuration<\/h2>\n<p><strong>ElasticSearch Docker Configuration:<\/strong>\u00a0We are going to use the official image, expose the two ports (9200\/9300) as required. <em>In production environments, make sure that the above ports are only accessible from internal and restrict access to the public.<\/em><\/p>\n<pre>elasticsearch:\r\nimage: elasticsearch:1.5.2\r\nports:\r\n- '9200:9200'\r\n- '9300:9300'\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>Kibana Docker Configuration: <\/strong>Kibana needs to connect to an instance of ElasticSearch so that visualizations can be made. Add <code>ELASTICSEARCH_URL<\/code>\u00a0environment variable and specify ElasticSearch Instance to connect to. <em>#5601<\/em> default port needs to be exposed.<\/p>\n<pre>kibana:\r\nimage: kibana:4.1.2\r\nlinks:\r\n- elasticsearch\r\nenvironment:\r\n- ELASTICSEARCH_URL=http:\/\/elasticsearch:9200\r\nports:\r\n- '5601:5601'\r\ndepends_on:\r\n- elasticsearch\r\n\r\n<\/pre>\n<p><strong>Logstash Docker Configuration: <\/strong>Logstash can process data from any source and normalizes it for storing. In the command section, you can note that Logstash will receive input on UDP protocol at port <em>#5000<\/em> and pushes the data to ElasticSearch instance.<\/p>\n<p>Also note, below is for demonstration purpose only but actually, Logstash can dynamically unify data from various sources and normalize the data into any of the destinations. You can also cleanse your data for diverse advanced downstream analytics and visualization use cases.<\/p>\n<pre>logstash:\r\n\u00a0\u00a0\u00a0 image: logstash:2.1.1\r\n\u00a0\u00a0\u00a0 environment:\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 - STDOUT=true\r\n\u00a0\u00a0\u00a0 links:\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 - elasticsearch\r\n\u00a0\u00a0\u00a0 depends_on:\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 - elasticsearch\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 - kibana\r\n\u00a0\u00a0\u00a0 command: 'logstash -e \"input { udp { port =&gt; 5000 } } output { elasticsearch { hosts =&gt; elasticsearch } }\"'\r\n\r\n<\/pre>\n<p>We now have an ELK stack configuration ready. Next steps, we&#8217;ll explore how to push logs into the system using Logspout.<\/p>\n<p><strong>Logspout Docker Configuration: <\/strong>Logspout will monitor Docker events. When a new container is launched it will automatically start collecting its logs. Every log line will be pushed into Logstash using the UDP protocol. Below is the Docker configuration, we are using logspout v3 but there are the latest versions available.<\/p>\n<pre>\u00a0 logspout:\r\n\u00a0\u00a0\u00a0 image: gliderlabs\/logspout:v3\r\n\u00a0\u00a0\u00a0 command: 'udp:\/\/logstash:5000'\r\n\u00a0\u00a0\u00a0 links:\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 - logstash\r\n\u00a0\u00a0\u00a0 volumes:\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 - '\/var\/run\/docker.sock:\/tmp\/docker.sock'\r\n\u00a0\u00a0\u00a0 depends_on:\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 - elasticsearch\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 - logstash\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 - kibana\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>Finally, our Docker Compose configuration will look the one below<\/p>\n<pre>version: '3.3'\r\nservices:\r\nlogspout:\r\nimage: gliderlabs\/logspout:v3\r\ncommand: 'udp:\/\/logstash:5000'\r\nlinks:\r\n- logstash\r\nvolumes:\r\n- '\/var\/run\/docker.sock:\/tmp\/docker.sock'\r\ndepends_on:\r\n- elasticsearch\r\n- logstash\r\n- kibana\r\nlogstash:\r\nimage: logstash:2.1.1\r\nenvironment:\r\n- STDOUT=true\r\nlinks:\r\n- elasticsearch\r\ndepends_on:\r\n- elasticsearch\r\n- kibana\r\ncommand: 'logstash -e \"input { udp { port =&gt; 5000 } } output { elasticsearch { hosts =&gt; elasticsearch } }\"'\r\nkibana:\r\nimage: kibana:4.1.2\r\nlinks:\r\n- elasticsearch\r\nenvironment:\r\n- ELASTICSEARCH_URL=http:\/\/elasticsearch:9200\r\nports:\r\n- '5601:5601'\r\ndepends_on:\r\n- elasticsearch\r\nelasticsearch:\r\nimage: elasticsearch:1.5.2\r\nports:\r\n- '9200:9200'\r\n- '9300:9300'\r\n<\/pre>\n<h2>Step #2.Launch Docker Containers<\/h2>\n<p>Now that Docker compose script is ready, launch containers using <code>docker-compose up<\/code> command.<\/p>\n<figure id=\"attachment_3285\" aria-describedby=\"caption-attachment-3285\" style=\"width: 731px\" class=\"wp-caption aligncenter\"><img data-recalc-dims=\"1\" decoding=\"async\" data-attachment-id=\"3285\" data-permalink=\"https:\/\/www.upnxtblog.com\/index.php\/2019\/01\/10\/how-to-aggregate-docker-container-logs-and-analyse-with-elk-stack\/elkd1\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/12\/ELKD1.jpg?fit=731%2C489&amp;ssl=1\" data-orig-size=\"731,489\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;S Karthikeyan&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1544184654&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"ELKD1\" data-image-description=\"&lt;p&gt;Start ELK stack&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Image &amp;#8211; Start ELK stack&lt;\/p&gt;\n\" data-large-file=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/12\/ELKD1.jpg?fit=731%2C489&amp;ssl=1\" class=\"size-full wp-image-3285 lazyload\" data-src=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/12\/ELKD1.jpg?resize=731%2C489\" alt=\"Start ELK stack\" width=\"731\" height=\"489\" data-srcset=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/12\/ELKD1.jpg?w=731&amp;ssl=1 731w, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/12\/ELKD1.jpg?resize=300%2C201&amp;ssl=1 300w\" data-sizes=\"auto, (max-width: 731px) 100vw, 731px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 731px; --smush-placeholder-aspect-ratio: 731\/489;\" \/><figcaption id=\"caption-attachment-3285\" class=\"wp-caption-text\">Image &#8211; Start ELK stack<\/figcaption><\/figure>\n<p>ElasticSearch and Kibana can take a few minutes to start. When Logstash launches it starts generating indexes in Elasticsearch.If you have noticed, we have not created any application which is generating logs, here we are going to use startup logs generated by ElasticSearch, Kibana &amp; Logstash itself.<\/p>\n<p>If you want to ignore logs for a specific container then you can add <code>LOGSPOUT=ignore<\/code> as an environment variable on Docker compose a script. For more information on other Logspout environment variables, please check <a href=\"https:\/\/github.com\/gliderlabs\/logspout\" target=\"_blank\" rel=\"noopener\">here<\/a>.<\/p>\n<p>Once all the containers are up, the next step is to launch Kibana and start defining the index pattern.<\/p>\n<h2>Step #3.Define Index Pattern<\/h2>\n<p>Now that startup logs would have been loaded to Elasticsearch, we would need to create an index pattern. An index is a collection of documents that have similar characteristics. An index is identified by a name and this name is used to refer to the index when performing indexing, search, update, and delete operations against the documents in it. Indexing is similar to the creation and update process of CRUD operations.<\/p>\n<p>Launch Kibana on port<em> # 5601<\/em>,under &#8216;Indices&#8217; \/ &#8216;Management&#8217; (on latest versions) tab you can find option to create Index pattern.Enter the name of the index <em>ex.logstash-*<\/em>. Kibana will then ask for a field containing a time\/timestamp which it should use for visualizing time-series data. for our case, this is the &#8220;@timestamp&#8221; field.<\/p>\n<figure id=\"attachment_3286\" aria-describedby=\"caption-attachment-3286\" style=\"width: 963px\" class=\"wp-caption aligncenter\"><img data-recalc-dims=\"1\" decoding=\"async\" data-attachment-id=\"3286\" data-permalink=\"https:\/\/www.upnxtblog.com\/index.php\/2019\/01\/10\/how-to-aggregate-docker-container-logs-and-analyse-with-elk-stack\/elkd2\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/12\/ELKD2.jpg?fit=963%2C623&amp;ssl=1\" data-orig-size=\"963,623\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;S Karthikeyan&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1544184679&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"ELKD2\" data-image-description=\"&lt;p&gt;Define Index Pattern&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Image &amp;#8211; Define Index Pattern&lt;\/p&gt;\n\" data-large-file=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/12\/ELKD2.jpg?fit=963%2C623&amp;ssl=1\" class=\"size-full wp-image-3286 lazyload\" data-src=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/12\/ELKD2.jpg?resize=963%2C623\" alt=\"Define Index Pattern\" width=\"963\" height=\"623\" data-srcset=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/12\/ELKD2.jpg?w=963&amp;ssl=1 963w, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/12\/ELKD2.jpg?resize=300%2C194&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/12\/ELKD2.jpg?resize=768%2C497&amp;ssl=1 768w\" data-sizes=\"auto, (max-width: 963px) 100vw, 963px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 963px; --smush-placeholder-aspect-ratio: 963\/623;\" \/><figcaption id=\"caption-attachment-3286\" class=\"wp-caption-text\">Image &#8211; Define Index Pattern<\/figcaption><\/figure>\n<p>Now that we have created the index pattern, it would take a few minutes to complete. The next step is to create visualizations. Before that, we can check the data from the &#8216;Discover&#8217; tab.<\/p>\n<figure id=\"attachment_3288\" aria-describedby=\"caption-attachment-3288\" style=\"width: 1281px\" class=\"wp-caption aligncenter\"><img data-recalc-dims=\"1\" decoding=\"async\" data-attachment-id=\"3288\" data-permalink=\"https:\/\/www.upnxtblog.com\/index.php\/2019\/01\/10\/how-to-aggregate-docker-container-logs-and-analyse-with-elk-stack\/elkd3\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/12\/ELKD3.jpg?fit=1281%2C630&amp;ssl=1\" data-orig-size=\"1281,630\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;S Karthikeyan&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1544184738&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"ELKD3\" data-image-description=\"&lt;p&gt;Check the log data under Discover tab&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Image &amp;#8211; Check the log data under Discover tab&lt;\/p&gt;\n\" data-large-file=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/12\/ELKD3.jpg?fit=1024%2C504&amp;ssl=1\" class=\"size-full wp-image-3288 lazyload\" data-src=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/12\/ELKD3.jpg?resize=1140%2C561\" alt=\"Check the log data under Discover tab\" width=\"1140\" height=\"561\" data-srcset=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/12\/ELKD3.jpg?w=1281&amp;ssl=1 1281w, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/12\/ELKD3.jpg?resize=300%2C148&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/12\/ELKD3.jpg?resize=768%2C378&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/12\/ELKD3.jpg?resize=1024%2C504&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/12\/ELKD3.jpg?resize=1100%2C541&amp;ssl=1 1100w\" data-sizes=\"auto, (max-width: 1140px) 100vw, 1140px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1140px; --smush-placeholder-aspect-ratio: 1140\/561;\" \/><figcaption id=\"caption-attachment-3288\" class=\"wp-caption-text\">Image &#8211; Check the log data under Discover tab<\/figcaption><\/figure>\n<p>We have enough data to visualize, we are ready to create Visualization<\/p>\n<h2>Step #4.Visualize the data<\/h2>\n<p>For demonstration purposes, I have created the below visualizations and attached them to the Dashboard.<\/p>\n<ol>\n<li>Metrics chart <em>to display count of log events<\/em><\/li>\n<li>Area chart <em>to show\u00a0count of logs events against time<\/em><\/li>\n<\/ol>\n<figure id=\"attachment_3289\" aria-describedby=\"caption-attachment-3289\" style=\"width: 1286px\" class=\"wp-caption aligncenter\"><img data-recalc-dims=\"1\" decoding=\"async\" data-attachment-id=\"3289\" data-permalink=\"https:\/\/www.upnxtblog.com\/index.php\/2019\/01\/10\/how-to-aggregate-docker-container-logs-and-analyse-with-elk-stack\/elkd4\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/12\/ELKD4.jpg?fit=1286%2C627&amp;ssl=1\" data-orig-size=\"1286,627\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;S Karthikeyan&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1544185390&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"ELKD4\" data-image-description=\"&lt;p&gt;Log events Dashboard with  visualizations&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Image &amp;#8211; Log events Dashboard with  visualizations&lt;\/p&gt;\n\" data-large-file=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/12\/ELKD4.jpg?fit=1024%2C499&amp;ssl=1\" class=\"size-full wp-image-3289 lazyload\" data-src=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/12\/ELKD4.jpg?resize=1140%2C556\" alt=\"Log events Dashboard with visualizations\" width=\"1140\" height=\"556\" data-srcset=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/12\/ELKD4.jpg?w=1286&amp;ssl=1 1286w, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/12\/ELKD4.jpg?resize=300%2C146&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/12\/ELKD4.jpg?resize=768%2C374&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/12\/ELKD4.jpg?resize=1024%2C499&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/12\/ELKD4.jpg?resize=1100%2C536&amp;ssl=1 1100w\" data-sizes=\"auto, (max-width: 1140px) 100vw, 1140px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1140px; --smush-placeholder-aspect-ratio: 1140\/556;\" \/><figcaption id=\"caption-attachment-3289\" class=\"wp-caption-text\">Image &#8211; Log events Dashboard with visualizations<\/figcaption><\/figure>\n<p><em>Congrats! we have learned how to aggregate all Docker container logs and analyze the same centrally using ELK stack.<\/em><\/p>\n<p>As always there is more to what was covered here! If you have questions, please post it in the comments section.<\/p>\n<p><em><strong>Like this post? Don\u2019t forget to share it!<\/strong><\/em><\/p>\n<h2>Useful Resources<\/h2>\n<ul>\n<li>Elasticsearch <a href=\"https:\/\/www.elastic.co\/guide\/en\/elasticsearch\/reference\/current\/docker.html\" target=\"_blank\" rel=\"noopener\">reference<\/a><\/li>\n<li>Kibana <a href=\"https:\/\/www.elastic.co\/guide\/en\/kibana\/current\/docker.html\" target=\"_blank\" rel=\"noopener\">reference<\/a><\/li>\n<li>Logstash <a href=\"https:\/\/www.elastic.co\/guide\/en\/logstash\/current\/docker.html\" target=\"_blank\" rel=\"noopener\">reference<\/a><\/li>\n<li>Logspout <a href=\"https:\/\/github.com\/gliderlabs\/logspout\" target=\"_blank\" rel=\"noopener\">Github<\/a><\/li>\n<li><a href=\"https:\/\/www.upnxtblog.com\/index.php\/2018\/08\/09\/tutorial-visualize-historical-data-with-elk-stack\/\">Tutorial : Visualize historical data with ELK stack<\/a><\/li>\n<li><a href=\"https:\/\/www.upnxtblog.com\/index.php\/2018\/09\/19\/docker-tutorial-build-docker-image-for-your-angular-6-application\/\">Docker tutorial \u2013 Build Docker image for your Angular 6 application<\/a><\/li>\n<li><a href=\"https:\/\/www.upnxtblog.com\/index.php\/2018\/07\/16\/kubernetes-tutorial-distributed-tracing-with-jaeger\/\">Kubernetes Tutorial : Distributed tracing with Jaeger<\/a><\/li>\n<li><a href=\"https:\/\/www.upnxtblog.com\/index.php\/2019\/03\/05\/monitoring-docker-containers-using-prometheus-cadvisor-grafana\/\">Monitoring Docker containers using Prometheus + cAdvisor + Grafana<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Today we are going to learn about how to aggregate Docker container logs and analyze the same centrally using ELK stack.\u00a0ELK\u00a0stack comprises of Elasticsearch, Logstash, and Kibana tools. Elasticsearch is a highly scalable open-source full-text search and analytics engine. It allows you to store, search, and analyze big volumes of data quickly and in near [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":3293,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[310,146],"tags":[53,279,304],"class_list":["post-3278","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-docker","category-cloud","tag-docker","tag-elk","tag-logspout"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/12\/ELKD.png?fit=898%2C312&ssl=1","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9fbQS-QS","jetpack-related-posts":[{"id":2707,"url":"https:\/\/www.upnxtblog.com\/index.php\/2018\/08\/09\/tutorial-visualize-historical-data-with-elk-stack\/","url_meta":{"origin":3278,"position":0},"title":"Tutorial : Visualize historical data with ELK stack","author":"Karthik","date":"August 9, 2018","format":false,"excerpt":"Today we are going to learn about the ELK stack, it consists of 3 powerful open-source tools Elasticsearch, Logstash, and Kibana. Elasticsearch is a highly scalable open-source full-text search and analytics engine. It allows you to store, search, and analyze big volumes of data quickly and in near real-time. Kibana\u2026","rel":"","context":"In &quot;How-To guides&quot;","block_context":{"text":"How-To guides","link":"https:\/\/www.upnxtblog.com\/index.php\/category\/how-to-guides\/"},"img":{"alt_text":"Final Dashboard with 3 visualizations","src":"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/07\/elk19.png?fit=1166%2C631&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/07\/elk19.png?fit=1166%2C631&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/07\/elk19.png?fit=1166%2C631&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/07\/elk19.png?fit=1166%2C631&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/07\/elk19.png?fit=1166%2C631&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":6290,"url":"https:\/\/www.upnxtblog.com\/index.php\/2021\/06\/14\/how-to-aggregate-logs-and-analyse-with-efk-stack\/","url_meta":{"origin":3278,"position":1},"title":"How to aggregate logs and analyse with EFK stack ?","author":"Karthik","date":"June 14, 2021","format":false,"excerpt":"Today we are going to learn about how to aggregate logs and analyze the same centrally using the EFK stack.\u00a0EFK stack comprises\u00a0Elasticsearch, Fluent Bit, and Kibana tools. Elasticsearch is a highly scalable open-source full-text search and analytics engine based on the Lucene library. It provides a distributed, multitenant-capable full-text search\u2026","rel":"","context":"In &quot;Kubernetes Guides&quot;","block_context":{"text":"Kubernetes Guides","link":"https:\/\/www.upnxtblog.com\/index.php\/category\/kubernetes\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2021\/05\/EFK.png?fit=586%2C243&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2021\/05\/EFK.png?fit=586%2C243&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2021\/05\/EFK.png?fit=586%2C243&ssl=1&resize=525%2C300 1.5x"},"classes":[]},{"id":3048,"url":"https:\/\/www.upnxtblog.com\/index.php\/2018\/11\/26\/kaniko-tutorial-build-container-images-without-docker-daemon\/","url_meta":{"origin":3278,"position":2},"title":"Kaniko Tutorial : Build container images without Docker Daemon","author":"Karthik","date":"November 26, 2018","format":false,"excerpt":"Google has recently introduced\u00a0Kaniko, an open-source tool for building container images from a Dockerfile even without privileged root access. If you've noticed, Docker daemon always runs as the root user. It actually binds to a Unix socket instead of a TCP port. By default, Unix socket is owned by the\u2026","rel":"","context":"In &quot;Docker Guides&quot;","block_context":{"text":"Docker Guides","link":"https:\/\/www.upnxtblog.com\/index.php\/category\/docker\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2017\/10\/google_chrome-logo.png?fit=800%2C473&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2017\/10\/google_chrome-logo.png?fit=800%2C473&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2017\/10\/google_chrome-logo.png?fit=800%2C473&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2017\/10\/google_chrome-logo.png?fit=800%2C473&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":3821,"url":"https:\/\/www.upnxtblog.com\/index.php\/2019\/05\/23\/everything-you-need-to-know-about-docker-enterprise-3-0\/","url_meta":{"origin":3278,"position":3},"title":"Everything You Need To Know About Docker Enterprise 3.0","author":"Karthik","date":"May 23, 2019","format":false,"excerpt":"Docker has recently announced Docker Enterprise 3.0, In this post, we take look at the key features of Enterprise Platform on how it improves developer productivity, accelerating time-to-market for new applications. If you're looking for the basic understanding of Docker concepts, please refer to earlier posts for understanding on Docker\u2026","rel":"","context":"In &quot;Docker Guides&quot;","block_context":{"text":"Docker Guides","link":"https:\/\/www.upnxtblog.com\/index.php\/category\/docker\/"},"img":{"alt_text":"Docker Enterprise Platform","src":"https:\/\/i0.wp.com\/blog.docker.com\/wp-content\/uploads\/2019\/04\/3222109f-b13e-4204-bd00-0c2ae19a9b6d-1.jpg?ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/blog.docker.com\/wp-content\/uploads\/2019\/04\/3222109f-b13e-4204-bd00-0c2ae19a9b6d-1.jpg?ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/blog.docker.com\/wp-content\/uploads\/2019\/04\/3222109f-b13e-4204-bd00-0c2ae19a9b6d-1.jpg?ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/blog.docker.com\/wp-content\/uploads\/2019\/04\/3222109f-b13e-4204-bd00-0c2ae19a9b6d-1.jpg?ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/blog.docker.com\/wp-content\/uploads\/2019\/04\/3222109f-b13e-4204-bd00-0c2ae19a9b6d-1.jpg?ssl=1&resize=1050%2C600 3x, https:\/\/i0.wp.com\/blog.docker.com\/wp-content\/uploads\/2019\/04\/3222109f-b13e-4204-bd00-0c2ae19a9b6d-1.jpg?ssl=1&resize=1400%2C800 4x"},"classes":[]},{"id":2913,"url":"https:\/\/www.upnxtblog.com\/index.php\/2018\/09\/12\/how-to-install-docker-on-ubuntu\/","url_meta":{"origin":3278,"position":4},"title":"How to install Docker on Ubuntu ?","author":"Karthik","date":"September 12, 2018","format":false,"excerpt":"Docker as we know, is an open platform for developers and sysadmins to build, ship, and run distributed applications, whether on laptops, data center VMs, or the cloud. In this post, we are going to take look at how to install Docker on Ubuntu 18 LTS. Requisites Ubuntu OS requirements:\u2026","rel":"","context":"In &quot;Docker Guides&quot;","block_context":{"text":"Docker Guides","link":"https:\/\/www.upnxtblog.com\/index.php\/category\/docker\/"},"img":{"alt_text":"Uninstall Docker","src":"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/09\/dock1.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/09\/dock1.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/09\/dock1.png?resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/09\/dock1.png?resize=700%2C400 2x"},"classes":[]},{"id":3686,"url":"https:\/\/www.upnxtblog.com\/index.php\/2019\/04\/29\/prometheus-vs-weavescope-vs-datadog-vs-sysdig-monitoring-tools-compared\/","url_meta":{"origin":3278,"position":5},"title":"Prometheus vs WeaveScope vs DataDog vs Sysdig monitoring tools compared","author":"Karthik","date":"April 29, 2019","format":false,"excerpt":"With the increasing adoption of containers and microservices in the enterprises, monitoring utilities now have to handle more services and server instances than ever before. Although infrastructure landscape has changed, operations teams still need to monitor the same metrics on CPU, RAM, File System, Network utilization, and the availability of\u2026","rel":"","context":"In &quot;Kubernetes Guides&quot;","block_context":{"text":"Kubernetes Guides","link":"https:\/\/www.upnxtblog.com\/index.php\/category\/kubernetes\/"},"img":{"alt_text":"kubernetes logo","src":"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2017\/11\/kubernetes.jpg?fit=722%2C612&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2017\/11\/kubernetes.jpg?fit=722%2C612&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2017\/11\/kubernetes.jpg?fit=722%2C612&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2017\/11\/kubernetes.jpg?fit=722%2C612&ssl=1&resize=700%2C400 2x"},"classes":[]}],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.upnxtblog.com\/index.php\/wp-json\/wp\/v2\/posts\/3278","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.upnxtblog.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.upnxtblog.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.upnxtblog.com\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.upnxtblog.com\/index.php\/wp-json\/wp\/v2\/comments?post=3278"}],"version-history":[{"count":2,"href":"https:\/\/www.upnxtblog.com\/index.php\/wp-json\/wp\/v2\/posts\/3278\/revisions"}],"predecessor-version":[{"id":3417,"href":"https:\/\/www.upnxtblog.com\/index.php\/wp-json\/wp\/v2\/posts\/3278\/revisions\/3417"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.upnxtblog.com\/index.php\/wp-json\/wp\/v2\/media\/3293"}],"wp:attachment":[{"href":"https:\/\/www.upnxtblog.com\/index.php\/wp-json\/wp\/v2\/media?parent=3278"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.upnxtblog.com\/index.php\/wp-json\/wp\/v2\/categories?post=3278"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.upnxtblog.com\/index.php\/wp-json\/wp\/v2\/tags?post=3278"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}