Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add docker events --format #26268

Merged
merged 1 commit into from
Sep 19, 2016
Merged

add docker events --format #26268

merged 1 commit into from
Sep 19, 2016

Conversation

AkihiroSuda
Copy link
Member

- What I did
Add docker events --format.

Note that -f is the short form of the existing --filter.
(similar to docker ps)

- How I did it
Please refer to the code

- How to verify it
Example: JSON Lines (aka NDJSON, LDJSON, JSON stream, ...)

$ docker events --format="{{json .}}"
{"status":"create","id":"7129b55274d19b62cbae90561b455403a3784364d4187c42cf1d533dd665b112","from":"alpine","Type":"container","Action":"create","Actor":{"ID":"7129b55274d19b62cbae90561b455403a3784364d4187c42cf1d533dd665b112","Attributes":{"image":"alpine","name":"goofy_yonath"}},"time":1472807143,"timeNano":1472807143011844368}
{"status":"attach","id":"7129b55274d19b62cbae90561b455403a3784364d4187c42cf1d533dd665b112","from":"alpine","Type":"container","Action":"attach","Actor":{"ID":"7129b55274d19b62cbae90561b455403a3784364d4187c42cf1d533dd665b112","Attributes":{"image":"alpine","name":"goofy_yonath"}},"time":1472807143,"timeNano":1472807143012990299}
{"Type":"network","Action":"connect","Actor":{"ID":"c8b01845e3aa17dc3f9026125c44cf0075de8672a086c04ecfa02c6d8b359afa","Attributes":{"container":"7129b55274d19b62cbae90561b455403a3784364d4187c42cf1d533dd665b112","name":"bridge","type":"bridge"}},"time":1472807143,"timeNano":1472807143033449708}
{"status":"start","id":"7129b55274d19b62cbae90561b455403a3784364d4187c42cf1d533dd665b112","from":"alpine","Type":"container","Action":"start","Actor":{"ID":"7129b55274d19b62cbae90561b455403a3784364d4187c42cf1d533dd665b112","Attributes":{"image":"alpine","name":"goofy_yonath"}},"time":1472807143,"timeNano":1472807143208051400}
{"status":"resize","id":"7129b55274d19b62cbae90561b455403a3784364d4187c42cf1d533dd665b112","from":"alpine","Type":"container","Action":"resize","Actor":{"ID":"7129b55274d19b62cbae90561b455403a3784364d4187c42cf1d533dd665b112","Attributes":{"height":"46","image":"alpine","name":"goofy_yonath","width":"174"}},"time":1472807143,"timeNano":1472807143209296139}
{"status":"die","id":"7129b55274d19b62cbae90561b455403a3784364d4187c42cf1d533dd665b112","from":"alpine","Type":"container","Action":"die","Actor":{"ID":"7129b55274d19b62cbae90561b455403a3784364d4187c42cf1d533dd665b112","Attributes":{"exitCode":"0","image":"alpine","name":"goofy_yonath"}},"time":1472807143,"timeNano":1472807143241584111}
{"Type":"network","Action":"disconnect","Actor":{"ID":"c8b01845e3aa17dc3f9026125c44cf0075de8672a086c04ecfa02c6d8b359afa","Attributes":{"container":"7129b55274d19b62cbae90561b455403a3784364d4187c42cf1d533dd665b112","name":"bridge","type":"bridge"}},"time":1472807143,"timeNano":1472807143384316935}
{"status":"destroy","id":"7129b55274d19b62cbae90561b455403a3784364d4187c42cf1d533dd665b112","from":"alpine","Type":"container","Action":"destroy","Actor":{"ID":"7129b55274d19b62cbae90561b455403a3784364d4187c42cf1d533dd665b112","Attributes":{"image":"alpine","name":"goofy_yonath"}},"time":1472807143,"timeNano":1472807143421794702}

automated test:

$ DOCKER_INCREMENTAL_BINARY=1 TESTFLAGS='-check.f DockerSuite.TestEvents' make test-integration-cli 

- Description for the changelog
add docker events --format

- A picture of a cute animal (not mandatory but encouraged)
https://commons.wikimedia.org/wiki/Pygoscelis_adeliae

Signed-off-by: Akihiro Suda [email protected]

@vieux
Copy link
Contributor

vieux commented Sep 6, 2016

interesting, LGTM

@vdemeester
Copy link
Member

Design LGTM too
/cc @icecrime @cpuguy83

@cpuguy83
Copy link
Member

cpuguy83 commented Sep 7, 2016

SGTM

@cpuguy83
Copy link
Member

cpuguy83 commented Sep 7, 2016

Moved to code-review

@cpuguy83
Copy link
Member

cpuguy83 commented Sep 7, 2016

And LGTM

@@ -96,6 +100,20 @@ relative to the current time on the client machine:
If you do not provide the --since option, the command returns only new and/or
live events.

## Format

If the `--format` option is set to `{{json .}}, the events are streamed as valid
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A backtick is missing here 😅

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@vdemeester
Copy link
Member

Code LGTM
/cc @dnephin

@AkihiroSuda on the documentation side, few small comments (misses) — we might want to also show an example with a field in addition the the json one 👼

tmpl, err := makeTemplate(opts.format)
if err != nil {
return cli.StatusError{StatusCode: 64,
Status: "Template parsing error: " + err.Error()}
Copy link
Member

@dnephin dnephin Sep 7, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting looks strange here. I think it should be:

return cli.StatusError{
    StatusCode: 64,
    Status: "Template parsing error: " + err.Error(),
}

and the error should be "Error parsing format: ", since the user is specfying a --format not --template.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@AkihiroSuda AkihiroSuda force-pushed the eventsjsonl branch 2 times, most recently from 6af1049 to 380870c Compare September 9, 2016 02:27
@dnephin
Copy link
Member

dnephin commented Sep 9, 2016

LGTM

@AkihiroSuda
Copy link
Member Author

rebased to upstream
@vieux @vdemeester @cpuguy83 @dnephin

@vdemeester
Copy link
Member

Still code LGTM, moving to doc review and docs LGTM 🐸
/cc @thaJeztah @SvenDowideit


**Format:**

# docker events --format '{{if eq .Type "container"}}Type={{.Type}} Status={{.Status}} ID={{.ID}}{{end}}'
Copy link
Member

@thaJeztah thaJeztah Sep 14, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonder if we should use an example that doesn't use "Type" in the template's condition (using --filter type=container is probably more useful to do that?)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, updated PR

@thaJeztah thaJeztah added this to the 1.13.0 milestone Sep 14, 2016
Signed-off-by: Akihiro Suda <[email protected]>
@thaJeztah
Copy link
Member

docs LGTM

@thaJeztah thaJeztah merged commit bb6fe56 into moby:master Sep 19, 2016
dnephin pushed a commit to dnephin/docker that referenced this pull request Apr 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants