Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,9 @@ import (
)

const (
collectorID = "process-collector"
componentName = "workloadmeta-process"
cacheValidityNoRT = 2 * time.Second
serviceCollectionInterval = 60 * time.Second // TODO: this should be made configurable in the future
collectorID = "process-collector"
componentName = "workloadmeta-process"
cacheValidityNoRT = 2 * time.Second

// Service discovery constants
maxPortCheckTries = 10
Expand Down Expand Up @@ -166,6 +165,10 @@ func (c *collector) isServiceDiscoveryEnabled() bool {
return c.systemProbeConfig.GetBool("discovery.enabled")
}

func (c *collector) getServiceCollectionInterval() time.Duration {
return c.systemProbeConfig.GetDuration("discovery.service_collection_interval")
}

// isLanguageCollectionEnabled returns a boolean indicating if language collection is enabled
func (c *collector) isLanguageCollectionEnabled() bool {
return c.config.GetBool("language_detection.enabled")
Expand All @@ -174,6 +177,7 @@ func (c *collector) isLanguageCollectionEnabled() bool {
// processCollectionIntervalConfig returns the configured collection interval
func (c *collector) processCollectionIntervalConfig() time.Duration {
processCollectionInterval := checks.GetInterval(c.config, checks.ProcessCheckName)
serviceCollectionInterval := c.getServiceCollectionInterval()
// service discovery data will be incorrect/empty if the process collection interval > service collection interval
// therefore, the service collection interval must be the max interval for process collection
if processCollectionInterval > serviceCollectionInterval {
Expand Down Expand Up @@ -213,6 +217,7 @@ func (c *collector) Start(ctx context.Context, store workloadmeta.Component) err
}

if c.isServiceDiscoveryEnabled() {
serviceCollectionInterval := c.getServiceCollectionInterval()
// Initialize service discovery metric
c.metricDiscoveredServices = telemetry.NewGaugeWithOpts(
collectorID,
Expand Down
1 change: 1 addition & 0 deletions pkg/config/setup/system_probe.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ func InitSystemProbeConfig(cfg pkgconfigmodel.Setup) {
cfg.BindEnvAndSetDefault(join(discoveryNS, "network_stats.enabled"), true)
cfg.BindEnvAndSetDefault(join(discoveryNS, "network_stats.period"), "60s")
cfg.BindEnvAndSetDefault(join(discoveryNS, "ignored_command_names"), []string{"chronyd", "cilium-agent", "containerd", "dhclient", "dockerd", "kubelet", "livenessprobe", "local-volume-pr", "sshd", "systemd"})
cfg.BindEnvAndSetDefault(join(discoveryNS, "service_collection_interval"), "60s")

// Fleet policies
cfg.BindEnv("fleet_policies_dir")
Expand Down