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

add journalctl launcher logs to flare #1592

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ee/allowedcmd/cmd_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ func Ip(ctx context.Context, arg ...string) (*exec.Cmd, error) {
return validatedCommand(ctx, "/usr/sbin/ip", arg...)
}

func Journalctl(ctx context.Context, arg ...string) (*exec.Cmd, error) {
return validatedCommand(ctx, "/usr/bin/journalctl", arg...)
}

func Loginctl(ctx context.Context, arg ...string) (*exec.Cmd, error) {
return validatedCommand(ctx, "/usr/bin/loginctl", arg...)
}
Expand Down
20 changes: 18 additions & 2 deletions ee/debug/checkups/init_logs_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,24 @@ package checkups
import (
"archive/zip"
"context"
"fmt"

"github.com/kolide/launcher/ee/allowedcmd"
)

func writeInitLogs(_ context.Context, _ *zip.Writer) error {
return nil
func writeInitLogs(ctx context.Context, logZip *zip.Writer) error {
cmd, err := allowedcmd.Journalctl(ctx, "-u", "launcher.kolide-k2.service", "-o", "json")
Copy link
Contributor Author

@James-Pickett James-Pickett Feb 9, 2024

Choose a reason for hiding this comment

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

putting these in JSON format, both for this and for windows, produce very verbose logs due to the extra properties it adds associated with each message ... do we want this?

Copy link
Contributor

Choose a reason for hiding this comment

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

The extra info doesn't seem super useful (except for _PID maybe, but that should be available in a different checkup anyway) -- I think I'd lean toward not including it just to avoid the extra noise?

Copy link
Contributor

Choose a reason for hiding this comment

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

My inkling is not. I think of this as being pretty simple to a quick "tail the log file". But maybe I'll regret saying that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

droped the json conversation and just let it print the default on linux. We could add some output options to make it prettier or more customized, but those options might not be present on all distros

if err != nil {
return fmt.Errorf("creating journalctl command: %w", err)
}

outFile, err := logZip.Create("linux_journalctl_launcher_logs.json")
if err != nil {
return fmt.Errorf("creating linux_journalctl_launcher_logs.json: %w", err)
}

cmd.Stderr = outFile
cmd.Stdout = outFile

return cmd.Run()
}
Loading