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] Always use synthetics data streams for browser #32064

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
2 changes: 2 additions & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ https://github.com/elastic/beats/compare/v8.2.0\...main[Check the HEAD diff]
- Add a new `salesforce` module to collect data from salesforce. {pull}31486[31486]

*Heartbeat*
- Browser monitors (beta) no write to the `synthetics-*` index prefix. {pull}32064[32064]
- Setting a custom index for a given monitor is now deprecated. Streams are preferred. {pull}32064[32064]


*Metricbeat*
Expand Down
17 changes: 16 additions & 1 deletion heartbeat/docs/monitors/monitor-common-options.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,20 @@ A list of processors to apply to the data generated by the monitor.
See <<filtering-and-enhancing-data>> 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`, where the type is always synthetics
unless overriden.


```yaml
# To enable data streams with the default namespace
data_stream.namespace: default
```

[float]
[[monitor-pipeline]]
===== `pipeline`
Expand All @@ -156,8 +170,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
Expand Down
10 changes: 10 additions & 0 deletions heartbeat/monitors/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 == "" {
Expand All @@ -218,6 +227,7 @@ func preProcessors(info beat.Info, settings publishSettings, monitorType string)
}

if !settings.Index.IsEmpty() {
logp.L().Warn("Deprecated use of 'index' setting in heartbeat monitor, use 'data_stream' instead!")
proc, err := indexProcessor(&settings.Index, info)
if err != nil {
return nil, err
Expand Down
18 changes: 15 additions & 3 deletions heartbeat/monitors/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down