Compare commits

..

3 Commits

Author SHA1 Message Date
c5017c7f89 Merge pull request #807 from thaniri/issue-97-add-configurable-collection-intervals
feat: add config flags for collection intervals
2025-06-06 17:16:51 +02:00
613d6ba302 feat: add config flags for collection intervals
The garbage collection interval should never be less than the collection
interval as this results in "gaps" in metrics.

By making these configurations tuneable it allows users to configure
kube-metrics-adapter to suit the needs of their clusters.

An example configuration that solves this issue is:

- --default-collection-interval=30s
- --metrics-ttl=30s
- --garbage-collector-interval=30s
- --metrics-ttl=45s

This ensures metrics are collected every 30 seconds, retained for 45
seconds, and garbage collected every 30 seconds. Resulting in zero
"gaps".

Signed-off-by: Marek Slabicki <mslabicki@demonware.net>
2025-05-22 15:02:13 -07:00
2ed22f04c2 Merge pull request #805 from zalando-incubator/helm/fix-wrong-image-src
helm: fix wrong image as we moved to ghcr
2025-05-20 13:25:11 +02:00

View File

@ -133,6 +133,8 @@ func NewCommandStartAdapterServer(stopCh <-chan struct{}) *cobra.Command {
"disregard failing to create collectors for incompatible HPAs")
flags.DurationVar(&o.MetricsTTL, "metrics-ttl", 15*time.Minute, "TTL for metrics that are stored in in-memory cache.")
flags.DurationVar(&o.GCInterval, "garbage-collector-interval", 10*time.Minute, "Interval to clean up metrics that are stored in in-memory cache.")
flags.DurationVar(&o.CollectionInterval, "default-collection-interval", 60*time.Second, "Default interval used for collecting metrics.")
flags.DurationVar(&o.ResourceUpdateInterval, "resource-update-interval", 30*time.Second, "Interval at which HPA resources get updated.")
flags.BoolVar(&o.ScalingScheduleMetrics, "scaling-schedule", o.ScalingScheduleMetrics, ""+
"whether to enable time-based ScalingSchedule metrics")
flags.DurationVar(&o.DefaultScheduledScalingWindow, "scaling-schedule-default-scaling-window", 10*time.Minute, "Default rampup and rampdown window duration for ScalingSchedules")
@ -391,7 +393,7 @@ func (o AdapterServerOptions) RunCustomMetricsAdapterServer(stopCh <-chan struct
go scheduledScalingController.Run(ctx)
}
hpaProvider := provider.NewHPAProvider(client, 30*time.Second, 1*time.Minute, collectorFactory, o.DisregardIncompatibleHPAs, o.MetricsTTL, o.GCInterval)
hpaProvider := provider.NewHPAProvider(client, o.ResourceUpdateInterval, o.CollectionInterval, collectorFactory, o.DisregardIncompatibleHPAs, o.MetricsTTL, o.GCInterval)
go hpaProvider.Run(ctx)
@ -509,6 +511,10 @@ type AdapterServerOptions struct {
MetricsTTL time.Duration
// Interval to clean up metrics that are stored in in-memory cache
GCInterval time.Duration
// Default interval used for collecting metrics
CollectionInterval time.Duration
// Interval at which HPA resources get updated
ResourceUpdateInterval time.Duration
// Time-based scaling based on the CRDs ScheduleScaling and ClusterScheduleScaling.
ScalingScheduleMetrics bool
// Default ramp-up/ramp-down window duration for scheduled metrics