Jul 12, 2018 - Valerii Bosiak (trainee)  

Monitoring Kubernetes

Student Valerii Bosiak reviews tools for monitoring Kubernetes.

What is the main idea of monitoring ?

Monitoring is a way to see the state of your system. For example load average, active RAM, load on the network and many other useful metrics, which you will necessarily want to see if you have a complex, cohesive infrastructure. If something goes wrong, motoring will help to identify a weak point in your system or to identify the cause of incorrect or inefficient operation of the system.

There are many monitoring tools exists now. So let's look on some of them.

Prometheus

Prometheus is an open-source systems monitoring and alerting. Since its inception in 2012, many companies and organizations have adopted Prometheus, and the project has a very active developer and user community. It is now a standalone open source project and maintained independently of any company.

Prometheus main features are:

  • the main Prometheus server which scrapes and stores time series data
  • client libraries for instrumenting application code
  • a push gateway for supporting short-lived jobs
  • special-purpose exporters for services like HAProxy, StatsD, Graphite, etc.
  • an alertmanager to handle alerts
  • various support tools

Grafana

Grafana is an open-source, general purpose dashboard and graph composer, which runs as a web application. Grafana allows you to query, visualize, alert on and understand your metrics no matter where they are stored.

Grafana main features are:

  • plethora of visualization options to help understand your data
  • define alerts and thresholds visually, and get notified via Slack, PagerDuty, and more
  • supports dozens of databases, natively. Mixing them together in the same Dashboard
  • official library with hundreds of dashboards and plugins
  • sharing data and dashboards across teams

Zabbix

Zabbix is software that monitors numerous parameters of a network and the health and integrity of servers. Zabbix uses a flexible notification mechanism that allows users to configure e-mail based alerts for virtually any event. This allows a fast reaction to server problems. Zabbix offers excellent reporting and data visualisation features based on the stored data. This makes Zabbix ideal for capacity planning.

Main Zabbix features:

  • device monitoring
  • network monitoring
  • database monitoring
  • website monitoring
  • automated alerts
  • reports, graphs, and charts

Setup monitoring with Prometeus and Grafana

Requirements:

  1. Working kubernetes cluster
  2. Installed helm

First we need to configure helm in your cluster, if it's not configured. There is one simple command:

helm init --upgrade

Then we add repository in your helm. This repo contain a Prometheus chart:

helm repo add coreos https://s3-eu-west-1.amazonaws.com/coreos-charts/stable/

Finnaly install required charts:

helm install coreos/prometheus-operator --name prometheus-operator --namespace monitoring
helm install coreos/kube-prometheus --name kube-prometheus --set global.rbacEnable=true --namespace monitoring

Grafana automatically installed with Prometheus, so we don't need to manually install it. To enter the Grafana or Prometheus web-interface we need to forward their ports.

For Grafana:

kubectl port-forward $(kubectl get pods --selector=app=kube-prometheus-grafana -n  monitoring --output=jsonpath="{.items..metadata.name}") -n monitoring  3000 &

For Prometheus:

kubectl port-forward -n monitoring prometheus-kube-prometheus-0 9090 &

All done! Now we can go to the web-interface at http://localhost:3000 and http://localhost:9090 relatively.

Conclusion

Monitoring of clusters of the Kubernetes is very important for maintaining the system in an efficient state. Monitoring systems can easily be configured for alerts in a dangerous situation. This will save your time and money many times.

For the latest and most detailed news follow @dataengi on Twitter. Future blog posts suggestions RSS

Discover Lightbend Enterprise Suite

Lightbend Reactive Platform and Lightbend Fast Data Platform include Enterprise Suite, to help you run your applications at scale.

Learn More

Try DataEngi service risk-free for 2-week trial sprint.

No credit card required. Have questions? Contact us.