Merge pull request #687 from rjnagal/cpu

Add 'all_events' option to the api to report all event types.
This commit is contained in:
Victor Marmol 2015-05-06 10:06:58 -07:00
commit e44420e887
2 changed files with 18 additions and 18 deletions

View File

@ -199,29 +199,28 @@ 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 {
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[info.EventOomKill] = newBool
query.EventType[eventType] = 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
}
}
if val, ok := urlMap["max_events"]; ok {
newInt, err := strconv.Atoi(val[0])

View File

@ -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 |