Skip to content

Commit

Permalink
Set beat ID in registries after loading meta file (#12180)
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 21, 2019
1 parent eca4b19 commit da783fe
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 @@ -74,6 +74,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Replace wmi queries with win32 api calls as they were consuming CPU resources {issue}3249[3249] and {issue}11840[11840]
- Fix queue.spool.write.flush.events config type. {pull}12080[12080]
- 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 @@ -168,15 +168,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 @@ -368,6 +366,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 da783fe

Please sign in to comment.