158 Commits

Author SHA1 Message Date
Kebree
907ce911f7 enable sha mechanism for kafka authentication (#173)
Co-authored-by: Jean-Baptiste GINTRAND <jean-baptiste.gintrand@forterro.com>
2024-05-14 00:27:38 +03:00
Ronak Nathani
d7ba03a966 Improves leader election so that we don't lose events (#153)
Currently, when a replica loses its leadership, a new leader isn't elected until leaseDuration seconds.
Here, that is 15s. The max time till we get a new leader is leaseDuration (15s) + retryPeriod (2s) = 17s.

This commit updates the shutdown process such that if the leader replica is sent a shutdown signal,
it sleeps for leaseDuration seconds. This allows the leader replica to continue to export events until
a new leader is elected. And a new leader is elected only if lease hasn't been renewed and leaseDuration expires.

In addition to this, leader election now uses the leases object instead of configMaps and leases. The clusterRole
is also updated to allow writing to the leases object.

For use cases where no event loss is tolerable, users should use maxEventAgeSeconds to > 1.
2024-02-23 08:26:06 +03:00
bysph
c1455c01fb fix: support to set kafka version (#146)
Co-authored-by: sph <shepenghui@corp.netease.com>
2023-11-21 16:30:45 +03:00
Branko Toic
ff7498c5cc feat(loki): add support for custom headers (#142)
add custom headers support in Loki sink, and documentation in README

fix: #141
2023-11-18 01:00:56 +03:00
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
tedyage
4df1af5f2b Add Headers into the ElasticsearchConfig. (#131)
Co-authored-by: tian.zhiqiang3 <tian.zhiqiang3@neolink.com>
2023-10-25 14:50:43 +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
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
Kazuki Suda
8b324e8ae0 sink/slack: Use GetString for color (#112)
Signed-off-by: Kazuki Suda <kazuki.suda@gmail.com>
2023-07-23 17:03:08 +03:00
Mustafa Akın
8f201cbbd0 Fixed failed config reading test 2023-07-21 10:20:00 +03:00
Hoshea Jiang
90a96d8721 Support setting the kubeconfig via flag and env variable (#42)
* Support setting the kubeconfig via configuration

* support KUBECONFIG env variable and flag
2023-07-21 10:14:15 +03:00
Mustafa Akın
7ec9b6b842 Revert "fixed kafka sinker initialization failure when the TLS certificate is invalid" (#103) 2023-07-06 21:22:33 +03:00
Mustafa Akın
4ee63104eb Merge branch 'br_kafka_error' of https://github.com/yanmxa/kubernetes-event-exporter into yanmxa-br_kafka_error 2023-07-06 21:17:32 +03:00
Mustafa Akın
ae366454e3 Revert "@timestamp handling from https://github.com/opsgenie/kubernetes-event-exporter/pull/165 (#92)" (#102)
This reverts commit c572daa48a.
2023-07-06 21:15:09 +03:00
Juha Ylitalo
c572daa48a @timestamp handling from https://github.com/opsgenie/kubernetes-event-exporter/pull/165 (#92) 2023-07-06 21:14:15 +03:00
Mustafa Akın
ff36eee2d0 Merge branch 'ineffectual_err' of https://github.com/Yleisradio/kubernetes-event-exporter into Yleisradio-ineffectual_err 2023-07-06 20:34:47 +03:00
Mustafa Akın
3ae9db7c7a Merge branch 'master' of https://github.com/xonvanetta/kubernetes-event-exporter into xonvanetta-master 2023-07-06 20:33:15 +03:00
Navid Shariati
680b4e29e3 add loki receiver (#50)
* add loki output

* update README for loki

---------

Co-authored-by: navid.shariaty <navid.shariaty@snapp.cab>
2023-07-06 20:31:54 +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
Mustafa Akın
34ca68c7fd Merge branch 'teams-rate-limited' of https://github.com/minchao/kubernetes-event-exporter into minchao-teams-rate-limited 2023-07-06 19:41:47 +03:00
Manuel Rüger
811ab9b6c9 go.mod: Update masterminds/sprig to v3 (#72) 2023-07-06 18:38:57 +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
Juha Ylitalo
e1070dc954 "io/ioutil" has been deprecated (#85)
As of Go 1.16, the same functionality is now provided by package io or package os
2023-07-06 18:36:15 +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
minchao
f5bf1eb7dc feat: return an error when teams endpoint responds with http error 429
Improve error handling in the teams sink to return an error when the Teams endpoint responds with HTTP error 429.

see: https://learn.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/connectors-using?tabs=cURL#rate-limiting-for-connectors
2023-05-30 20:36:57 +08:00
Juha Ylitalo
937b37e038 ineffectual assignment to err, if we don't check it 2023-05-19 15:53:34 +03:00
myan
6db2f8a304 Fixed kafka producer initialization failure when the TLS certificate is invalid
Signed-off-by: myan <myan@redhat.com>
2023-05-11 14:46:19 +00:00
Fabian Heib
7db54ff9bc feat: Add GetString to slack sink config
like title,auther and footer
return error from template Parse in GetString
2023-05-02 14:28:59 +02:00
Evedel
7b93286ac5 add setup package to handle errors during yaml parsing 2023-03-19 16:19:22 +11:00
Evedel
94ee2b7e03 install goccy/go-yaml 2023-03-19 16:10:21 +11:00
Romain Poirot
335530564c feat: add dedot option to stdout and pipe sinks (#59) 2023-03-17 10:44:00 +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
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
raffis
1b684b5cb9 fix: allow specify root ca without client/key (#41)
Signed-off-by: Raffael Sahli <raffael.sahli@doodle.com>

Signed-off-by: Raffael Sahli <raffael.sahli@doodle.com>
2022-12-19 10:56:36 +03:00
Kevin Li
a3dc8681df Reuse transport to avoid the unnecessary connections (#31)
* Reuse trasport to avoid uncessary connections

* Fix typo

Co-authored-by: Kanwen Li 🐼 <kanwli@microsoft.com>
Co-authored-by: Mustafa Akın <mustafa@resmo.com>
2022-12-19 10:52:32 +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
Kirill Borodin
60cc0f689b enable DeDot function with firehose sink (#18)
* enable DeDot function with firehose sink

* function fix
2022-09-15 11:08:56 +03:00
Mustafa Akın
eeef75d3d8 Merge branch 'client-throttle' 2022-09-15 10:42:03 +03:00
Mustafa Akın
2bb8c7c357 Merge pull request #3 from fpants/clustername
added support for optional clusterName via config file
2022-07-20 00:21:42 +03:00
Mustafa Akın
5c720d3a4d Remove vendor now, go is better at handling dependencies 2022-07-03 22:40:29 +03:00
Mustafa Akın
a7f6c0fa4a Merge branch 'avoid_error_logging_crd' 2022-07-03 22:04:10 +03:00
Mustafa Akın
62c4f35f3d Merge branch 'xxops/master' 2022-07-03 22:01:43 +03:00
Mustafa Akın
90375e68c2 Merge branch 'webhook-transport-proxy' 2022-07-03 21:58:38 +03:00
Mustafa Akın
970e9a0adb Merge branch 'add-opensearch-sink' 2022-07-03 21:57:59 +03:00
Mustafa Akın
d0f6821543 Merge branch 'fix-timestamp' 2022-07-03 21:54:20 +03:00
lob
8915de4a2b fix: GetTimestampMs handles different event timestamp
Signed-off-by: lob <pengyu@pingcap.com>
2022-04-16 17:59:17 +08:00