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

Integrations always running regardless of enabled flag #689

Merged
merged 17 commits into from
Jul 21, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
11 changes: 11 additions & 0 deletions cmd/agent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@ func main() {
if cfg != nil {
cfg.Server.Log = cfgLogger
}
// Iterate over the configurations and remove any that Enabled = false, this works by setting i to the last element
// and then returning the array minus the last element. This loses order but is performant.
for i := 0; i < len(cfg.Integrations.Integrations);{
if !cfg.Integrations.Integrations[i].CommonConfig().Enabled {
cfg.Integrations.Integrations[i] = cfg.Integrations.Integrations[len(cfg.Integrations.Integrations)-1]
cfg.Integrations.Integrations = cfg.Integrations.Integrations[:len(cfg.Integrations.Integrations)-1]
} else {
i++
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you create a new function and call it from integrations.Manager.ApplyConfig instead? Filtering the actual slice here will omit the config from the results of /-/config which might be a little confusing to users.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This got more complicated. When you remove a configuration it did not stop the scraper, so when a configuration is disabled/removed and reload called Agent would list scrape_error = 404. Since the integration had stopped but the scraper was still running.


return cfg, err
}
cfg, err := reloader()
Expand Down
5 changes: 0 additions & 5 deletions pkg/integrations/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,6 @@ func (m *Manager) ApplyConfig(cfg ManagerConfig) error {
shouldCollect = *common.ScrapeIntegration
}

// If Enabled is false then we should override the should collect
if !p.cfg.CommonConfig().Enabled {
shouldCollect = false
}

switch shouldCollect {
case true:
instanceConfig := m.instanceConfigForIntegration(p.cfg, p.i, cfg)
Expand Down