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

logging: change log level dynamically #1048

Merged
merged 4 commits into from Jun 12, 2023

Conversation

tixxdz
Copy link
Member

@tixxdz tixxdz commented Jun 2, 2023

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
Copy link

netlify bot commented Jun 2, 2023

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.

Copy link
Contributor

@kkourt kkourt left a comment

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.

cmd/tetragon/main.go Show resolved Hide resolved
docs/content/en/docs/tutorials/debugging-tetragon.md Outdated Show resolved Hide resolved
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
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
21 checks passed
@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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants