|
| 1 | +# Events |
| 2 | + |
| 3 | +The `Event` API defines the structure of the events issued by Flux controllers. |
| 4 | + |
| 5 | +Flux controllers use the [fluxcd/pkg/runtime/events](https://github.com/fluxcd/pkg/tree/main/runtime/events) |
| 6 | +package to push events to the notification-controller API. |
| 7 | + |
| 8 | +## Example |
| 9 | + |
| 10 | +The following is an example of an event sent by kustomize-controller to report a reconciliation error. |
| 11 | + |
| 12 | +```json |
| 13 | +{ |
| 14 | + "involvedObject": { |
| 15 | + "apiVersion": "kustomize.toolkit.fluxcd.io/v1beta2", |
| 16 | + "kind": "Kustomization", |
| 17 | + "name": "webapp", |
| 18 | + "namespace": "apps", |
| 19 | + "uid": "7d0cdc51-ddcf-4743-b223-83ca5c699632" |
| 20 | + }, |
| 21 | + "metadata": { |
| 22 | + "kustomize.toolkit.fluxcd.io/revision": "main/731f7eaddfb6af01cb2173e18f0f75b0ba780ef1" |
| 23 | + }, |
| 24 | + "severity":"error", |
| 25 | + "reason": "ValidationFailed", |
| 26 | + "message":"service/apps/webapp validation error: spec.type: Unsupported value: Ingress", |
| 27 | + "reportingController":"kustomize-controller", |
| 28 | + "timestamp":"2022-10-28T07:26:19Z" |
| 29 | +} |
| 30 | +``` |
| 31 | + |
| 32 | +In the above example: |
| 33 | + |
| 34 | +- An event is issued by kustomize-controller for a specific object, indicated in the |
| 35 | + `involvedObject` field. |
| 36 | +- The notification-controller receives the event and finds the [alerts](alerts.md) |
| 37 | + that match the `involvedObject` and `severity` values. |
| 38 | +- For all matching alerts, the controller posts the `message` and the source revision |
| 39 | + extracted from `metadata` to the alert provider API. |
| 40 | + |
| 41 | +## Event structure |
| 42 | + |
| 43 | +The Go type that defines the event structure can be found in the |
| 44 | +[fluxcd/pkg/runtime/events](https://github.com/fluxcd/pkg/blob/main/runtime/events/event.go) |
| 45 | +package. |
| 46 | + |
| 47 | +## Rate limiting |
| 48 | + |
| 49 | +Events received by notification-controller are subject to rate limiting to reduce the |
| 50 | +amount of duplicate alerts sent to external systems like Slack, Sentry, etc. |
| 51 | + |
| 52 | +Events are rate limited based on `involvedObject.name`, `involvedObject.namespace`, |
| 53 | +`involvedObject.kind`, `message`, and `metadata`. |
| 54 | +The interval of the rate limit is set by default to `5m` but can be configured |
| 55 | +with the `--rate-limit-interval` controller flag. |
| 56 | + |
| 57 | +The event server exposes HTTP request metrics to track the amount of rate limited events. |
| 58 | +The following promql will get the rate at which requests are rate limited: |
| 59 | + |
| 60 | +``` |
| 61 | +rate(gotk_event_http_request_duration_seconds_count{code="429"}[30s]) |
| 62 | +``` |
0 commit comments