Skip to content
Open
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ Main (unreleased)

- `prometheus.exporter.unix`: Add an `arp` config block to configure the ARP collector. (@ptodev)

- Make cAdvisor housekeeping configurable via flags for the `run` command (@into-the-v0id)

### Bugfixes

- Stop `loki.source.kubernetes` discarding log lines with duplicate timestamps. (@ciaranj)
Expand Down
104 changes: 60 additions & 44 deletions internal/alloycli/cmd_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (

"github.com/fatih/color"
"github.com/go-kit/log"
"github.com/google/cadvisor/manager"
"github.com/grafana/ckit/advertise"
"github.com/grafana/ckit/peer"
"github.com/prometheus/client_golang/prometheus"
Expand Down Expand Up @@ -55,20 +56,23 @@ import (

func runCommand() *cobra.Command {
r := &alloyRun{
inMemoryAddr: "alloy.internal:12345",
httpListenAddr: "127.0.0.1:12345",
storagePath: "data-alloy/",
minStability: featuregate.StabilityGenerallyAvailable,
uiPrefix: "/",
disableReporting: false,
enablePprof: true,
configFormat: "alloy",
clusterAdvInterfaces: advertise.DefaultInterfaces,
clusterMaxJoinPeers: 5,
clusterRejoinInterval: 60 * time.Second,
disableSupportBundle: false,
windowsPriority: windowspriority.PriorityNormal,
taskShutdownDeadline: 10 * time.Minute,
inMemoryAddr: "alloy.internal:12345",
httpListenAddr: "127.0.0.1:12345",
storagePath: "data-alloy/",
minStability: featuregate.StabilityGenerallyAvailable,
uiPrefix: "/",
disableReporting: false,
enablePprof: true,
configFormat: "alloy",
clusterAdvInterfaces: advertise.DefaultInterfaces,
clusterMaxJoinPeers: 5,
clusterRejoinInterval: 60 * time.Second,
disableSupportBundle: false,
windowsPriority: windowspriority.PriorityNormal,
taskShutdownDeadline: 10 * time.Minute,
cadvisorHousekeepingInterval: 1 * time.Second,
cadvisorAllowDynamicHousekeeping: true,
cadvisorMaxHousekeepingInterval: 60 * time.Second,
}

cmd := &cobra.Command{
Expand Down Expand Up @@ -168,42 +172,48 @@ depending on the nature of the reload error.
cmd.Flags().StringVar(&r.windowsPriority, "windows.priority", r.windowsPriority, fmt.Sprintf("Process priority to use when running on windows. This flag is currently in public preview. Supported values: %s", strings.Join(slices.Collect(windowspriority.PriorityValues()), ", ")))
}
cmd.Flags().DurationVar(&r.taskShutdownDeadline, "feature.component-shutdown-deadline", r.taskShutdownDeadline, "Maximum duration to wait for a component to shut down before giving up and logging an error")
cmd.Flags().DurationVar(&r.cadvisorHousekeepingInterval, "cadvisor.housekeeping-interval", r.cadvisorHousekeepingInterval, "Interval between cadvisor container housekeepings")
cmd.Flags().BoolVar(&r.cadvisorAllowDynamicHousekeeping, "cadvisor.allow-dynamic-housekeeping", r.cadvisorAllowDynamicHousekeeping, "Whether to allow the cadvisor housekeeping interval to be dynamic")
cmd.Flags().DurationVar(&r.cadvisorMaxHousekeepingInterval, "cadvisor.max-housekeeping-interval", r.cadvisorMaxHousekeepingInterval, "Largest interval to allow between cadvisor container housekeepings")

addDeprecatedFlags(cmd)
return cmd
}

type alloyRun struct {
inMemoryAddr string
httpListenAddr string
storagePath string
minStability featuregate.Stability
uiPrefix string
enablePprof bool
disableReporting bool
clusterEnabled bool
clusterNodeName string
clusterAdvAddr string
clusterJoinAddr string
clusterDiscoverPeers string
clusterAdvInterfaces []string
clusterRejoinInterval time.Duration
clusterMaxJoinPeers int
clusterName string
clusterEnableTLS bool
clusterTLSCAPath string
clusterTLSCertPath string
clusterTLSKeyPath string
clusterTLSServerName string
clusterWaitForSize int
clusterWaitTimeout time.Duration
configFormat string
configBypassConversionErrors bool
configExtraArgs string
enableCommunityComps bool
disableSupportBundle bool
windowsPriority string
taskShutdownDeadline time.Duration
inMemoryAddr string
httpListenAddr string
storagePath string
minStability featuregate.Stability
uiPrefix string
enablePprof bool
disableReporting bool
clusterEnabled bool
clusterNodeName string
clusterAdvAddr string
clusterJoinAddr string
clusterDiscoverPeers string
clusterAdvInterfaces []string
clusterRejoinInterval time.Duration
clusterMaxJoinPeers int
clusterName string
clusterEnableTLS bool
clusterTLSCAPath string
clusterTLSCertPath string
clusterTLSKeyPath string
clusterTLSServerName string
clusterWaitForSize int
clusterWaitTimeout time.Duration
configFormat string
configBypassConversionErrors bool
configExtraArgs string
enableCommunityComps bool
disableSupportBundle bool
windowsPriority string
taskShutdownDeadline time.Duration
cadvisorHousekeepingInterval time.Duration
cadvisorAllowDynamicHousekeeping bool
cadvisorMaxHousekeepingInterval time.Duration
}

func (fr *alloyRun) Run(cmd *cobra.Command, configPath string) error {
Expand Down Expand Up @@ -270,6 +280,12 @@ func (fr *alloyRun) Run(cmd *cobra.Command, configPath string) error {
}
}()

manager.HousekeepingInterval = &fr.cadvisorHousekeepingInterval
manager.HousekeepingConfigFlags = manager.HouskeepingConfig{
Interval: &fr.cadvisorMaxHousekeepingInterval,
AllowDynamic: &fr.cadvisorAllowDynamicHousekeeping,
}

// TODO(rfratto): many of the dependencies we import register global metrics,
// even when their code isn't being used. To reduce the number of series
// generated by Alloy, we should switch to a custom registry.
Expand Down