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

[Heartbeat] add screenshots config to synthetics #26455

Merged
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
31 changes: 30 additions & 1 deletion heartbeat/docs/monitors/monitor-browser.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,33 @@ Set this option to `true` to enable the normally disabled chromium sandbox. Defa
[[monitor-browser-synthetics-args]]
==== `synthetics_args`

Extra arguments to pass to the synthetics agent package. Takes a list of strings.
Extra arguments to pass to the synthetics agent package. Takes a list of
strings.

[float]
[[monitor-browser-screenshots]]
==== `screenshots`

Set this option to manage the screenshots captured by the synthetics agent.

Under `screenshots`, specify one of these options:

*`on`*:: capture screenshots for all steps in a journey (default)
*`off`*:: do not capture any screenshots
*`only-on-failure`*:: capture screenshots for all steps when a journey fails
(any failing step marks the whole journey as failed)

Example configuration:

[source,yaml]
-------------------------------------------------------------------------------
- type: browser
id: local-journeys
name: Local journeys
schedule: '@every 1m'
screenshots: "on"
source:
local:
path: "/path/to/synthetics/journeys"
-------------------------------------------------------------------------------

4 changes: 3 additions & 1 deletion x-pack/heartbeat/monitors/browser/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import (

func DefaultConfig() *Config {
return &Config{
Sandbox: false,
Sandbox: false,
Screenshots: "on",
}
}

Expand All @@ -27,6 +28,7 @@ type Config struct {
// Id is optional for lightweight checks but required for browsers
Id string `config:"id"`
Sandbox bool `config:"sandbox"`
Screenshots string `config:"screenshots"`
SyntheticsArgs []string `config:"synthetics_args"`
}

Expand Down
3 changes: 3 additions & 0 deletions x-pack/heartbeat/monitors/browser/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ func (s *Suite) extraArgs() []string {
if s.suiteCfg.Sandbox {
extraArgs = append(extraArgs, "--sandbox")
}
if s.suiteCfg.Screenshots != "" {
extraArgs = append(extraArgs, "--screenshots", s.suiteCfg.Screenshots)
}

return extraArgs
}
Expand Down
10 changes: 10 additions & 0 deletions x-pack/heartbeat/monitors/browser/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,21 @@ func TestExtraArgs(t *testing.T) {
&Config{},
nil,
},
{
"default",
DefaultConfig(),
[]string{"--screenshots", "on"},
},
{
"sandbox",
&Config{Sandbox: true},
[]string{"--sandbox"},
},
{
"screenshots",
&Config{Screenshots: "off"},
[]string{"--screenshots", "off"},
},
{
"capabilities",
&Config{SyntheticsArgs: []string{"--capability", "trace", "ssblocks"}},
Expand Down