5 Commits
Author SHA1 Message Date
Ronak Nathani f48d5bf9ba Add owner references to EnhancedEvent, consolidate calls to apiserver, make cache size configurable and add metrics for reads (#144)
* Adds ownerReferences to the exported events

This commit uses the same approach as labels and annotations and adds ownerReferences to the EnhancedEvent struct.
The flow is as follows:
* use an LRU cache to store the ownerReferences with object UID as the key
* if the object doesn't exist in cache, look up using dynamic client and store it in cache
* if the object exists in cache, return the value from cache

* Reduce the number of GetObject calls by using a single cache to store all labels, annotations and ownerReferences

Currently, every time there's an event, the events exporter runs GetObject for metadata like labels and annotations
independently. This results in the same object being looked up multiple times for different pieces of the metadata.
These number of calls grow as we want to look up additional information about the object like ownerReferences.
So, in this change, a struct called `ObjectMetadata` is created to capture all the pieces of information that need to be added
to the EnhancedEvent. And every time there's an event, the object is fetched from the kube-apiserver if it's not in the cache already
and all pieces of metadata require only 1 call. The metadata is cached so repeated events about the same object don't
result in more calls.

Additionally, UID + ResourceVersion is used the cacheKey so if the object changes, it's looked up again.

One more change here is introduction of a `deleted` field in the `EnhancedEvent.InvolvedObject` to capture whether the object
is deleted. This helps receivers identify whether a resource is deleted and create rules for it when needed.

Tests are added for these updates and the mock functions are moved to the test files.

* Make the cache size configurable

* Add metrics for number of reads served from cache and kube-apiserver respectively

* Add `deleted` field to the involvedObject in EnhancedEvent to identify whether the resource is being deleted
2023-11-18 01:00:27 +03:00
t3mi b892cb20df feat: add build_info metric (#121)
Signed-off-by: t3mi <t3mi@users.noreply.github.com>
2023-10-25 14:57:39 +03:00
Manuel Rüger 9e7f84ba16 Use exporter-toolkit (#71)
This adds support for TLS configuration on the http metrics endpoint
as well as support for a landing page.
2023-07-27 11:11:31 +03:00
Nicolas Lamirault 64db91f26b New probes and Kubernetes Service resource (#82)
* Add: Healthy and Ready handlers

Signed-off-by: Nicolas Lamirault <nicolas.lamirault@gmail.com>

* Update: new probes

Signed-off-by: Nicolas Lamirault <nicolas.lamirault@gmail.com>

* Add: Service resource

Signed-off-by: Nicolas Lamirault <nicolas.lamirault@gmail.com>

---------

Signed-off-by: Nicolas Lamirault <nicolas.lamirault@gmail.com>
2023-07-06 18:38:01 +03:00
Biriukov Sergei 9aa12cfe43 consolidate metrics code in a single package, add metrics prefix config option (#55) 2023-03-17 09:29:05 +03:00