dawarich/app/controllers/metrics_controller.rb
2025-07-26 15:27:22 +02:00

17 lines
460 B
Ruby

# frozen_string_literal: true
class MetricsController < ApplicationController
http_basic_authenticate_with name: METRICS_USERNAME, password: METRICS_PASSWORD, only: :index
def index
result = PrometheusMetrics.fetch_data
if result[:success]
render plain: result[:data], content_type: 'text/plain'
elsif result[:error] == 'Prometheus exporter not enabled'
head :not_found
else
head :service_unavailable
end
end
end