Published on 00/00/0000
Last updated on 00/00/0000
Published on 00/00/0000
Last updated on 00/00/0000
Share
Share
STRATEGY & INSIGHTS
7 min read
Share
controller manager
creates a replicaset
for that deployment.scheduler
(another controller) assigns nodes to pods.kubelet
(a per node controller) executes the containers.event
in Kubernetes. You can check those events via kubectl
or your preferred GUI or CLI tool.
If you don’t want to filter events you can simply use:
kubectl get events
and the result will be something similar to this:
LAST SEEN TYPE REASON OBJECT SUBOBJECT SOURCE MESSAGE FIRST SEEN COUNT NAME
3m7s Normal LeaderElection configmap/banzaicloud-thanos-operator one-eye-thanos-operator-6467d7bd65-8xb27_01984c3f-b24d-4ebe-8156-d9a321a3a5d5 one-eye-thanos-operator-6467d7bd65-8xb27_01984c3f-b24d-4ebe-8156-d9a321a3a5d5 became leader 3m7s 1 banzaicloud-thanos-operator.16cb552d7b33e74b
3m7s Normal LeaderElection lease/banzaicloud-thanos-operator one-eye-thanos-operator-6467d7bd65-8xb27_01984c3f-b24d-4ebe-8156-d9a321a3a5d5 one-eye-thanos-operator-6467d7bd65-8xb27_01984c3f-b24d-4ebe-8156-d9a321a3a5d5 became leader 3m7s 1 banzaicloud-thanos-operator.16cb552d7b341142
2m39s Normal LeaderElection configmap/banzaicloud-thanos-operator one-eye-thanos-operator-6467d7bd65-8xb27_6b649c1c-1cc3-47cf-ae12-894b19b4ee99 one-eye-thanos-operator-6467d7bd65-8xb27_6b649c1c-1cc3-47cf-ae12-894b19b4ee99 became leader 2m39s 1 banzaicloud-thanos-operator.16cb5533d626f885
2m39s Normal LeaderElection lease/banzaicloud-thanos-operator one-eye-thanos-operator-6467d7bd65-8xb27_6b649c1c-1cc3-47cf-ae12-894b19b4ee99 one-eye-thanos-operator-6467d7bd65-8xb27_6b649c1c-1cc3-47cf-ae12-894b19b4ee99 became leader 2m3
kubectl get event one-eye-thanos-operator.16cb552b0653a67d
apiVersion: v1
count: 1
eventTime: null
firstTimestamp: "2022-01-18T10:02:12Z"
involvedObject:
apiVersion: apps/v1
kind: Deployment
name: one-eye-thanos-operator
namespace: default
resourceVersion: "4521231"
uid: ee22d555-1bdf-4424-a1ea-19a1382c958d
kind: Event
lastTimestamp: "2022-01-18T10:02:12Z"
message:
Scaled up replica set one-eye-thanos-operator-6467d7bd65
to 1
metadata:
creationTimestamp: "2022-01-18T10:02:12Z"
name: one-eye-thanos-operator.16cb552b0653a67d
namespace: default
resourceVersion: "4521234"
selfLink: /api/v1/namespaces/default/events/one-eye-thanos-operator.16cb552b0653a67d
uid: e5cf909c-53c2-4e5e-be4c-af92a956a12c
reason: ScalingReplicaSet
reportingComponent: ""
reportingInstance: ""
source:
component: deployment-controller
type: Normal
As you can see, Kubernetes events are essentially resources similar to deployments
or pods
. They have the same version and metadata fields. However, we have a couple of event-specific fields as well. Let's see the most important ones:
eventTime
The timestamp of an atomic eventfirstTimestamp
The first timestamp of a continuous eventlastTimestamp
The last timestamp of a continuous eventcount
The number of times this event was triggeredmessage
Human readable messagereason
Short description of the eventinvolvedObject
Reference to the Kubernetes resource the event is related tometadata
The event's own metadata including name, uid, etc.source
The source object of the eventtype
Event type like Normal, Warning, and so on.reason
), they can be translated into metrics. A good transformation would be to use the reason
field as metric name and the count
field as value. All the other relevant attributes can be label
s on the metric. From this information you can create a nice overview of what's happening in your cluster. This seems like a good idea and it provides you with an overall health indicator, yet you lose a lot of important information. Time series databases don't handle high cardinality information well. If you need more than aggregated values, like message
and/or the name
field, they become individual time series per event. That does not sound good, does it?
{
"collapse": {
"field": "event.metadata.name.keyword"
},
"query": {
"constant_score": {
"filter": {
"bool": {
"must": [
{
"term": {
"event.involvedObject.apiVersion.keyword": "v1"
}
},
{
"term": {
"event.involvedObject.kind.keyword": "Pod"
}
},
{
"term": {
"event.involvedObject.namespace.keyword": "default"
}
},
{
"term": {
"event.involvedObject.name.keyword": "nginx-558bd4d5db-6v9sc"
}
},
{
"bool": {
"should": [
{
"range": {
"event.eventTime": {
"from": "2022-02-14T01:00:00Z",
"include_lower": true,
"include_upper": true,
"to": null
}
}
},
{
"bool": {
"must": {
"range": {
"event.lastTimestamp": {
"from": "2022-02-14T01:00:00Z",
"include_lower": true,
"include_upper": true,
"to": null
}
}
}
}
}
]
}
}
]
}
}
}
},
"size": 10000,
"sort": [
{
"event.lastTimestamp": {
"missing": "_first",
"order": "desc",
"unmapped_type": "date"
}
},
{
"event.eventTime": {
"missing": "_first",
"order": "desc",
"unmapped_type": "date"
}
}
]
}
As you can see, there's quite a hierarchy of objects to express all these conditions and transformations, but we'll take it clause-by-clause. The collapse
clause is responsible for aggregating events by event name. The query
clause describes the logical combination of different filters. In our case, the first four term
clauses filter the events by involved object, and the last clause defines the time range predicate for both event kinds — events with eventTime
and events with firstTimestamp
and lastTimestamp
. Lastly, the size
clause limits the result set size and the sort
clause specifies an ordering by event timestamp.
And that's it! Not so complicated after all. The results are then represented on a timeline on our correlation view:
one-eye logging install -us
one-eye opensearch install
one-eye event-backend install
And we are ready to browse our Events! In a future post we will show a practical example about logs, metrics and events in the correlation view!Get emerging insights on emerging technology straight to your inbox.
Outshift is leading the way in building an open, interoperable, agent-first, quantum-safe infrastructure for the future of artificial intelligence.
* No email required
The Shift is Outshift’s exclusive newsletter.
Get the latest news and updates on generative AI, quantum computing, and other groundbreaking innovations shaping the future of technology.