Best Practices, Tools, and Approaches for Kubernetes Monitoring
Tags: kubernetes, monitoring, cloud, bestpractices
Published: 2022-03-28 22:18:23

In a Kubernetes environment, applications operate across multiple nodes within a cluster, and application services can be distributed across multiple clusters and multiple clouds, making tracking the health of an application and the infrastructure it depends on quite challenging.

Kubernetes monitoring is the process of gathering metrics from the Kubernetes clusters you operate to identify critical events and ensure that all hardware, software, and applications are operating as expected. Aggregating metrics in a central location will help you understand and protect the health of your entire Kubernetes fleet and the applications and services running on it.

Between the layers of abstraction created by containerization and Kubernetes, and the dynamic nature of applications running in a K8s environment, monitoring everything can be a challenge. Fortunately a number of open source Kubernetes monitoring tools—as well as popular commercial tools—exist to make monitoring easier.

This blog examines some of the available Kubernetes monitoring and Kubernetes logging tools, including Prometheus for monitoring and Grafana for visualization and dashboards. It also explains how Rafay’s Visibility and Monitoring Service enhances your teams’ Kubernetes monitoring ability.

## **Kubernetes Ecosystem Tools for Logging and Monitoring**
There are a variety of popular tools that can enhance your Kubernetes container monitoring efforts. Some of the most common ones include:

- **[Prometheus](https://prometheus.io/docs/introduction/overview/)**: An open-source event monitoring and alerting tool that collects and stores metrics as time series data. Prometheus joined the [Cloud Native Computing Foundation](https://www.cncf.io/) in 2016 as the second hosted project after Kubernetes.

- **[Grafana](https://grafana.com/)**: A fully managed visualization platform for applications and infrastructure that works with monitoring software such as Prometheus. Grafana provides capabilities to collect, store, visualize, and alert on data.

- **[Thanos](https://thanos.io/)**: A metric system that provides a simple and cost-effective way to centralize and scale Prometheus-based monitoring systems.

- **[Elasticsearch](https://www.elastic.co/elasticsearch/)**: A distributed, JSON-based search and analytics engine.

- **[Logstash](https://www.elastic.co/logstash/)**: An open source, server-side data processing pipeline that ingests data from a multitude of sources simultaneously, transforms it, and then sends it to your favorite stash.

- **[Kibana](https://www.elastic.co/kibana/)**: A data visualization and exploration tool used for log and time-series analytics, application monitoring, and operational intelligence use cases.

## **Which Kubernetes Monitoring Tools Should You Choose?**
Many teams use these monitoring and logging tools alone or in combination to create their own solutions and address specific container monitoring and Kubernetes application monitoring needs. One of the most commonly used combinations is Prometheus plus Grafana. Prometheus enables you to gather time-series data from both hardware and software sources, while Grafana lets you visualize the data that Prometheus collects. 

Another popular combination is Elasticsearch plus Logstash plus Kibana, often referred to as ELK stack or [Elastic Stack](https://www.elastic.co/elastic-stack/), and all available through [Elastic](https://www.elastic.co/). While Elastic is itself a for-profit company, these components are free and open source.

Implementing any of the above tools, whether singly or in combination, necessarily creates a certain amount of complexity, especially as your Kubernetes fleet grows to include many clusters—potentially running different K8s distributions in different cloud environments. 

Managing a Prometheus config at scale may become a challenge due to [app onboarding issues, manual configuration requirements, and configuration drift](https://thenewstack.io/3-key-configuration-challenges-for-kubernetes-monitoring-with-prometheus/). While Prometheus and Grafana work well together for individual clusters, in multi-cluster environments you may have to add [Thanos](https://thanos.io/) to your toolset to aggregate data and provide long-term storage and a global view. Still you may face limitations with data retention and HA that cause some to prefer ELK stack.

Because of this complexity, many organizations prefer monitoring as a service using commercial solutions such as Datadog, Cloudwatch, and New Relic. 

## **How Rafay Simplifies Kubernetes Monitoring**
 
The Rafay Visibility and Monitoring Service is a cloud-based service that unifies monitoring, alerting, and visualization for all your Kubernetes clusters and applications, reducing mean time to recovery (MTTR) by up to 60%.

Rafay’s service provides a single pane of glass (SPOG), enabling centralized Kubernetes logging and management for your entire K8s fleet, spanning multi-cluster, multi-cloud, and edge deployments. Contextual, role-based dashboards let your team drill deeper into your K8s environment, providing enterprise-wide insights at  a project, cluster, node, application, pod, or container level. From Rafay dashboards, you can see a wide range of Kubernetes metrics and events including resources consumed, user and access activity, critical alerts, and the overall health of every cluster and application deployed. You can instantly visualize, diagnose, and resolve incidents by interactively drilling down and identifying issues quickly.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/20n93qnbhstrmrmcmabd.png)

The Rafay Controller provides a web-based view of the entire fleet of Kubernetes clusters under management. When the Visibility and Monitoring Service is enabled, Prometheus and related addons are automatically deployed on your clusters, and metrics are automatically scraped and aggregated to a centralized time series database for all clusters. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/57soxloz8e10s5yjmwc5.png)

## **Integrate with the Tools You Rely On**
Rafay integrates with a variety of popular management tools and services including [Amazon Prometheus](https://docs.rafay.co/recipes/monitoring/amazon-prometheus/overview/), [CloudWatch](https://docs.rafay.co/recipes/monitoring/cloudwatch/cloudwatch/), [Datadog](https://docs.rafay.co/recipes/monitoring/datadog/), [Grafana](https://docs.rafay.co/recipes/monitoring/grafana/), [New Relic](https://docs.rafay.co/recipes/monitoring/newrelic/), [Splunk](https://docs.rafay.co/recipes/monitoring/splunk/), and the [Prometheus Operator](https://docs.rafay.co/recipes/monitoring/prometheus_operator/) (for custom Prometheus). If you utilize or plan to use these tools, Rafay can standardize the deployment and config of the necessary components. 

## **Streamline Visibility and Monitoring with Rafay**
To discover how Rafay can help you standardize visibility and monitoring across your entire fleet of K8s clusters, take a closer look at Rafay’s [Visibility and Monitoring Service](https://rafay.co/platform/visibility-monitoring-service/). Rafay’s [Kubernetes Operations Platform](https://rafay.co/platform/kubernetes-operations-platform/) delivers the visibility, monitoring, and other capabilities you need to ensure the success of your multi-cloud, multi-cluster Kubernetes environment.

Ready to find out why so many enterprises and platform teams have partnered with Rafay to streamline Kubernetes operations?  [Sign up for a free trial](https://rafay.co/start/).