From b869b51a3c53a0344aff9d890edb0d421b40a462 Mon Sep 17 00:00:00 2001 From: Vignesh Shanmugam Date: Mon, 28 Jun 2021 13:30:57 -0700 Subject: [PATCH] [Heartbeat] add screenshots config to synthetics (#26455) * [Heartbeat] add screenshots config to synthetics * docs: update screenshot docs (cherry picked from commit 7ca5909d70808a8d007672468c31ee8c54d58427) --- .../docs/monitors/monitor-browser.asciidoc | 31 ++++++++++++++++++- x-pack/heartbeat/monitors/browser/config.go | 4 ++- x-pack/heartbeat/monitors/browser/suite.go | 3 ++ .../heartbeat/monitors/browser/suite_test.go | 10 ++++++ 4 files changed, 46 insertions(+), 2 deletions(-) diff --git a/heartbeat/docs/monitors/monitor-browser.asciidoc b/heartbeat/docs/monitors/monitor-browser.asciidoc index 69ce06f88ca..ab2e0cb85ff 100644 --- a/heartbeat/docs/monitors/monitor-browser.asciidoc +++ b/heartbeat/docs/monitors/monitor-browser.asciidoc @@ -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. \ No newline at end of file +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" +------------------------------------------------------------------------------- + diff --git a/x-pack/heartbeat/monitors/browser/config.go b/x-pack/heartbeat/monitors/browser/config.go index 0da4eb0a860..3be6af640ac 100644 --- a/x-pack/heartbeat/monitors/browser/config.go +++ b/x-pack/heartbeat/monitors/browser/config.go @@ -13,7 +13,8 @@ import ( func DefaultConfig() *Config { return &Config{ - Sandbox: false, + Sandbox: false, + Screenshots: "on", } } @@ -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"` } diff --git a/x-pack/heartbeat/monitors/browser/suite.go b/x-pack/heartbeat/monitors/browser/suite.go index d265c0a4b3f..5e3d286d460 100644 --- a/x-pack/heartbeat/monitors/browser/suite.go +++ b/x-pack/heartbeat/monitors/browser/suite.go @@ -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 } diff --git a/x-pack/heartbeat/monitors/browser/suite_test.go b/x-pack/heartbeat/monitors/browser/suite_test.go index c583492d39d..54e708c3e07 100644 --- a/x-pack/heartbeat/monitors/browser/suite_test.go +++ b/x-pack/heartbeat/monitors/browser/suite_test.go @@ -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"}},