Merge pull request #687 from rjnagal/cpu
Add 'all_events' option to the api to report all event types.
This commit is contained in:
commit
e44420e887
@ -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 {
|
||||
|
@ -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 |
|
||||
|
Loading…
Reference in New Issue
Block a user