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

[Process Agent] Disable console logging when running check --json #11560

Merged
merged 4 commits into from
Apr 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 8 additions & 1 deletion cmd/process-agent/app/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ const loggerName ddconfig.LoggerName = "PROCESS"
var checkOutputJSON = false

func runCheckCmd(cmd *cobra.Command, args []string) error {
// Override the log_to_console setting if `--json` is specified. This way the check command will output proper json.
if checkOutputJSON {
ddconfig.Datadog.Set("log_to_console", false)
}

// We need to load in the system probe environment variables before we load the config, otherwise an
// "Unknown environment variable" warning will show up whenever valid system probe environment variables are defined.
ddconfig.InitSystemProbeConfig(ddconfig.Datadog)
Expand Down Expand Up @@ -137,7 +142,9 @@ func runCheck(cfg *config.AgentConfig, ch checks.Check) error {

time.Sleep(1 * time.Second)

printResultsBanner(ch.Name())
if !checkOutputJSON {
printResultsBanner(ch.Name())
}
just-chillin marked this conversation as resolved.
Show resolved Hide resolved

msgs, err := ch.Run(cfg, 1)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
fixes:
- Adds new `--json` flag to `check`. `process-agent check --json` now outputs valid json.