diff --git a/api/handler.go b/api/handler.go index 71b368060c..721f631592 100644 --- a/api/handler.go +++ b/api/handler.go @@ -199,28 +199,27 @@ func getEventRequest(r *http.Request) (*events.Request, bool, error) { query.IncludeSubcontainers = newBool } } - if val, ok := urlMap["oom_events"]; ok { + eventTypes := map[string]info.EventType{ + "oom_events": info.EventOom, + "oom_kill_events": info.EventOomKill, + "creation_events": info.EventContainerCreation, + "deletion_events": info.EventContainerDeletion, + } + allEventTypes := false + if val, ok := urlMap["all_events"]; ok { newBool, err := strconv.ParseBool(val[0]) if err == nil { - query.EventType[info.EventOom] = newBool + allEventTypes = newBool } } - if val, ok := urlMap["oom_kill_events"]; ok { - newBool, err := strconv.ParseBool(val[0]) - if err == nil { - query.EventType[info.EventOomKill] = newBool - } - } - if val, ok := urlMap["creation_events"]; ok { - newBool, err := strconv.ParseBool(val[0]) - if err == nil { - query.EventType[info.EventContainerCreation] = newBool - } - } - if val, ok := urlMap["deletion_events"]; ok { - newBool, err := strconv.ParseBool(val[0]) - if err == nil { - query.EventType[info.EventContainerDeletion] = newBool + for opt, eventType := range eventTypes { + if allEventTypes { + query.EventType[eventType] = true + } else if val, ok := urlMap[opt]; ok { + newBool, err := strconv.ParseBool(val[0]) + if err == nil { + query.EventType[eventType] = newBool + } } } if val, ok := urlMap["max_events"]; ok { diff --git a/docs/api.md b/docs/api.md index 6fe6c0fbbe..9fa45bda34 100644 --- a/docs/api.md +++ b/docs/api.md @@ -29,6 +29,7 @@ The endpoint accepts a certain number of query parameters: | `stream` | Whether to stream new events as they occur. If false returns historical events | false | | `subcontainers` | Whether to also return events for all subcontainers | false | | `max_events` | The max number of events to return (for stream=false) | 10 | +| `all_events` | Whether to include all supported event types | false | | `oom_events` | Whether to include OOM events | false | | `oom_kill_events` | Whether to include OOM kill events | false | | `creation_events` | Whether to include container creation events | false |