Skip to content

Commit 59a7e35

Browse files
authored
Merge pull request #443 from fluxcd/event-spec
docs: update spec to reflect v1beta1 Event API
2 parents 505345c + de9915e commit 59a7e35

File tree

1 file changed

+43
-56
lines changed

1 file changed

+43
-56
lines changed

docs/spec/v1beta1/event.md

Lines changed: 43 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,62 @@
1-
# Event
2-
3-
The `Event` API defines what information a report of an event issued by a controller should contain.
4-
5-
## Specification
6-
7-
Spec:
8-
9-
```go
10-
type Event struct {
11-
// The object that this event is about.
12-
// +required
13-
InvolvedObject corev1.ObjectReference `json:"involvedObject"`
14-
15-
// Severity type of this event (info, error)
16-
// +required
17-
Severity string `json:"severity"`
18-
19-
// The time at which this event was recorded.
20-
// +required
21-
Timestamp metav1.Time `json:"timestamp"`
22-
23-
// A human-readable description of this event.
24-
// Maximum length 39,000 characters
25-
// +required
26-
Message string `json:"message"`
27-
28-
// A machine understandable string that gives the reason
29-
// for the transition into the object's current status.
30-
// +required
31-
Reason string `json:"reason"`
32-
33-
// Metadata of this event, e.g. apply change set.
34-
// +optional
35-
Metadata map[string]string `json:"metadata,omitempty"`
36-
37-
// Name of the controller that emitted this event, e.g. `source-controller`.
38-
// +required
39-
ReportingController string `json:"reportingController"`
40-
41-
// ID of the controller instance, e.g. `source-controller-xyzf`.
42-
// +optional
43-
ReportingInstance string `json:"reportingInstance,omitempty"`
1+
# Events
2+
3+
The `Event` API defines the structure of the events issued by Flux controllers.
4+
5+
Flux controllers use the [`github.com/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"
4429
}
4530
```
4631

47-
Event severity:
32+
In the above example:
4833

49-
```go
50-
const (
51-
EventSeverityInfo string = "info"
52-
EventSeverityError string = "error"
53-
)
54-
```
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](alert.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
5542

56-
Controller implementations can use the [fluxcd/pkg/runtime/events](https://github.com/fluxcd/pkg/tree/main/runtime/events)
57-
package to push events to notification-controller API.
43+
The Go type defining the event structure can be found in the
44+
[`github.com/fluxcd/pkg/apis/event/v1beta1`](https://github.com/fluxcd/pkg/blob/main/apis/event/v1beta1/event.go)
45+
package.
5846

5947
## Rate limiting
6048

6149
Events received by notification-controller are subject to rate limiting to reduce the
6250
amount of duplicate alerts sent to external systems like Slack, Sentry, etc.
6351

64-
Events are rate limited based on `InvolvedObject.Name`, `InvolvedObject.Namespace`,
65-
`InvolvedObject.Kind`, `Message`, and `Metadata.revision`.
52+
Events are rate limited based on `.involvedObject.name`, `.involvedObject.namespace`,
53+
`.involvedObject.kind`, `.message`, and `.metadata`.
6654
The interval of the rate limit is set by default to `5m` but can be configured
67-
with the `--rate-limit-interval` option.
55+
with the `--rate-limit-interval` controller flag.
6856

6957
The event server exposes HTTP request metrics to track the amount of rate limited events.
7058
The following promql will get the rate at which requests are rate limited:
7159

7260
```
7361
rate(gotk_event_http_request_duration_seconds_count{code="429"}[30s])
7462
```
75-

0 commit comments

Comments
 (0)