Skip to content

logging: change log level dynamically#1048

Merged
tixxdz merged 4 commits into
mainfrom
pr/tixxdz/change-log-level-dynamically
Jun 12, 2023
Merged

logging: change log level dynamically#1048
tixxdz merged 4 commits into
mainfrom
pr/tixxdz/change-log-level-dynamically

Conversation

@tixxdz

@tixxdz tixxdz commented Jun 2, 2023

Copy link
Copy Markdown
Member

Allow to change log level dynamically which is handy for debugging problems.

sudo kill -s SIGRTMIN+20 $(pidof tetragon)
sudo kill -s SIGRTMIN+21 $(pidof tetragon)
sudo kill -s SIGRTMIN+22 $(pidof tetragon)
sudo kill -s SIGRTMIN+22 $(pidof tetragon)

output:
time="2023-06-02T13:14:31+02:00" level=info msg="Listening for events..."
time="2023-06-02T13:14:33+02:00" level=info msg="Received signal SIGRTMIN+20: switching from LogLevel 'info' to 'debug'"
time="2023-06-02T13:14:37+02:00" level=info msg="Received signal SIGRTMIN+21: switching from LogLevel 'debug' to 'trace'"
time="2023-06-02T13:14:40+02:00" level=trace msg="process_exec: no container ID due to cgroup name not being a compatible ID, ignoring." cgroup.id=13750 cgroup.name=vte-spawn-5c6c92b1-0631-48d7-855c-bc00f4b70255.scope process.binary=/usr/bin/pidof process.exec_id="OjE2MDExMDU5NDY0NzgxOjEzODMzOQ=="
time="2023-06-02T13:14:40+02:00" level=trace msg="process_exec: no container ID due to cgroup name not being a compatible ID, ignoring." cgroup.id=13750 cgroup.name=vte-spawn-5c6c92b1-0631-48d7-855c-bc00f4b70255.scope process.binary=/usr/bin/sudo process.exec_id="OjE2MDExMDgxNzM4MTE2OjEzODM0MA=="
time="2023-06-02T13:14:40+02:00" level=trace msg="process_exec: no container ID due to cgroup name not being a compatible ID, ignoring." cgroup.id=13750 cgroup.name=vte-spawn-5c6c92b1-0631-48d7-855c-bc00f4b70255.scope process.binary=/usr/bin/kill process.exec_id="OjE2MDExMTAxMjU2NTU4OjEzODM0Mg=="
time="2023-06-02T13:14:40+02:00" level=info msg="Received signal SIGRTMIN+22: resetting original LogLevel 'info'"
time="2023-06-02T13:14:42+02:00" level=info msg="Received signal SIGRTMIN+22: resetting original LogLevel 'info'"

@tixxdz
tixxdz requested a review from a team as a code owner June 2, 2023 11:02
@tixxdz
tixxdz requested a review from olsajiri June 2, 2023 11:02
@tixxdz
tixxdz marked this pull request as draft June 2, 2023 11:02
@tixxdz
tixxdz marked this pull request as ready for review June 2, 2023 11:20
@netlify

netlify Bot commented Jun 2, 2023

Copy link
Copy Markdown

Deploy Preview for tetragon ready!

Name Link
🔨 Latest commit fbe40e9
🔍 Latest deploy log https://app.netlify.com/sites/tetragon/deploys/6486f2058e097c000836f7e1
😎 Deploy Preview https://deploy-preview-1048--tetragon.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@kkourt kkourt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cool! Thanks!

Just a couple of minor suggestions from my side.

Comment thread cmd/tetragon/main.go
Comment thread docs/content/en/docs/tutorials/debugging-tetragon.md Outdated
tixxdz added 2 commits June 12, 2023 11:34
Allow to change log level dynamically which is handy for debugging
problems.

Set loglevel to debug:

sudo kill -s SIGRTMIN+20 $(pidof tetragon)

time="2023-06-02T12:59:43+02:00" level=info msg="Listening for events..."
time="2023-06-02T12:59:47+02:00" level=info msg="Received signal SIGRTMIN+20: switching from LogLevel 'info' to 'debug'"
time="2023-06-02T12:59:57+02:00" level=info msg="Received signal SIGRTMIN+20: LogLevel is already 'debug'"

Sending the second signal shows up that the loglevel is already debug.

Signed-off-by: Djalal Harouni <tixxdz@gmail.com>
Set loglevel to trace level:

sudo kill -s SIGRTMIN+21 $(pidof tetragon)

time="2023-06-02T13:07:17+02:00" level=info msg="Listening for events..."
time="2023-06-02T13:07:28+02:00" level=info msg="Received signal SIGRTMIN+21: switching from LogLevel 'debug' to 'trace'"

Signed-off-by: Djalal Harouni <tixxdz@gmail.com>
@tixxdz
tixxdz force-pushed the pr/tixxdz/change-log-level-dynamically branch from 558a07a to fbe40e9 Compare June 12, 2023 10:22
tixxdz added 2 commits June 12, 2023 12:25
Allow to reset original log level by sending SIGRTMIN+22 signal to
tetragon.

sudo kill -s SIGRTMIN+20 $(pidof tetragon)
sudo kill -s SIGRTMIN+21 $(pidof tetragon)
sudo kill -s SIGRTMIN+22 $(pidof tetragon)
sudo kill -s SIGRTMIN+22 $(pidof tetragon)

output:
time="2023-06-02T13:14:31+02:00" level=info msg="Listening for events..."
time="2023-06-02T13:14:33+02:00" level=info msg="Received signal SIGRTMIN+20: switching from LogLevel 'info' to 'debug'"
time="2023-06-02T13:14:37+02:00" level=info msg="Received signal SIGRTMIN+21: switching from LogLevel 'debug' to 'trace'"
time="2023-06-02T13:14:40+02:00" level=trace msg="process_exec: no container ID due to cgroup name not being a compatible ID, ignoring." cgroup.id=13750 cgroup.name=vte-spawn-5c6c92b1-0631-48d7-855c-bc00f4b70255.scope process.binary=/usr/bin/pidof process.exec_id="OjE2MDExMDU5NDY0NzgxOjEzODMzOQ=="
time="2023-06-02T13:14:40+02:00" level=trace msg="process_exec: no container ID due to cgroup name not being a compatible ID, ignoring." cgroup.id=13750 cgroup.name=vte-spawn-5c6c92b1-0631-48d7-855c-bc00f4b70255.scope process.binary=/usr/bin/sudo process.exec_id="OjE2MDExMDgxNzM4MTE2OjEzODM0MA=="
time="2023-06-02T13:14:40+02:00" level=trace msg="process_exec: no container ID due to cgroup name not being a compatible ID, ignoring." cgroup.id=13750 cgroup.name=vte-spawn-5c6c92b1-0631-48d7-855c-bc00f4b70255.scope process.binary=/usr/bin/kill process.exec_id="OjE2MDExMTAxMjU2NTU4OjEzODM0Mg=="
time="2023-06-02T13:14:40+02:00" level=info msg="Received signal SIGRTMIN+22: resetting original LogLevel 'info'"
time="2023-06-02T13:14:42+02:00" level=info msg="Received signal SIGRTMIN+22: resetting original LogLevel 'info'"

Signed-off-by: Djalal Harouni <tixxdz@gmail.com>
Signed-off-by: Djalal Harouni <tixxdz@gmail.com>
@tixxdz
tixxdz force-pushed the pr/tixxdz/change-log-level-dynamically branch from fbe40e9 to 0fa55ee Compare June 12, 2023 10:27
@tixxdz
tixxdz merged commit 7017fc3 into main Jun 12, 2023
@tixxdz
tixxdz deleted the pr/tixxdz/change-log-level-dynamically branch June 12, 2023 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants