From 7052140fa8524cdf739af514ff6a45112018d853 Mon Sep 17 00:00:00 2001 From: vigneshshanmugam Date: Wed, 23 Jun 2021 11:28:14 -0700 Subject: [PATCH 1/2] [Heartbeat] add screenshots config to synthetics --- x-pack/heartbeat/monitors/browser/config.go | 4 +++- x-pack/heartbeat/monitors/browser/suite.go | 3 +++ x-pack/heartbeat/monitors/browser/suite_test.go | 10 ++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) 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"}}, From c19512502a29ae6e8b2c15388a815ca2d4c035d0 Mon Sep 17 00:00:00 2001 From: vigneshshanmugam Date: Mon, 28 Jun 2021 09:34:00 -0700 Subject: [PATCH 2/2] docs: update screenshot docs --- .../docs/monitors/monitor-browser.asciidoc | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) 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" +------------------------------------------------------------------------------- +