Skip to content

Commit

Permalink
[7.1] Set beat ID in registries after loading meta file (#12180) (#12219
Browse files Browse the repository at this point in the history
)

* Reset beat ID in registries in case loaded from meta file

* Set, not reset

* Adding CHANGELOG entry
  • Loading branch information
ycombinator authored May 28, 2019
1 parent 44df636 commit 4f25ee0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ https://github.com/elastic/beats/compare/v7.1.1...7.1[Check the HEAD diff]
*Affecting all Beats*

- Fixed a memory leak when using the add_process_metadata processor under Windows. {pull}12100[12100]
- Fixed Beat ID being reported by GET / API. {pull}12180[12180]

*Auditbeat*

Expand Down
9 changes: 7 additions & 2 deletions libbeat/cmd/instance/beat.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,13 @@ func Run(settings Settings, bt beat.Creator) error {
monitoring.NewString(registry, "version").Set(b.Info.Version)
monitoring.NewString(registry, "beat").Set(b.Info.Beat)
monitoring.NewString(registry, "name").Set(b.Info.Name)
monitoring.NewString(registry, "uuid").Set(b.Info.ID.String())
monitoring.NewString(registry, "hostname").Set(b.Info.Hostname)

// Add additional info to state registry. This is also reported to monitoring
stateRegistry := monitoring.GetNamespace("state").GetRegistry()
serviceRegistry := stateRegistry.NewRegistry("service")
monitoring.NewString(serviceRegistry, "version").Set(b.Info.Version)
monitoring.NewString(serviceRegistry, "name").Set(b.Info.Beat)
monitoring.NewString(serviceRegistry, "id").Set(b.Info.ID.String())
beatRegistry := stateRegistry.NewRegistry("beat")
monitoring.NewString(beatRegistry, "name").Set(b.Info.Name)
monitoring.NewFunc(stateRegistry, "host", host.ReportInfo, monitoring.Report)
Expand Down Expand Up @@ -349,6 +347,13 @@ func (b *Beat) launch(settings Settings, bt beat.Creator) error {
return err
}

// Set Beat ID in registry vars, in case it was loaded from meta file
infoRegistry := monitoring.GetNamespace("info").GetRegistry()
monitoring.NewString(infoRegistry, "uuid").Set(b.Info.ID.String())

serviceRegistry := monitoring.GetNamespace("state").GetRegistry().GetRegistry("service")
monitoring.NewString(serviceRegistry, "id").Set(b.Info.ID.String())

svc.BeforeRun()
defer svc.Cleanup()

Expand Down

0 comments on commit 4f25ee0

Please sign in to comment.