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] Fix zip monitors #33723

Merged
merged 11 commits into from
Nov 21, 2022
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ https://github.com/elastic/beats/compare/v8.2.0\...main[Check the HEAD diff]
- Fix Google workspace pagination and document ID generation. {pull}33666[33666]

*Heartbeat*
- Fix broken zip URL monitors. NOTE: Zip URL Monitors will be removed in version 8.7 and replaced with project monitors. {pull}33723[33723]
- Fix bug affecting let's encrypt and other users of cross-signed certs, where cert expiration was incorrectly calculated. {issue}33215[33215]
- Fix broken disable feature for kibana configured monitors. {pull}33293[33293]
- Fix states client support for output options. {pull}33405[33405]
Expand Down
22 changes: 13 additions & 9 deletions x-pack/heartbeat/monitors/browser/synthexec/enrich.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ import (
type enricher func(event *beat.Event, se *SynthEvent) error

type streamEnricher struct {
je *journeyEnricher
sFields stdfields.StdMonitorFields
checkGroup string
je *journeyEnricher
journeyCount int
sFields stdfields.StdMonitorFields
checkGroup string
}

func newStreamEnricher(sFields stdfields.StdMonitorFields) *streamEnricher {
Expand All @@ -39,8 +40,15 @@ func (senr *streamEnricher) enrich(event *beat.Event, se *SynthEvent) error {
senr.je = newJourneyEnricher(senr)
}

eventext.MergeEventFields(event, map[string]interface{}{"monitor": map[string]interface{}{"check_group": senr.checkGroup}})
// TODO: Remove this when zip monitors are removed and we have 1:1 monitor / journey
if se != nil && se.Type == JourneyStart {
senr.journeyCount++
if senr.journeyCount > 1 {
senr.checkGroup = makeUuid()
}
}

eventext.MergeEventFields(event, map[string]interface{}{"monitor": map[string]interface{}{"check_group": senr.checkGroup}})
return senr.je.enrich(event, se)
}

Expand Down Expand Up @@ -153,7 +161,7 @@ func (je *journeyEnricher) enrichSynthEvent(event *beat.Event, se *SynthEvent) e

eventext.MergeEventFields(event, se.ToMap())

if je.urlFields == nil {
if len(je.urlFields) == 0 {
if urlFields, err := event.GetValue("url"); err == nil {
if ufMap, ok := urlFields.(mapstr.M); ok {
je.urlFields = ufMap
Expand Down Expand Up @@ -206,10 +214,6 @@ func (je *journeyEnricher) createSummary(event *beat.Event) error {
if je.journeyComplete {
return je.error
}

// create a new check group for the next journey
je.streamEnricher.checkGroup = makeUuid()

return fmt.Errorf("journey did not finish executing, %d steps ran: %w", je.stepCount, je.error)
}

Expand Down