dawarich/app/controllers/metrics_controller.rb

18 lines
460 B
Ruby
Raw Normal View History

2025-07-26 06:14:08 -04:00
# frozen_string_literal: true
class MetricsController < ApplicationController
http_basic_authenticate_with name: METRICS_USERNAME, password: METRICS_PASSWORD, only: :index
2025-07-26 06:14:08 -04:00
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