Skip to content

Parse and ship desktop logs #2379

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

Merged
merged 7 commits into from
Jul 28, 2025

Conversation

RebeccaMahany
Copy link
Contributor

Relates to #2342.

This PR updates the log parsing from the launcher watchdog to additionally use it to parse desktop logs. Since we will now set the correct level on the logs instead of always logging them as debug, desktop logs at the info level and above will be shipped to the cloud. This means we'll also be able to take advantage of error reporting functionality for desktop logs.

Log examples

"launcher starting up"

Before:

{
  "time": "2025-07-25T14:43:41.794339Z",
  "level": "DEBUG",
  "source": {
    "function": "github.com/kolide/launcher/ee/desktop/runner.(*DesktopUsersProcessesRunner).processLogs",
    "file": "/Users/runner/work/launcher/launcher/ee/desktop/runner/runner.go",
    "line": 1039
  },
  "msg": "{\"time\":\"2025-07-25T14:43:41.794306Z\",\"level\":\"INFO\",\"msg\":\"launcher starting up\",\"version\":\"1.23.1-16-gf2750aae\",\"revision\":\"f2750aaeeb37e77ad19dd061766a96956cdb836d\"}",
  "component": "desktop_runner",
  "uid": "501",
  "subprocess": "desktop"
}

After:

{
  "time": "2025-07-25T14:38:06.03199Z",
  "level": "INFO",
  "source": {
    "function": "github.com/kolide/launcher/ee/log.LogRawLogRecord",
    "file": "/Users/rebeccamahany-horton/Repos/launcher/ee/log/parser.go",
    "line": 65
  },
  "msg": "launcher starting up",
  "component": "desktop_runner",
  "uid": "501",
  "subprocess": "desktop",
  "original.time": "2025-07-25T14:38:06.03189Z",
  "original.version": "1.23.1-16-gf2750aae-dirty",
  "original.revision": "f2750aaeeb37e77ad19dd061766a96956cdb836d"
}
"starting"

Before:

{
  "time": "2025-07-25T14:43:41.794415Z",
  "level": "DEBUG",
  "source": {
    "function": "github.com/kolide/launcher/ee/desktop/runner.(*DesktopUsersProcessesRunner).processLogs",
    "file": "/Users/runner/work/launcher/launcher/ee/desktop/runner/runner.go",
    "line": 1039
  },
  "msg": "{\"time\":\"2025-07-25T10:43:41.794355-04:00\",\"level\":\"INFO\",\"source\":{\"function\":\"main.runDesktop\",\"file\":\"/Users/runner/work/launcher/launcher/cmd/launcher/desktop.go\",\"line\":109},\"msg\":\"starting\",\"subprocess\":\"desktop\",\"session_pid\":43482,\"uid\":\"501\"}",
  "component": "desktop_runner",
  "uid": "501",
  "subprocess": "desktop"
}

After:

{
  "time": "2025-07-25T14:38:06.032066Z",
  "level": "INFO",
  "source": {
    "function": "github.com/kolide/launcher/ee/log.LogRawLogRecord",
    "file": "/Users/rebeccamahany-horton/Repos/launcher/ee/log/parser.go",
    "line": 65
  },
  "msg": "starting",
  "component": "desktop_runner",
  "uid": "501",
  "subprocess": "desktop",
  "original.session_pid": 42756,
  "original.uid": "501",
  "original.time": "2025-07-25T10:38:06.03194-04:00",
  "original.source": {
    "file": "/Users/rebeccamahany-horton/Repos/launcher/cmd/launcher/desktop.go",
    "function": "main.runDesktop",
    "line": 109
  },
  "original.subprocess": "desktop"
}
"received interrupt error from first actor -- shutting down other actors"

Before:

{
  "time": "2025-07-25T14:43:50.375691Z",
  "level": "DEBUG",
  "source": {
    "function": "github.com/kolide/launcher/ee/desktop/runner.(*DesktopUsersProcessesRunner).processLogs",
    "file": "/Users/runner/work/launcher/launcher/ee/desktop/runner/runner.go",
    "line": 1039
  },
  "msg": "{\"time\":\"2025-07-25T10:43:50.375558-04:00\",\"level\":\"INFO\",\"source\":{\"function\":\"github.com/kolide/launcher/pkg/rungroup.(*Group).Run\",\"file\":\"/Users/runner/work/launcher/launcher/pkg/rungroup/rungroup.go\",\"line\":99},\"msg\":\"received interrupt error from first actor -- shutting down other actors\",\"subprocess\":\"desktop\",\"session_pid\":43482,\"uid\":\"501\",\"component\":\"run_group\",\"err\":null,\"error_source\":\"desktopServerShutdownListener\"}",
  "component": "desktop_runner",
  "uid": "501",
  "subprocess": "desktop"
}

After:

{
  "time": "2025-07-25T14:38:33.808803Z",
  "level": "INFO",
  "source": {
    "function": "github.com/kolide/launcher/ee/log.LogRawLogRecord",
    "file": "/Users/rebeccamahany-horton/Repos/launcher/ee/log/parser.go",
    "line": 65
  },
  "msg": "received interrupt error from first actor -- shutting down other actors",
  "component": "desktop_runner",
  "uid": "501",
  "subprocess": "desktop",
  "original.time": "2025-07-25T10:38:33.808627-04:00",
  "original.source": {
    "file": "/Users/rebeccamahany-horton/Repos/launcher/pkg/rungroup/rungroup.go",
    "function": "github.com/kolide/launcher/pkg/rungroup.(*Group).Run",
    "line": 99
  },
  "original.subprocess": "desktop",
  "original.session_pid": 42756,
  "original.uid": "501",
  "original.component": "run_group",
  "err": null,
  "original.error_source": "desktopServerShutdownListener"
}
"received interrupt"

Before:

{
  "time": "2025-07-25T14:43:50.37596Z",
  "level": "DEBUG",
  "source": {
    "function": "github.com/kolide/launcher/ee/desktop/runner.(*DesktopUsersProcessesRunner).processLogs",
    "file": "/Users/runner/work/launcher/launcher/ee/desktop/runner/runner.go",
    "line": 1039
  },
  "msg": "{\"time\":\"2025-07-25T10:43:50.375873-04:00\",\"level\":\"INFO\",\"source\":{\"function\":\"github.com/kolide/launcher/ee/desktop/user/universallink.(*universalLinkHandler).Interrupt\",\"file\":\"/Users/runner/work/launcher/launcher/ee/desktop/user/universallink/handler_darwin.go\",\"line\":72},\"msg\":\"received interrupt\",\"subprocess\":\"desktop\",\"session_pid\":43482,\"uid\":\"501\",\"component\":\"universal_link_handler\"}",
  "component": "desktop_runner",
  "uid": "501",
  "subprocess": "desktop"
}

After:

{
  "time": "2025-07-25T14:38:33.809034Z",
  "level": "DEBUG",
  "source": {
    "function": "github.com/kolide/launcher/ee/log.LogRawLogRecord",
    "file": "/Users/rebeccamahany-horton/Repos/launcher/ee/log/parser.go",
    "line": 65
  },
  "msg": "received interrupt",
  "component": "desktop_runner",
  "uid": "501",
  "subprocess": "desktop",
  "original.session_pid": 42756,
  "original.uid": "501",
  "original.component": "universal_link_handler",
  "original.time": "2025-07-25T10:38:33.808805-04:00",
  "original.source": {
    "file": "/Users/rebeccamahany-horton/Repos/launcher/ee/desktop/user/universallink/handler_darwin.go",
    "function": "github.com/kolide/launcher/ee/desktop/user/universallink.(*universalLinkHandler).Interrupt",
    "line": 72
  },
  "original.subprocess": "desktop"
}
Desktop logs with manufactured panic
{
  "time": "2025-07-25T14:56:05.363834Z",
  "level": "ERROR",
  "source": {
    "function": "github.com/kolide/launcher/ee/log.LogRawLogRecord",
    "file": "/Users/rebeccamahany-horton/Repos/launcher/ee/log/parser.go",
    "line": 65
  },
  "msg": "panic occurred in goroutine",
  "component": "desktop_runner",
  "uid": "501",
  "subprocess": "desktop",
  "original.component": "run_group",
  "err": "runtime error: index out of range [4] with length 0",
  "original.subprocess": "desktop",
  "original.session_pid": 46329,
  "original.time": "2025-07-25T10:56:05.36361-04:00",
  "original.source": {
    "file": "/Users/rebeccamahany-horton/Repos/launcher/ee/gowrapper/goroutine.go",
    "function": "github.com/kolide/launcher/ee/gowrapper.GoWithRecoveryAction.func1.1",
    "line": 24
  },
  "original.uid": "501",
  "@type": "type.googleapis.com/google.devtools.clouderrorreporting.v1beta1.ReportedErrorEvent",
  "message": "panic occurred in goroutine"
}
{
  "time": "2025-07-25T14:56:05.3641Z",
  "level": "ERROR",
  "source": {
    "function": "github.com/kolide/launcher/ee/log.LogRawLogRecord",
    "file": "/Users/rebeccamahany-horton/Repos/launcher/ee/log/parser.go",
    "line": 65
  },
  "msg": "panic stack trace",
  "component": "desktop_runner",
  "uid": "501",
  "subprocess": "desktop",
  "original.source": {
    "file": "/Users/rebeccamahany-horton/Repos/launcher/ee/gowrapper/goroutine.go",
    "function": "github.com/kolide/launcher/ee/gowrapper.GoWithRecoveryAction.func1.1",
    "line": 29
  },
  "original.subprocess": "desktop",
  "original.uid": "501",
  "stack_trace": "runtime error: index out of range [4] with length 0\ngithub.com/kolide/launcher/ee/gowrapper.GoWithRecoveryAction.func1.1\n\t/Users/rebeccamahany-horton/Repos/launcher/ee/gowrapper/goroutine.go:31\nruntime.gopanic\n\t/opt/homebrew/Cellar/go/1.24.5/libexec/src/runtime/panic.go:792\nruntime.goPanicIndex\n\t/opt/homebrew/Cellar/go/1.24.5/libexec/src/runtime/panic.go:115\nmain.runDesktop.func3\n\t/Users/rebeccamahany-horton/Repos/launcher/cmd/launcher/desktop.go:135\ngithub.com/kolide/launcher/pkg/rungroup.(*Group).Run.func1\n\t/Users/rebeccamahany-horton/Repos/launcher/pkg/rungroup/rungroup.go:76\ngithub.com/kolide/launcher/ee/gowrapper.GoWithRecoveryAction.func1\n\t/Users/rebeccamahany-horton/Repos/launcher/ee/gowrapper/goroutine.go:39\nruntime.goexit\n\t/opt/homebrew/Cellar/go/1.24.5/libexec/src/runtime/asm_arm64.s:1223",
  "original.time": "2025-07-25T10:56:05.363786-04:00",
  "original.session_pid": 46329,
  "original.component": "run_group",
  "@type": "type.googleapis.com/google.devtools.clouderrorreporting.v1beta1.ReportedErrorEvent",
  "message": "panic stack trace"
}

@RebeccaMahany RebeccaMahany added the observability Observability label Jul 25, 2025
@RebeccaMahany RebeccaMahany marked this pull request as ready for review July 25, 2025 16:33
Copy link
Contributor

@zackattack01 zackattack01 left a comment

Choose a reason for hiding this comment

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

🔥

@RebeccaMahany RebeccaMahany added this pull request to the merge queue Jul 28, 2025
Merged via the queue into kolide:main with commit 64bff6c Jul 28, 2025
36 checks passed
@RebeccaMahany RebeccaMahany deleted the becca/ship-desktop-logs branch July 28, 2025 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
observability Observability
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants