+ File.write("/srv/www.openstreetmap.org/rails/tmp/statistics.json", statistics.slice(:status, :uri).to_json)
+
+ File.open("/var/lib/prometheus/node-exporter/api.tmp", "w") do |file|
+ file.puts "# HELP api_call_count_total Number of calls by type and status"
+ file.puts "# TYPE api_call_count_total counter"
+
+ statistics[:count].each do |key, value|
+ uri, status = key
+
+ file.puts "api_call_count_total{uri=\"#{uri}\",status=\"#{status}\"} #{value}"
+ end
+
+ file.puts "# HELP api_call_bytes_total Number of bytes returned by type and status"
+ file.puts "# TYPE api_call_bytes_total counter"
+
+ statistics[:bytes].each do |key, value|
+ uri, status = key
+
+ file.puts "api_call_bytes_total{uri=\"#{uri}\",status=\"#{status}\"} #{value}"
+ end
+
+ file.puts "# HELP api_call_seconds_total Number of seconds returned by type and status"
+ file.puts "# TYPE api_call_seconds_total counter"
+
+ statistics[:seconds].each do |key, value|
+ uri, status = key
+
+ file.puts "api_call_seconds_total{uri=\"#{uri}\",status=\"#{status}\"} #{value}"
+ end
+
+ file.puts "# HELP api_call_ssl_total Number of calls by SSL protocol and cipher"
+ file.puts "# TYPE api_call_ssl_total counter"
+
+ statistics[:ssl].each do |key, value|
+ protocol, cipher = key
+
+ file.puts "api_call_ssl_total{protocol=\"#{protocol}\",cipher=\"#{cipher}\"} #{value}"
+ end
+
+ file.puts "# HELP api_call_auth_method_total Number of calls by authentication method"
+ file.puts "# TYPE api_call_auth_method_total counter"
+
+ statistics[:auth].each do |method, value|
+ file.puts "api_call_auth_method_total{method=\"#{method}\"} #{value}"
+ end
+ end
+
+ File.rename("/var/lib/prometheus/node-exporter/api.tmp", "/var/lib/prometheus/node-exporter/api.prom")
+