Monitoring and Logging

Introduction

Here we describe how you can setup your logging and monitoring for kubernetes keeping in mind dashboard design also.

Logging

Logging mainly divide into three parts

  1. Logs collector

    1. fluentd

    2. Elasticsearch Beats (like filebeat for logs)

    3. fluent bit (light version of fluentd written in C for performance and low resource utilization)

    4. Telegraf (part of influxdb project)

  2. Logs storage

    1. Elasticsearch (best for text based searching)

    2. filesystem (if you won't interested in text based search)

    3. InfluxDB (influxDB also able to store logs, but I am not so much aware)

  3. Logs dashboard

    1. Kibana (Kibana is well known ELK stack project and well works with elasticsearch database, but the problem is it uses lots of RAM, you can use logtrail plugin for showing logs in tail form based on some filters)

Here we are going to use Elasticsearch, fluent bit, and Kibana for logging solution for kubernetes.

Fluent bit/Fluentd

For collecting all logs you need to run fluent bit/fluentd as a DaemonSet and collect all files from folder /var/log/containers. You can also use helm chart for the deployment of this.

Here we can also create new index of each namespace of kubernetes, this easily the filtering little bit on logtrail plugin screen

In above you can see that I am using logstash_prefix which is used generate dynamic index in elasticsearch, you can also use your own pattern, this will help you filter in settings of logtrail plugin

Use any standard way to install fluent bit/fluentd on your kubernetes, for e.g., use below helm charts

Elasticsearch

Install elasticsearch on your own, either use helm chart (https://github.com/kubernetes/charts/tree/master/incubator/elasticsearch) and just use any VMs to install it, you can find many tutorial to configure and optimize it.

Kibana

You can install default kibana either on Kubernetes or on any machine from where it can access elasticsearch

Logging tail in Kibana

You can use logtail(https://github.com/sivasamyk/logtrail) plugin of kibana for that, and use below logtrail.json

In above you can just use various filters according to index patterns made my fluentd/fluent bit and also define your own mapping

Last updated