Skip to content

Commit 97a320d

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Export all journal logs"
2 parents 8ca63ac + 59ce1d9 commit 97a320d

3 files changed

Lines changed: 73 additions & 19 deletions

File tree

roles/export-devstack-journal/README.rst

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
Export journal files from devstack services
22

3-
Export the systemd journal for every devstack service in native
4-
journal format as well as text. Also, export a syslog-style file with
5-
kernal and sudo messages.
3+
This performs a number of logging collection services
64

7-
Writes the output to the ``logs/`` subdirectory of
8-
``stage_dir``.
5+
* Export the systemd journal in native format
6+
* For every devstack service, export logs to text in a file named
7+
``screen-*`` to maintain legacy compatability when devstack services
8+
used to run in a screen session and were logged separately.
9+
* Export a syslog-style file with kernel and sudo messages for legacy
10+
compatability.
11+
12+
Writes the output to the ``logs/`` subdirectory of ``stage_dir``.
913

1014
**Role Variables**
1115

roles/export-devstack-journal/tasks/main.yaml

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,49 @@
66
state: directory
77
owner: "{{ ansible_user }}"
88

9-
# TODO: convert this to ansible
10-
- name: Export journal files
9+
- name: Export legacy stack screen log files
1110
become: true
1211
shell:
1312
cmd: |
1413
u=""
1514
name=""
16-
for u in `systemctl list-unit-files | grep devstack | awk '{print $1}'`; do
15+
for u in $(systemctl list-unit-files | grep devstack | awk '{print $1}'); do
1716
name=$(echo $u | sed 's/devstack@/screen-/' | sed 's/\.service//')
1817
journalctl -o short-precise --unit $u | gzip - > {{ stage_dir }}/logs/$name.txt.gz
1918
done
2019
21-
# Export the journal in export format to make it downloadable
22-
# for later searching. It can then be rewritten to a journal native
23-
# format locally using systemd-journal-remote. This makes a class of
24-
# debugging much easier. We don't do the native conversion here as
25-
# some distros do not package that tooling.
26-
journalctl -u 'devstack@*' -o export | \
27-
xz --threads=0 - > {{ stage_dir }}/logs/devstack.journal.xz
28-
29-
# The journal contains everything running under systemd, we'll
30-
# build an old school version of the syslog with just the
31-
# kernel and sudo messages.
20+
- name: Export legacy syslog.txt
21+
become: true
22+
shell:
23+
# The journal contains everything running under systemd, we'll
24+
# build an old school version of the syslog with just the
25+
# kernel and sudo messages.
26+
cmd: |
3227
journalctl \
3328
-t kernel \
3429
-t sudo \
3530
--no-pager \
3631
--since="$(cat {{ devstack_base_dir }}/log-start-timestamp.txt)" \
3732
| gzip - > {{ stage_dir }}/logs/syslog.txt.gz
33+
34+
# TODO: convert this to ansible
35+
# - make a list of the above units
36+
# - iterate the list here
37+
- name: Export journal
38+
become: true
39+
shell:
40+
# Export the journal in export format to make it downloadable
41+
# for later searching. It can then be rewritten to a journal native
42+
# format locally using systemd-journal-remote. This makes a class of
43+
# debugging much easier. We don't do the native conversion here as
44+
# some distros do not package that tooling.
45+
cmd: |
46+
journalctl -o export \
47+
--since="$(cat {{ devstack_base_dir }}/log-start-timestamp.txt)" \
48+
| xz --threads=0 - > {{ stage_dir }}/logs/devstack.journal.xz
49+
50+
- name: Save journal README
51+
become: true
52+
template:
53+
src: devstack.journal.README.txt.j2
54+
dest: '{{ stage_dir }}/logs/devstack.journal.README.txt'
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
Devstack systemd journal
2+
========================
3+
4+
The devstack.journal file is a copy of the systemd journal during the
5+
devstack run.
6+
7+
To use it, you will need to convert it so journalctl can read it
8+
locally. After downloading the file:
9+
10+
$ /lib/systemd/systemd-journal-remote <(xzcat ./devstack.journal.xz) -o output.journal
11+
12+
Note this binary is not in the regular path. On Debian/Ubuntu
13+
platforms, you will need to have the "sytemd-journal-remote" package
14+
installed.
15+
16+
It should result in something like:
17+
18+
Finishing after writing <large number> entries
19+
20+
You can then use journalctl to examine this file. For example, to see
21+
all devstack services try:
22+
23+
$ journalctl --file ./output.journal -u 'devstack@*'
24+
25+
To see just cinder API server logs restrict the match with
26+
27+
$ journalctl --file ./output.journal -u 'devstack@c-api'
28+
29+
There may be many types of logs available in the journal, a command like
30+
31+
$ journalctl --file ./output.journal --output=json-pretty | grep "_SYSTEMD_UNIT" | sort -u
32+
33+
can help you find interesting things to filter on.

0 commit comments

Comments
 (0)