mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-10 01:01:39 -05:00
17 lines
460 B
Ruby
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
|