Turning Kubernetes (K8s) Alerts into K8s Notifications

Last updated
May 23, 2024
Evan Witmer
Growth Lead

Table of Contents

Get started with Botkube Cloud

What are Kubernetes Alerts?

Kubernetes Alerts are notifications that are sent out when certain conditions are met in a Kubernetes cluster. These conditions can be anything from a pod failing to start up to a resource running out of memory. DevOps teams use Kubernetes Alerts to stay up-to-date on the health of their clusters and to quickly identify and resolve any issues that may arise.

By setting up and monitoring Kubernetes Alerts, DevOps teams can stay up-to-date on the health of their clusters and quickly identify and resolve any issues that may arise. This can help to prevent outages, improve performance, and improve security.

Here are some additional benefits of using Kubernetes Alerts:

  • Reduced downtime: Alerts can help to reduce downtime by notifying DevOps teams of potential problems early on, so that they can be addressed before they cause an outage.
  • Improved performance: Alerts can help to improve performance by identifying and resolving performance issues early on.
  • Improved security: Alerts can help to improve security by identifying and resolving security vulnerabilities early on. It also allows for Role Based Access Control to receive notifications about anything to do with your cluster.

K8s Alert Setup Best Practices

There are a number of different ways to set up and monitor Kubernetes Alerts. One common approach is to use a monitoring tool like Prometheus or ELK. These tools can collect metrics from Kubernetes clusters and alert on any conditions that meet a pre-defined threshold.

Another approach is to use a ChatOps tool like Slack or Discord. These tools can be used to send alerts directly to a chat room where DevOps engineers can see them and take action. Those users familiar with Botkube already know that this is our chosen method for Kubernetes notifications. However, Botkube does not restrict its users to only chat rooms as a method to monitor health and will gladly connect Prometheus Alertmanager into Slack Chats.

Common DevOps K8s Alerting Deployment Stack

As mentioned previously, the most common deployment for Kubernetes-based alerts is Prometheus deployed within the K8s cluster. Prometheus comes with some out-of-the-box monitoring, but it really needs to be set up. This is common with Kubernetes tools, as they offer a lot of functionality but require additional setup to be secure.

Prometheus can be used to monitor a variety of metrics, including CPU and memory usage, network traffic, and errors. By monitoring these metrics, DevOps teams can identify potential problems early on and take action to prevent them from causing outages or other disruptions.

Most DevOps engineers or Platform Engineers who choose Prometheus as their alert generator will add AlertManager to take advantage of the default alerting setup there.

Here are some of the metrics that Prometheus can be used to monitor:

  • CPU usage: This metric tracks how much CPU time is being used by a pod or container.
  • Memory usage: This metric tracks how much memory is being used by a pod or container.
  • Network traffic: This metric tracks the amount of network traffic that is being generated by a pod or container.
  • Errors: This metric tracks the number of errors that are being produced by a pod or container.

Deploying Alerting in Kubernetes

Up until recently, the most convenient way to deploy Prometheus on Kubernetes was to use the Prometheus Operator, but the newest method is within Botkube's new Kubernetes instance building tool that allows drag-and-drop deployment of Kubernetes and popular tools used to manage K8s.

See the screenshot below of a user getting to choose which Kubernetes monitoring tools should be deployed on the instance. This adds a simple drag and drop method for deployment of clusters and all the popular extras everyone adds to K8s.

Using Botkube easy deployment to add Prometheus to a cluster for monitoring systems

In addition to deploying Prometheus and Alert Manager, the instance builder allows for the notifications to show up directly in a group chat! No longer having to set up manual webhooks every time you want to see cluster errors in Slack. Just simply add your group channel in the low-code/no-code Kubernetes Instance builder and the notifications will automatically flow!

Monitoring Notifications & Performing Operations from Slack (The Dream!)

DevOps viewing Kubernetes related alerts in Slack Channel

If the developer has followed the best practices up until this point, they should have Kubernetes monitoring within their clusters with notifications coming out in the form of chat messages in Slack, Teams, or Discord. This will show things like Pod Failing, Restart, or any number of other customizable Kubernetes alerts.

Botkube also allows for operations to be run to fix any K8s alert that comes in based on its AI suggested fix. Simply click the button prompts Botkube gives with its troubleshooting suggestions and our software will run the commands directly in your cluster. No more switching back to Command Line Interfaces! Just run everything in your chat group!

Solving Kubernetes Alerts with AI

Botkube simplifies Kubernetes troubleshooting by letting you interact with error notifications using everyday language. Spot an OOMKilled error in Slack? Simply ask Botkube AI for a definition and solutions, all through natural conversation.

To see this in action, check out the video where our developer advocate, Maria, demonstrates the power of the Botkube AI Assistant.

About Botkube

Botkube is a collaborative troubleshooting tool designed specifically for Kubernetes users. With Botkube, you can seamlessly receive and act on alerts directly within your preferred messaging and collaboration platforms like Slack, Microsoft Teams, Discord, and Mattermost. In addition, Botkube enables you to automate actions based on events, run kubectl and Helm commands, receive recommendations for best practices and much more. Get started with Botkube for free.