Thanks for getting this started.
Diff comments:
> diff --git a/cloudinit/analyze/README.md b/cloudinit/analyze/README.md
> new file mode 100644
> index 000..e496d74
> --- /dev/null
> +++ b/cloudinit/analyze/README.md
We'll want this in docs/rtd
> @@ -0,0 +1,167 @@
> +Getting Started
> +===
> +
> +You'll need a working LXD setup. If you can lxc launch a machine then you're
> +good to go.
> +
> +1. lxc init ubuntu-daily:yakkety y1
Use xenial here
> +
> +# for now, we need to adjust cloud-init's logging to emit messages in
> +# a more useful format for parsing.
> +#
> +# NOTE: you need mount-image-callback
> +# from https://code.launchpad.net/~smoser/cloud-utils/trunk.mic-lxd
> +2. sudo ./bin/inject-payload.sh lxd:y1
> +
> +# now you can start it
> +3. lxc start y1
> +
We can remove this inject section as it's being integrated now
> +# now you can analyze it:
> +# % bin/cloudinit-analyze --help
> +# usage: cloudinit analyze []
> +#
> +# Subcommands:
> +#blame Print list of executed stages ordered by time to init
> +#dump Print an in-order list of events in JSON format
> +#show Print an in-order list of stages with execution times
> +#
> +# Analyze cloud-init logs and data
> +#
> +# positional arguments:
> +# subcommand subcommand to run
> +#
> +# optional arguments:
> +# -h, --help show this help message and exit
> +
> +# Print boot events, sections ran, unit time and total time, per boot
> +4. lxc exec y1 -- journalctl-cloudinitlog | ./bin/cloudinit analyze show -i -
We'll want to revert this to something like:
lxc file pull y1/var/log/cloud-init.log - | cloud-init analyze show -i -
> +
> +
> +# % $cmd | tail -n 20
> +# |`->config-byobu previously ran @01.48600s +00.0s
> +# Finished stage: (modules-config) 00.03300 seconds
> +#
> +# Starting stage: modules-final
> +# |`->config-rightscale_userdata previously ran @01.92300s +00.0s
> +# |`->config-scripts-vendor previously ran @01.92300s +00.00100s
> +# |`->config-scripts-per-once previously ran @01.92400s +00.0s
> +# |`->config-scripts-per-boot ran successfully @01.92400s +00.00100s
> +# |`->config-scripts-per-instance previously ran @01.92500s +00.0s
> +# |`->config-scripts-user previously ran @01.92500s +00.00100s
> +# |`->config-ssh-authkey-fingerprints previously ran @01.92600s +00.0s
> +# |`->config-keys-to-console previously ran @01.92600s +00.0s
> +# |`->config-phone-home previously ran @01.92700s +00.0s
> +# |`->config-final-message ran successfully @01.92700s +00.00600s
> +# |`->config-power-state-change previously ran @01.93300s +00.0s
> +# Finished stage: (modules-final) 00.01800 seconds
> +#
> +# Total Time: 0.25700 seconds
> +#
> +# 2 boot records analyzed
> +
> +
> +# dump json event stream parsted from cloud-init.log
> +5. lxc exec y1 -- journalctl-cloudinitlog | ./bin/cloudinit-analyze dump -i -
> +
> +# {
> +# "description": "config-power-state-change previously ran",
> +# "event_type": "finish",
> +# "name": "modules-final/config-power-state-change",
> +# "origin": "cloudinit",
> +# "result": "SUCCESS",
> +# "timestamp": 147376.711
> +# },
> +# {
> +# "description": "running modules for final",
> +# "event_type": "finish",
> +# "name": "modules-final",
> +# "origin": "cloudinit",
> +# "result": "SUCCESS",
> +# "timestamp": 147376.713
> +# }
> +# ]
> +
> +
> +# sort events by time length (blame!)
> +6. lxc exec y1 -- journalctl-cloudinitlog | ./bin/cloudinit-analyze blame -i
> -
> +
> +# -- Boot Record 01 --
> +# 00.68700s (modules-config/config-locale)
> +# 00.16800s (init-network/config-ssh)
> +# 00.14600s (modules-config/config-grub-dpkg)
> +# 00.07600s (modules-config/config-apt-configure)
> +# 00.01900s (modules-final/config-keys-to-console)
> +# 00.01900s (init-local/search-NoCloud)
> +# 00.01500s (init-network/config-users-groups)
> +# 00.00500s (modules-final/config-final-message)
> +# 00.00500s (init-network/consume-vendor-data)
> +# 00.00500s (init-network/config-growpart)
> +# 00.00400s (init-network/config-set_hostname)
> +# 00.00400s (init-network/config-resizefs)
> +# 00.00300s (init-network/consume-user-data)
> +# 00.00200s (modules-final/config-ssh-authkey-fingerprints)
> +# 00.00200s (modules-final/config-scripts-per-instance)
> +# 00.00200s (modules-final/config-phone-home)
> +# 00.00200s (modules-config/config-snappy)
> +# 00.00200s (modules-config/confg-mounts)
> +# 00.00200s (modules-config/config-fan)
> +
> +
> +Testing with KVM
> +
> +
> +1. Download the current cloud image
> +
> +%
> https://cloud-images.ubuntu.com/daily/server/yakkety/current/yakkety-server-cloudimg-amd64.img
> +
> +2. Create snapshot image to preserve the original cloud-image.
> +
> +% qemu-img create -b yakkety-server-cloudimg-amd64.img -f qcow2
> test-cloudinit.qcow2
> +
> +3. Inject the cloud-init mod