Skip to content

Commit

Permalink
[Ingest Manager] Fix refresh of monitoring configuration (elastic#23619)
Browse files Browse the repository at this point in the history
* fix refresh of monitoring beats

* more descriptive comment

* changelog

* newline
  • Loading branch information
michalpristas committed Jan 22, 2021
1 parent 5691b7c commit 8760522
Show file tree
Hide file tree
Showing 5 changed files with 274 additions and 86 deletions.
1 change: 1 addition & 0 deletions x-pack/elastic-agent/CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
- Fix Windows service installation script {pull}20203[20203]
- Fix timeout issue stopping service applications {pull}20256[20256]
- Fix incorrect hash when upgrading agent {pull}22322[22322]
- Fixed nil pointer during unenroll {pull}23609[23609]

==== New features

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package application

import (
"crypto/md5"
"fmt"

"github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/application/info"
Expand All @@ -15,6 +16,7 @@ import (
const (
monitoringName = "FLEET_MONITORING"
programsKey = "programs"
monitoringChecksumKey = "monitoring_checksum"
monitoringKey = "agent.monitoring"
monitoringUseOutputKey = "agent.monitoring.use_output"
monitoringOutputFormatKey = "outputs.%s"
Expand Down Expand Up @@ -74,12 +76,15 @@ func injectMonitoring(agentInfo *info.AgentInfo, outputGroup string, rootAst *tr
}

programList := make([]string, 0, len(programsToRun))
cfgHash := md5.New()
for _, p := range programsToRun {
programList = append(programList, p.Spec.Cmd)
cfgHash.Write(p.Config.Hash())
}
// making program list part of the config
// making program list and their hashes part of the config
// so it will get regenerated with every change
config[programsKey] = programList
config[monitoringChecksumKey] = fmt.Sprintf("%x", cfgHash.Sum(nil))

monitoringProgram.Config, err = transpiler.NewAST(config)
if err != nil {
Expand Down
Loading

0 comments on commit 8760522

Please sign in to comment.