Merge ~powersj/cloud-init:docs/analyze into cloud-init:master

Proposed by Joshua Powers
Status: Merged
Approved by: Chad Smith
Approved revision: f2d60b63e8e9702b22342cfc4df6966de5d231fd
Merge reported by: Server Team CI bot
Merged at revision: not available
Proposed branch: ~powersj/cloud-init:docs/analyze
Merge into: cloud-init:master
Diff against target: 392 lines (+302/-68)
1 file modified
doc/rtd/topics/analyze.rst (+302/-68)
Reviewer Review Type Date Requested Status
Chad Smith Approve
Server Team CI bot continuous-integration Approve
Review via email: mp+372651@code.launchpad.net

Commit message

docs: added output examples to analyze.rst

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:f2d60b63e8e9702b22342cfc4df6966de5d231fd
https://jenkins.ubuntu.com/server/job/cloud-init-ci/1125/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/1125//rebuild

review: Approve (continuous-integration)
Revision history for this message
Chad Smith (chad.smith) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/doc/rtd/topics/analyze.rst b/doc/rtd/topics/analyze.rst
index 5cf38bd..709131b 100644
--- a/doc/rtd/topics/analyze.rst
+++ b/doc/rtd/topics/analyze.rst
@@ -1,84 +1,318 @@
1*************************1.. _analyze:
2Cloud-init Analyze Module2
3*************************3Analyze
44*******
5Overview5
6========6The analyze subcommand was added to cloud-init in order to help analyze
7The analyze module was added to cloud-init in order to help analyze cloud-init boot time 7cloud-init boot time performance. It is loosely based on systemd-analyze where
8performance. It is loosely based on systemd-analyze where there are 4 main actions: 8there are four subcommands:
9show, blame, dump, and boot.9
1010- blame
11The 'show' action is similar to 'systemd-analyze critical-chain' which prints a list of units, the 11- show
12time they started and how long they took. For cloud-init, we have four stages, and within each stage12- dump
13a number of modules may run depending on configuration. ‘cloudinit-analyze show’ will, for each 13- boot
14boot, print this information and a summary total time, per boot.
15
16The 'blame' action matches 'systemd-analyze blame' where it prints, in descending order,
17the units that took the longest to run. This output is highly useful for examining where cloud-init
18is spending its time during execution.
19
20The 'dump' action simply dumps the cloud-init logs that the analyze module is performing
21the analysis on and returns a list of dictionaries that can be consumed for other reporting needs.
22
23The 'boot' action prints out kernel related timestamps that are not included in any of the
24cloud-init logs. There are three different timestamps that are presented to the user:
25kernel start, kernel finish boot, and cloud-init start. This was added for additional
26clarity into the boot process that cloud-init does not have control over, to aid in debugging of
27performance issues related to cloudinit startup or tracking regression.
2814
29Usage15Usage
30=====16=====
31Using each of the printing formats is as easy as running one of the following bash commands:17
18The analyze command requires one of the four subcommands:
3219
33.. code-block:: shell-session20.. code-block:: shell-session
3421
35 cloud-init analyze show22 $ cloud-init analyze blame
36 cloud-init analyze blame23 $ cloud-init analyze show
37 cloud-init analyze dump24 $ cloud-init analyze dump
38 cloud-init analyze boot25 $ cloud-init analyze boot
26
27Availability
28============
29
30The analyze subcommand is generally available across all distributions with the
31exception of Gentoo and FreeBSD.
32
33Subcommands
34===========
35
36Blame
37-----
38
39The ``blame`` action matches ``systemd-analyze blame`` where it prints, in
40descending order, the units that took the longest to run. This output is
41highly useful for examining where cloud-init is spending its time during
42execution.
43
44.. code-block:: shell-session
45
46 $ cloud-init analyze blame
47 -- Boot Record 01 --
48 00.80300s (init-network/config-growpart)
49 00.64300s (init-network/config-resizefs)
50 00.62100s (init-network/config-ssh)
51 00.57300s (modules-config/config-grub-dpkg)
52 00.40300s (init-local/search-NoCloud)
53 00.38200s (init-network/config-users-groups)
54 00.19800s (modules-config/config-apt-configure)
55 00.03700s (modules-final/config-keys-to-console)
56 00.02100s (init-network/config-update_etc_hosts)
57 00.02100s (init-network/check-cache)
58 00.00800s (modules-final/config-ssh-authkey-fingerprints)
59 00.00800s (init-network/consume-vendor-data)
60 00.00600s (modules-config/config-timezone)
61 00.00500s (modules-final/config-final-message)
62 00.00400s (init-network/consume-user-data)
63 00.00400s (init-network/config-mounts)
64 00.00400s (init-network/config-disk_setup)
65 00.00400s (init-network/config-bootcmd)
66 00.00400s (init-network/activate-datasource)
67 00.00300s (init-network/config-update_hostname)
68 00.00300s (init-network/config-set_hostname)
69 00.00200s (modules-final/config-snappy)
70 00.00200s (init-network/config-rsyslog)
71 00.00200s (init-network/config-ca-certs)
72 00.00200s (init-local/check-cache)
73 00.00100s (modules-final/config-scripts-vendor)
74 00.00100s (modules-final/config-scripts-per-once)
75 00.00100s (modules-final/config-salt-minion)
76 00.00100s (modules-final/config-rightscale_userdata)
77 00.00100s (modules-final/config-phone-home)
78 00.00100s (modules-final/config-package-update-upgrade-install)
79 00.00100s (modules-final/config-fan)
80 00.00100s (modules-config/config-ubuntu-advantage)
81 00.00100s (modules-config/config-ssh-import-id)
82 00.00100s (modules-config/config-snap)
83 00.00100s (modules-config/config-set-passwords)
84 00.00100s (modules-config/config-runcmd)
85 00.00100s (modules-config/config-locale)
86 00.00100s (modules-config/config-byobu)
87 00.00100s (modules-config/config-apt-pipelining)
88 00.00100s (init-network/config-write-files)
89 00.00100s (init-network/config-seed_random)
90 00.00100s (init-network/config-migrator)
91 00.00000s (modules-final/config-ubuntu-drivers)
92 00.00000s (modules-final/config-scripts-user)
93 00.00000s (modules-final/config-scripts-per-instance)
94 00.00000s (modules-final/config-scripts-per-boot)
95 00.00000s (modules-final/config-puppet)
96 00.00000s (modules-final/config-power-state-change)
97 00.00000s (modules-final/config-mcollective)
98 00.00000s (modules-final/config-lxd)
99 00.00000s (modules-final/config-landscape)
100 00.00000s (modules-final/config-chef)
101 00.00000s (modules-config/config-snap_config)
102 00.00000s (modules-config/config-ntp)
103 00.00000s (modules-config/config-emit_upstart)
104 00.00000s (modules-config/config-disable-ec2-metadata)
105 00.00000s (init-network/setup-datasource)
106
107 1 boot records analyzed
108
109Show
110----
111
112The ``show`` action is similar to ``systemd-analyze critical-chain`` which
113prints a list of units, the time they started and how long they took.
114Cloud-init has four stages and within each stage a number of modules may run
115depending on configuration. ``cloudinit-analyze show`` will, for each boot,
116print this information and a summary total time, per boot.
117
118The following is an abbreviated example of the show output:
119
120.. code-block:: shell-session
121
122 $ cloud-init analyze show
123 -- Boot Record 01 --
124 The total time elapsed since completing an event is printed after the "@" character.
125 The time the event takes is printed after the "+" character.
126
127 Starting stage: init-local
128 |``->no cache found @00.01700s +00.00200s
129 |`->found local data from DataSourceNoCloud @00.11000s +00.40300s
130 Finished stage: (init-local) 00.94200 seconds
131
132 Starting stage: init-network
133 |`->restored from cache with run check: DataSourceNoCloud [seed=/dev/sr0][dsmode=net] @04.79500s +00.02100s
134 |`->setting up datasource @04.88900s +00.00000s
135 |`->reading and applying user-data @04.90100s +00.00400s
136 |`->reading and applying vendor-data @04.90500s +00.00800s
137 |`->activating datasource @04.95200s +00.00400s
138 Finished stage: (init-network) 02.72100 seconds
139
140 Starting stage: modules-config
141 |`->config-emit_upstart ran successfully @15.43100s +00.00000s
142 |`->config-snap ran successfully @15.43100s +00.00100s
143 ...
144 |`->config-runcmd ran successfully @16.22300s +00.00100s
145 |`->config-byobu ran successfully @16.23400s +00.00100s
146 Finished stage: (modules-config) 00.83500 seconds
147
148 Starting stage: modules-final
149 |`->config-snappy ran successfully @16.87400s +00.00200s
150 |`->config-package-update-upgrade-install ran successfully @16.87600s +00.00100s
151 ...
152 |`->config-final-message ran successfully @16.93700s +00.00500s
153 |`->config-power-state-change ran successfully @16.94300s +00.00000s
154 Finished stage: (modules-final) 00.10300 seconds
155
156 Total Time: 4.60100 seconds
157
158 1 boot records analyzed
159
160If additional boot records are detected then they are printed out from oldest
161to newest.
162
163Dump
164----
165
166The ``dump`` action simply dumps the cloud-init logs that the analyze module
167is performing the analysis on and returns a list of dictionaries that can be
168consumed for other reporting needs. Each element in the list is a boot entry.
169
170.. code-block:: shell-session
171
172 $ cloud-init analyze dump
173 [
174 {
175 "description": "starting search for local datasources",
176 "event_type": "start",
177 "name": "init-local",
178 "origin": "cloudinit",
179 "timestamp": 1567057578.037
180 },
181 {
182 "description": "attempting to read from cache [check]",
183 "event_type": "start",
184 "name": "init-local/check-cache",
185 "origin": "cloudinit",
186 "timestamp": 1567057578.054
187 },
188 {
189 "description": "no cache found",
190 "event_type": "finish",
191 "name": "init-local/check-cache",
192 "origin": "cloudinit",
193 "result": "SUCCESS",
194 "timestamp": 1567057578.056
195 },
196 {
197 "description": "searching for local data from DataSourceNoCloud",
198 "event_type": "start",
199 "name": "init-local/search-NoCloud",
200 "origin": "cloudinit",
201 "timestamp": 1567057578.147
202 },
203 {
204 "description": "found local data from DataSourceNoCloud",
205 "event_type": "finish",
206 "name": "init-local/search-NoCloud",
207 "origin": "cloudinit",
208 "result": "SUCCESS",
209 "timestamp": 1567057578.55
210 },
211 {
212 "description": "searching for local datasources",
213 "event_type": "finish",
214 "name": "init-local",
215 "origin": "cloudinit",
216 "result": "SUCCESS",
217 "timestamp": 1567057578.979
218 },
219 {
220 "description": "searching for network datasources",
221 "event_type": "start",
222 "name": "init-network",
223 "origin": "cloudinit",
224 "timestamp": 1567057582.814
225 },
226 {
227 "description": "attempting to read from cache [trust]",
228 "event_type": "start",
229 "name": "init-network/check-cache",
230 "origin": "cloudinit",
231 "timestamp": 1567057582.832
232 },
233 ...
234 {
235 "description": "config-power-state-change ran successfully",
236 "event_type": "finish",
237 "name": "modules-final/config-power-state-change",
238 "origin": "cloudinit",
239 "result": "SUCCESS",
240 "timestamp": 1567057594.98
241 },
242 {
243 "description": "running modules for final",
244 "event_type": "finish",
245 "name": "modules-final",
246 "origin": "cloudinit",
247 "result": "SUCCESS",
248 "timestamp": 1567057594.982
249 }
250 ]
251
252
253Boot
254----
255
256The ``boot`` action prints out kernel related timestamps that are not included
257in any of the cloud-init logs. There are three different timestamps that are
258presented to the user:
259
260- kernel start
261- kernel finish boot
262- cloud-init start
263
264This was added for additional clarity into the boot process that cloud-init
265does not have control over, to aid in debugging of performance issues related
266to cloud-init startup, and tracking regression.
267
268.. code-block:: shell-session
269
270 $ cloud-init analyze boot
271 -- Most Recent Boot Record --
272 Kernel Started at: 2019-08-29 01:35:37.753790
273 Kernel ended boot at: 2019-08-29 01:35:38.807407
274 Kernel time to boot (seconds): 1.053617000579834
275 Cloud-init activated by systemd at: 2019-08-29 01:35:43.992460
276 Time between Kernel end boot and Cloud-init activation (seconds): 5.185053110122681
277 Cloud-init start: 2019-08-29 08:35:45.867000
278 successful
279
280Timestamp Gathering
281^^^^^^^^^^^^^^^^^^^
282
283The following boot related timestamps are gathered on demand when cloud-init
284analyze boot runs:
39285
40Cloud-init analyze boot Timestamp Gathering286- Kernel startup gathered from system uptime
41===========================================287- Kernel finishes initialization from systemd
42The following boot related timestamps are gathered on demand when cloud-init analyze boot runs:288 UserSpaceMonotonicTimestamp property
43- Kernel Startup, which is inferred from system uptime289- Cloud-init activation from the property InactiveExitTimestamp of the
44- Kernel Finishes Initialization, which is inferred from systemd UserSpaceMonotonicTimestamp property290 cloud-init local systemd unit
45- Cloud-init activation, which is inferred from the property InactiveExitTimestamp of the cloud-init
46local systemd unit.
47291
48In order to gather the necessary timestamps using systemd, running the commands292In order to gather the necessary timestamps using systemd, running the
293commands below will gather the UserspaceTimestamp and InactiveExitTimestamp:
49294
50.. code-block:: shell-session295.. code-block:: shell-session
51296
52 systemctl show -p UserspaceTimestampMonotonic 297 $ systemctl show -p UserspaceTimestampMonotonic
53 systemctl show cloud-init-local -p InactiveExitTimestampMonotonic298 UserspaceTimestampMonotonic=989279
299 $ systemctl show cloud-init-local -p InactiveExitTimestampMonotonic
300 InactiveExitTimestampMonotonic=4493126
54301
55will gather the UserspaceTimestamp and InactiveExitTimestamp. 302The UserspaceTimestamp tracks when the init system starts, which is used as
56The UserspaceTimestamp tracks when the init system starts, which is used as an indicator of kernel303an indicator of kernel finishing initialization. The InactiveExitTimestamp
57finishing initialization. The InactiveExitTimestamp tracks when a particular systemd unit transitions304tracks when a particular systemd unit transitions from the Inactive to Active
58from the Inactive to Active state, which can be used to mark the beginning of systemd's activation305state, which can be used to mark the beginning of systemd's activation of
59of cloud-init.306cloud-init.
60307
61Currently this only works for distros that use systemd as the init process. We will be expanding308Currently this only works for distros that use systemd as the init process.
62support for other distros in the future and this document will be updated accordingly.309We will be expanding support for other distros in the future and this document
310will be updated accordingly.
63311
64If systemd is not present on the system, dmesg is used to attempt to find an event that logs the312If systemd is not present on the system, dmesg is used to attempt to find an
65beginning of the init system. However, with this method only the first two timestamps are able to be found;313event that logs the beginning of the init system. However, with this method
66dmesg does not monitor userspace processes, so no cloud-init start timestamps are emitted like when314only the first two timestamps are able to be found; dmesg does not monitor
315userspace processes, so no cloud-init start timestamps are emitted like when
67using systemd.316using systemd.
68317
69List of Cloud-init analyze boot supported distros
70=================================================
71- Arch
72- CentOS
73- Debian
74- Fedora
75- OpenSuSE
76- Red Hat Enterprise Linux
77- Ubuntu
78- SUSE Linux Enterprise Server
79- CoreOS
80
81List of Cloud-init analyze boot unsupported distros
82===================================================
83- FreeBSD
84- Gentoo
85\ No newline at end of file318\ No newline at end of file
319.. vi: textwidth=79

Subscribers

People subscribed via source and target branches