diff --git a/heartbeat/docs/monitors/monitor-common-options.asciidoc b/heartbeat/docs/monitors/monitor-common-options.asciidoc index 8d14e8adb513..64a0ea17e0b5 100644 --- a/heartbeat/docs/monitors/monitor-common-options.asciidoc +++ b/heartbeat/docs/monitors/monitor-common-options.asciidoc @@ -143,6 +143,19 @@ A list of processors to apply to the data generated by the monitor. See <> for information about specifying processors in your config. +[float] +[[monitor-data-stream]] + +Contains options pertaining to data stream naming, following the conventions followed by [Fleet Data Streams](https://www.elastic.co/guide/en/fleet/current/data-streams.html). By default Heartbeat will +write to a datastream named `heartbeat-VERSION` except in the case of `browser` monitors, which will +always follow the Fleet convention of `type-dataset-namespace`. + + +```yaml +# To enable data streams with the default namespace +data_stream.namespace: default +``` + [float] [[monitor-pipeline]] ===== `pipeline` @@ -156,8 +169,9 @@ input is used. [float] [[monitor-index]] -===== `index` +===== `index` (deprecated) +This setting is now deprecated in favor of the `data_stream` option. If present, this formatted string overrides the index for events from this input (for elasticsearch outputs), or sets the `raw_index` field of the event's metadata (for other outputs). This string can only refer to the agent name and diff --git a/heartbeat/monitors/factory.go b/heartbeat/monitors/factory.go index c2f34d1f7208..5b08387c48f0 100644 --- a/heartbeat/monitors/factory.go +++ b/heartbeat/monitors/factory.go @@ -205,6 +205,15 @@ func preProcessors(info beat.Info, settings publishSettings, monitorType string) // Always set event.dataset procs.AddProcessor(actions.NewAddFields(mapstr.M{"event": mapstr.M{"dataset": dataset}}, true, true)) + // always use synthetics data streams for browser monitors, there is no good reason not to + // the default `heartbeat` data stream won't split out network and screenshot data. + // at some point we should make all monitors use the `synthetics` datastreams and retire + // the heartbeat one, but browser is the only beta one, and it would be a breaking change + // to do so otherwise. + if monitorType == "browser" && settings.DataStream == nil { + settings.DataStream = &add_data_stream.DataStream{} + } + if settings.DataStream != nil { ds := *settings.DataStream if ds.Type == "" { diff --git a/heartbeat/monitors/factory_test.go b/heartbeat/monitors/factory_test.go index 695b07834f57..817c780d847d 100644 --- a/heartbeat/monitors/factory_test.go +++ b/heartbeat/monitors/factory_test.go @@ -48,19 +48,31 @@ func TestPreProcessors(t *testing.T) { wantProc bool wantErr bool }{ - "no settings should yield no processor": { + "no settings should yield no processor for lightweight monitor": { publishSettings{}, "", nil, - "browser", + "http", false, false, }, + "no settings should yield a data stream processor for browsers": { + publishSettings{}, + "synthetics-browser-default", + &add_data_stream.DataStream{ + Namespace: "default", + Dataset: "browser", + Type: "synthetics", + }, + "browser", + true, + false, + }, "exact index should be used exactly": { publishSettings{Index: *fmtstr.MustCompileEvent("test")}, "test", nil, - "browser", + "http", true, false, },