From 7c2fc54e91ca3809d13cb9fa4b3b1cf8155d6d75 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 7 Sep 2023 17:07:27 +0100 Subject: [PATCH 1/1] Report selected apache configuration options to prometheus --- cookbooks/apache/recipes/default.rb | 7 +++++ .../apache/templates/default/apache.prom.erb | 27 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 cookbooks/apache/templates/default/apache.prom.erb diff --git a/cookbooks/apache/recipes/default.rb b/cookbooks/apache/recipes/default.rb index f47d500b5..4d91da140 100644 --- a/cookbooks/apache/recipes/default.rb +++ b/cookbooks/apache/recipes/default.rb @@ -97,6 +97,13 @@ munin_plugin "apache_accesses" munin_plugin "apache_processes" munin_plugin "apache_volume" +template "/var/lib/prometheus/node-exporter/apache.prom" do + source "apache.prom.erb" + owner "root" + group "root" + mode "644" +end + prometheus_exporter "apache" do port 9117 options "--scrape_uri=http://localhost/server-status?auto" diff --git a/cookbooks/apache/templates/default/apache.prom.erb b/cookbooks/apache/templates/default/apache.prom.erb new file mode 100644 index 000000000..8c0b5b0e9 --- /dev/null +++ b/cookbooks/apache/templates/default/apache.prom.erb @@ -0,0 +1,27 @@ +# HELP apache_server_limit Value of ServerLimit directive +# TYPE apache_server_limit gauge +<% if node[:apache][:mpm] == "prefork" -%> +apache_server_limit{} <%= node[:apache][:prefork][:server_limit] || 256 %> +<% elsif node[:apache][:mpm] == "worker" -%> +apache_server_limit{} <%= node[:apache][:worker][:server_limit] || 16 %> +<% elsif node[:apache][:mpm] == "event" -%> +apache_server_limit{} <%= node[:apache][:event][:server_limit] || 16 %> +<% end -%> +# HELP apache_threads_per_child Value of ThreadsPerChild directive +# TYPE apache_threads_per_child gauge +<% if node[:apache][:mpm] == "prefork" -%> +apache_threads_per_child{} 1 +<% elsif node[:apache][:mpm] == "worker" -%> +apache_threads_per_child{} <%= node[:apache][:worker][:threads_per_child] || 25 %> +<% elsif node[:apache][:mpm] == "event" -%> +apache_threads_per_child{} <%= node[:apache][:event][:threads_per_child] || 25 %> +<% end -%> +# HELP apache_async_request_worker_factor Value of AsyncRequestWorkerFactor directive +# TYPE apache_async_request_worker_factor gauge +<% if node[:apache][:mpm] == "prefork" -%> +apache_async_request_worker_factor{} 0 +<% elsif node[:apache][:mpm] == "worker" -%> +apache_async_request_worker_factor{} 0 +<% elsif node[:apache][:mpm] == "event" -%> +apache_async_request_worker_factor{} <%= node[:apache][:event][:async_request_worker_factor] || 2 %> +<% end -%> -- 2.39.5