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

Cherry-pick #23619 to 7.11: Fix refresh of monitoring configuration #23635

Merged
merged 1 commit into from
Jan 26, 2021
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
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