Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,17 @@ to keep the config file clean of secrets.
maxEventAgeSeconds: 60
```

## Ignore event update
if an event occur many times, It will only update the event fields like ```count``` and ```lastTimestamp```.
By default ```kubernetes-event-exporter``` will ignore the eventUpdate and will not sent to the recivers.
If you Don't want to miss every event,you can use trigger ```processUpdateEvent``` to controll whether sent the event to the recivers.
```azure
processUpdateEvent true|false (default false)

true: sent every matching event to the recivers including when the event updated
false: ignore the event updted
```

### Opsgenie

[Opsgenie](https://www.opsgenie.com) is an alerting and on-call management tool. kubernetes-event-exporter can push to
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func main() {
}
}

w := kube.NewEventWatcher(kubecfg, cfg.Namespace, cfg.MaxEventAgeSeconds, metricsStore, onEvent, cfg.OmitLookup)
w := kube.NewEventWatcher(kubecfg, cfg.Namespace, cfg.MaxEventAgeSeconds, cfg.ProcessUpdateEvent, metricsStore, onEvent, cfg.OmitLookup)

ctx, cancel := context.WithCancel(context.Background())
leaderLost := make(chan bool)
Expand Down
1 change: 1 addition & 0 deletions pkg/exporter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type Config struct {
KubeBurst int `yaml:"kubeBurst,omitempty"`
MetricsNamePrefix string `yaml:"metricsNamePrefix,omitempty"`
OmitLookup bool `yaml:"omitLookup,omitempty"`
ProcessUpdateEvent bool `yaml:"processUpdateEvent,omitempty"`
}

func (c *Config) Validate() error {
Expand Down
10 changes: 8 additions & 2 deletions pkg/kube/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ type EventWatcher struct {
fn EventHandler
maxEventAgeSeconds time.Duration
metricsStore *metrics.Store
ProcessUpdateEvent bool
}

func NewEventWatcher(config *rest.Config, namespace string, MaxEventAgeSeconds int64, metricsStore *metrics.Store, fn EventHandler, omitLookup bool) *EventWatcher {
func NewEventWatcher(config *rest.Config, namespace string, MaxEventAgeSeconds int64, ProcessUpdateEvent bool, metricsStore *metrics.Store, fn EventHandler, omitLookup bool) *EventWatcher {
clientset := kubernetes.NewForConfigOrDie(config)
factory := informers.NewSharedInformerFactoryWithOptions(clientset, 0, informers.WithNamespace(namespace))
informer := factory.Core().V1().Events().Informer()
Expand All @@ -41,6 +42,7 @@ func NewEventWatcher(config *rest.Config, namespace string, MaxEventAgeSeconds i
fn: fn,
maxEventAgeSeconds: time.Second * time.Duration(MaxEventAgeSeconds),
metricsStore: metricsStore,
ProcessUpdateEvent: ProcessUpdateEvent,
}

informer.AddEventHandler(watcher)
Expand All @@ -57,7 +59,11 @@ func (e *EventWatcher) OnAdd(obj interface{}) {
}

func (e *EventWatcher) OnUpdate(oldObj, newObj interface{}) {
// Ignore updates
if e.ProcessUpdateEvent {
event := newObj.(*corev1.Event)
e.onEvent(event)
}

}

// Ignore events older than the maxEventAgeSeconds
Expand Down