From bb846b71a62082dbcbb2cd1defe853934b34347f Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Mon, 8 Aug 2022 13:51:30 +0100 Subject: [PATCH] Increase interval and timeout for statuscake monitoring --- cookbooks/prometheus/recipes/server.rb | 5 +++++ cookbooks/prometheus/resources/exporter.rb | 2 ++ cookbooks/prometheus/templates/default/prometheus.yml.erb | 3 +++ 3 files changed, 10 insertions(+) diff --git a/cookbooks/prometheus/recipes/server.rb b/cookbooks/prometheus/recipes/server.rb index 155608926..18e0bc97c 100644 --- a/cookbooks/prometheus/recipes/server.rb +++ b/cookbooks/prometheus/recipes/server.rb @@ -40,6 +40,8 @@ end prometheus_exporter "statuscake" do port 9595 + scrape_interval "5m" + scrape_timeout "2m" environment "STATUSCAKE_APIKEY" => tokens["statuscake"] end @@ -203,12 +205,14 @@ search(:node, "recipes:prometheus\\:\\:default").sort_by(&:name).each do |client address = exporter[:address] sni = exporter[:sni] scrape_interval = exporter[:scrape_interval] + scrape_timeout = exporter[:scrape_timeout] metric_relabel = exporter[:metric_relabel] || [] else name = key address = exporter sni = nil scrape_interval = nil + scrape_timeout = nil metric_relabel = [] end @@ -218,6 +222,7 @@ search(:node, "recipes:prometheus\\:\\:default").sort_by(&:name).each do |client :sni => sni, :instance => client.name.split(".").first, :scrape_interval => scrape_interval, + :scrape_timeout => scrape_timeout, :metric_relabel => metric_relabel } end diff --git a/cookbooks/prometheus/resources/exporter.rb b/cookbooks/prometheus/resources/exporter.rb index 7ff729211..c978f6c62 100644 --- a/cookbooks/prometheus/resources/exporter.rb +++ b/cookbooks/prometheus/resources/exporter.rb @@ -32,6 +32,7 @@ property :options, :kind_of => [String, Array] property :environment, :kind_of => Hash, :default => {} property :service, :kind_of => String property :scrape_interval, :kind_of => String +property :scrape_timeout, :kind_of => String property :metric_relabel, :kind_of => Array property :register_target, :kind_of => [TrueClass, FalseClass], :default => true @@ -71,6 +72,7 @@ action :create do :name => new_resource.exporter, :address => listen_address, :scrape_interval => new_resource.scrape_interval, + :scrape_timeout => new_resource.scrape_timeout, :metric_relabel => new_resource.metric_relabel } end diff --git a/cookbooks/prometheus/templates/default/prometheus.yml.erb b/cookbooks/prometheus/templates/default/prometheus.yml.erb index 00f3c65df..50a074eb1 100644 --- a/cookbooks/prometheus/templates/default/prometheus.yml.erb +++ b/cookbooks/prometheus/templates/default/prometheus.yml.erb @@ -60,6 +60,9 @@ scrape_configs: <% if targets.first[:scrape_interval] -%> scrape_interval: <%= targets.first[:scrape_interval] %> <% end -%> +<% if targets.first[:scrape_timeout] -%> + scrape_timeout: <%= targets.first[:scrape_timeout] %> +<% end -%> <% if targets.first[:sni] -%> tls_config: server_name: <%= targets.first[:sni] %> -- 2.39.5