This repository was archived by the owner on Sep 26, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed
Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -90,8 +90,13 @@ def start
9090 super
9191
9292 timer_execute :metric_scraper , @interval , &method ( :scrape_metrics )
93- timer_execute :stats_metric_scraper , @interval , &method ( :scrape_stats_metrics )
9493 timer_execute :cadvisor_metric_scraper , @interval , &method ( :scrape_cadvisor_metrics )
94+ # It is done to optionally fetch from 'stats' for k8s version <1.21
95+ if is_stats_endpoint_available?
96+ timer_execute :stats_metric_scraper , @interval , &method ( :scrape_stats_metrics )
97+ else
98+ log . info "'/stats' endpoint is not available. It has been deprecated since k8s v1.15, disabled since v1.18, and removed in v1.21 and onwards"
99+ end
95100 end
96101
97102 def close
@@ -642,6 +647,20 @@ def scrape_metrics
642647 end
643648 end
644649
650+ def is_stats_endpoint_available?
651+ if @use_rest_client
652+ response_stats = RestClient ::Request . execute request_options_stats
653+ else
654+ @node_names . each do |node |
655+ @node_name = node
656+ response_stats = stats_proxy_api ( node ) . get ( @client . headers )
657+ end
658+ end
659+ true
660+ rescue RestClient ::NotFound
661+ false
662+ end
663+
645664 def scrape_stats_metrics
646665 if @use_rest_client
647666 response_stats = RestClient ::Request . execute request_options_stats
You can’t perform that action at this time.
0 commit comments