Class: Tasker::MetricsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/tasker/metrics_controller.rb

Overview

Metrics controller providing Prometheus-compatible metrics endpoint.

This controller provides a single metrics endpoint:

  • /tasker/metrics - Prometheus format metrics (optional authentication)

The metrics endpoint uses optional authentication based on the telemetry configuration. If authentication is disabled or telemetry.metrics_auth_required is false, access is allowed. If authentication is enabled, users need the tasker.metrics:index permission.

Instance Method Summary collapse

Instance Method Details

#indexText

Metrics endpoint providing Prometheus-compatible metrics Uses optional authentication based on telemetry configuration

Returns:

  • (Text)

    Prometheus format metrics or JSON error



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/controllers/tasker/metrics_controller.rb', line 22

def index
  result = export_metrics

  if result[:success]
    render plain: result[:data], content_type: 'text/plain; charset=utf-8'
  else
    render json: {
      error: 'Metrics export failed',
      message: result[:error],
      timestamp: result[:timestamp]
    }, status: :service_unavailable
  end
rescue StandardError => e
  render json: {
    error: 'Metrics endpoint failed',
    message: e.message,
    timestamp: Time.current.iso8601
  }, status: :service_unavailable
end