When dealing with infrastructure or orchestration issues, Kubernetes Events are often very useful. However, by their nature, they are only stored 1h in the cluster and can be a bit painful to read with the command kubectl get events .
On this post i’ll quickly show an easy way to have them in some kind of centralized log/monitoring platform.
Note: this is just one simple way of doing it. There’s plenty of other solutions
Note 2: for the sake of reproductibility, i froze the helm package versions. Of course feel free to use the latest releases, but probably expect some fine tuning from your part
Step 1 - Install a k8s event logger
As stated in the name, we need a simple application that catches k8s events and log them in stdout. There’s plenty of solutions, often implementing by themself the logging to external platform such as OpenSearch.
I prefer to “separate the concerns” as much as possible, so i went with this simple solution :
k8s-event-logger ( Kudos to the devs ! )
Install with Helm
I install it in a namespace named “monitoring” but this can be changed without any impact for the following operations.
Step 2 - Setup Vector for log parsing/forwarding
Vector is, for me, the best replacement for the fluent* family :
VRL remap language, which is (almost) runsafe, and allow to test your remapping
Lot of built-in observability, especially prometheus metrics
Low resources requirements
Lots of included sources/output modules
However, even though in my experience it’s very stable at runtime, keep in mind that Vector is still under development and there’s yet no 1.X release ( at least when at moment of writing ), so use it at your own risks !
Configuring Vector to output into OpenSearch
We’ll install vector with helm too.
In this example, i’ll use OpenSearch as an output database. Here is a simple, documented, values.yaml file for that :
Then you can run :
Step 3 - Visualizing in Grafana
Grafana offers a nice panel of visualization and very good integration with OpenSearch.
Here is a simple example panel, created in Grafana 10 :
This very simple dashboards allows you to easily read and filter the kubernetes events
I hope this small article will make your k8s monitoring easier !