@@ -145,6 +145,8 @@ type agent struct {
145
145
lastContainerEventTime time.Time
146
146
watchdogRunAt []time.Time
147
147
metricFilter * metricFilter
148
+ promFilter * metricFilter
149
+ mergeMetricFilter * metricFilter
148
150
monitorManager * blackbox.RegisterManager
149
151
rulesManager * rules.Manager
150
152
reloadState ReloadState
@@ -648,7 +650,7 @@ func (a *agent) updateThresholds(ctx context.Context, thresholds map[string]thre
648
650
if err != nil {
649
651
logger .V (2 ).Printf ("An error occurred while running discoveries for updateThresholds: %v" , err )
650
652
} else {
651
- err = a .metricFilter . RebuildDynamicLists ( a . dynamicScrapper , services , a . threshold . GetThresholdMetricNames (), a . rulesManager . MetricNames () )
653
+ err = a .rebuildDynamicMetricAllowDenyList ( services )
652
654
if err != nil {
653
655
logger .V (2 ).Printf ("An error occurred while rebuilding dynamic list for updateThresholds: %v" , err )
654
656
}
@@ -671,6 +673,24 @@ func (a *agent) updateThresholds(ctx context.Context, thresholds map[string]thre
671
673
}
672
674
}
673
675
676
+ func (a * agent ) rebuildDynamicMetricAllowDenyList (services []discovery.Service ) error {
677
+ var errs []error
678
+
679
+ errs = append (
680
+ errs ,
681
+ a .metricFilter .RebuildDynamicLists (a .dynamicScrapper , services , a .threshold .GetThresholdMetricNames (), a .rulesManager .MetricNames ()),
682
+ )
683
+
684
+ errs = append (
685
+ errs ,
686
+ a .promFilter .RebuildDynamicLists (a .dynamicScrapper , services , a .threshold .GetThresholdMetricNames (), a .rulesManager .MetricNames ()),
687
+ )
688
+
689
+ a .mergeMetricFilter .mergeInPlace (a .metricFilter , a .promFilter )
690
+
691
+ return errors .Join (errs ... )
692
+ }
693
+
674
694
// Run will start the agent. It will terminate when sigquit/sigterm/sigint is received.
675
695
func (a * agent ) run (ctx context.Context , sighupChan chan os.Signal ) { //nolint:maintidx
676
696
ctx , cancel := context .WithCancel (ctx )
@@ -800,6 +820,9 @@ func (a *agent) run(ctx context.Context, sighupChan chan os.Signal) { //nolint:m
800
820
logger .Printf ("An error occurred while building the Prometheus metric filter, allow/deny list may be partial: %v" , err )
801
821
}
802
822
823
+ a .promFilter = promFilter
824
+ a .mergeMetricFilter = mergeMetricFilters (a .promFilter , bleemeoFilter )
825
+
803
826
secretInputsGate := gate .New (inputs .MaxParallelSecrets ())
804
827
805
828
a .gathererRegistry , err = registry .New (
@@ -809,7 +832,7 @@ func (a *agent) run(ctx context.Context, sighupChan chan os.Signal) { //nolint:m
809
832
FQDN : fqdn ,
810
833
GloutonPort : strconv .Itoa (a .config .Web .Listener .Port ),
811
834
BlackboxSendScraperID : a .config .Blackbox .ScraperSendUUID ,
812
- Filter : mergeMetricFilters ( promFilter , bleemeoFilter ) ,
835
+ Filter : a . mergeMetricFilter ,
813
836
Queryable : a .store ,
814
837
SecretInputsGate : secretInputsGate ,
815
838
ShutdownDeadline : 15 * time .Second ,
@@ -1943,7 +1966,7 @@ func (a *agent) handleTrigger(ctx context.Context) {
1943
1966
}
1944
1967
}
1945
1968
1946
- err := a .metricFilter . RebuildDynamicLists ( a . dynamicScrapper , services , a . threshold . GetThresholdMetricNames (), a . rulesManager . MetricNames () )
1969
+ err := a .rebuildDynamicMetricAllowDenyList ( services )
1947
1970
if err != nil {
1948
1971
logger .V (2 ).Printf ("Error during dynamic Filter rebuild: %v" , err )
1949
1972
}
0 commit comments