31 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
Boris Petersen bbcbeeb385 Introduce omitLookup config flag (#115)
This flag wraps the Label and Annotation lookup to prevent API
throttling

Signed-off-by: Boris Petersen <boris.petersen@dkb.de>
2023-08-04 19:48:46 +03:00
Mustafa Akın 65f6d73cca Merge branch 'migrate-yaml-library-to-expose-config-errors-easier' of https://github.com/Evedel/kubernetes-event-exporter into Evedel-migrate-yaml-library-to-expose-config-errors-easier 2023-07-06 20:30:45 +03:00
Juha Ylitalo da4a97c1e2 Remove redundant returns (#87)
* If ev.Count >= r.MinCount, it will fallthrough to return true

* No need for return at the end of Stdout.Close
2023-07-06 18:35:17 +03:00
Evedel 94ee2b7e03 install goccy/go-yaml 2023-03-19 16:10:21 +11: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
Biriukov Sergei 858089f2dc Add more visibility for dropped events (#37)
* add warn for when event is discarded

* add events discarded metrics

* drop event onUpdate subscription

* rename ThrottlePeriod -> MaxEventAgeSeconds

* update readme to match new name of config var

* add explicit go arch

* gofmt

* add config tests

* revert accidental change to dockerfile

* add tests for event MaxEventAgeSeconds

* add tests for event discarded to onEvent function

* Use custom role with wider read permissions (#2)

* use longer time intervals for more stable tests on slower ci

* fix failing config test
2022-12-19 17:18:47 +03:00
Mustafa Akın f9335bda24 Updated packages, tidied and changed package name from opsgenie to resmoio (#45)
* Updated packages, tidied and changed package name from opsgenie to resmoio

* Handle removal of clusterName from API and leader election api change

* Update Dockerfile Go to 1.19

* Test case for parsing minCount properly for #43

* more extensive test case to also match apiVersion config
2022-12-19 10:45:46 +03:00
Sasaki Motoaki fe3289cbe2 add yaml tag to MinCount (#43)
Will add more tags
2022-12-19 10:29:27 +03:00
Mustafa Akın 8aaaf451a4 Merge branch 'master' of github.com:resmoio/kubernetes-event-exporter 2022-09-15 11:10:45 +03:00
Brian McQueen b79cc20ecd added initial set of prometheus metrics per ticket #4 exposing basic success and error rates (#15) 2022-09-15 11:09:30 +03:00
Mustafa Akın eeef75d3d8 Merge branch 'client-throttle' 2022-09-15 10:42:03 +03:00
lob 3cd9dd2c0d fix: add kubernetes client QPS and Burst config
Signed-off-by: lob <pengyu@pingcap.com>
2021-12-08 22:17:28 +08:00
Brian McQueen 3559ed4c08 added support for optional clusterName via config file, since emitted events need a clustername when multiple clusters are in service 2021-12-01 15:15:47 -08:00
Mustafa Akın 3208b6e37f throttle period fix 2021-11-06 12:45:19 +03:00
Mauger Ophélie 0782a2df63 Add ThrottlePeriod param to give possibility to choose period for evicted event 2021-08-31 17:01:26 +02:00
Ivana Vilimonovic 28bf293b9f add test for label regex 2020-08-14 18:31:31 -04:00
ivana f1c7400493 Fix label matching bug
Use the configured label value as the regex pattern. Currently it is trying to match the value from the config using the object's label as the pattern, which is incorrect. See also the Annotations matching below which is doing it correctly.
2020-08-14 18:07:40 -04:00
Manuel Rüger bd348fbdb4 pkg/exporter/receivers.go: Fix typo in filename 2020-07-02 15:08:39 +02:00
Mustafa Akin 077bb6654c Namespace support to work without cluster scope, fixes #42 2020-06-22 18:28:11 +03:00
Mustafa Akin 1a24caeeeb Log format support, fixes #52 2020-06-22 17:31:01 +03:00
Mustafa Akin 1ff1f121db Test for issue #51 2020-06-22 17:04:25 +03:00
Mustafa Akın b3695e478d Merge pull request #37 from youyongsong/feature/support-leader-election
feature: support leader election
2020-05-02 01:25:27 +03:00
Ameya Joshi 122836c1d0 go fmt 2020-04-20 16:20:00 +05:30
Ameya Joshi 6108bad882 Adding Annotations in Rules 2020-04-20 16:13:52 +05:30
youyongsong 5dca26ee8c feature: support leader election
leader election function is disabled by default, and could be enabled by adding the
following section in `config.yaml`:

```yaml
leaderElection:
  enabled: true
  leaderElectionID: kubernetes-event-exporter  // this field can be omited, default value is kubernetes-event-exporter
```
2020-04-14 19:35:23 +08:00
Marc Demierre 106e78ae0e engine: Implement clean closing of sinks
Before the change, the engine didn't call the `Close()` method of the
sinks. This is needed in some cases, i.e when a sink implementation is
buffered.

This change adds a `Close()` method to the registry that
will signal sinks to exit and wait for all sinks to exit before
returning. This is then used in the engine stop logic.

In the channel-based registry, the closing of all sinks is done in
parallel (using a `sync.WaitGroup`). In the sync registry, sinks are
closed sequentially.

Fixes issue #10
2019-12-15 21:56:37 +01:00
Mustafa Akin 45cf57c7f9 Modified README and fixed minor bugs 2019-12-09 14:09:26 +03:00
Mustafa Akin b78cf2d997 Add Slack, SQS, SNS outputs. Batching skeleton is implemented but not used in sinks 2019-12-01 16:26:31 +03:00
Mustafa Akin c4726c1a72 Opsgenie output is added, some minor fixes 2019-11-21 10:30:33 -08:00
Mustafa Akin 1fc04d5570 Initial commit, working tests 2019-10-29 00:03:31 +03:00