]> git.openstreetmap.org Git - chef.git/commitdiff
Report details of configured network interfaces to prometheus
authorTom Hughes <tom@compton.nu>
Wed, 23 Sep 2020 21:26:08 +0000 (22:26 +0100)
committerTom Hughes <tom@compton.nu>
Wed, 23 Sep 2020 21:29:15 +0000 (22:29 +0100)
cookbooks/prometheus/recipes/default.rb
cookbooks/prometheus/templates/default/chef.prom.erb [new file with mode: 0644]

index 9df0056be2827d80d0881194246f807212de76d7..71325238a4550843c3f397f59c7a650b036f2f1b 100644 (file)
@@ -71,6 +71,13 @@ directory "/var/lib/prometheus/node-exporter" do
   recursive true
 end
 
+template "/var/lib/prometheus/node-exporter/chef.prom" do
+  source "chef.prom.erb"
+  owner "root"
+  group "root"
+  mode "644"
+end
+
 prometheus_exporter "node" do
   port 9100
   options "--collector.ntp --collector.processes --collector.interrupts --collector.textfile.directory=/var/lib/prometheus/node-exporter"
diff --git a/cookbooks/prometheus/templates/default/chef.prom.erb b/cookbooks/prometheus/templates/default/chef.prom.erb
new file mode 100644 (file)
index 0000000..831a3a5
--- /dev/null
@@ -0,0 +1,5 @@
+# HELP chef_network_interface Information about network interfaces
+# TYPE chef_network_interface gauge
+<% node.interfaces do |interface| -%>
+chef_network_interface{name="<%= interface[:interface] %>",role="<%= interface[:role].to_s %>",family="<%= interface[:family].to_s %>"} 1
+<% end -%>