prometheus_exporter
prometheus_exporter copied to clipboard
Generating Prometheus metrics text timed out
Hello running ruby 2.5.5 with puma
puma.rb
...
preload_app!
# Allow puma to be restarted by `rails restart` command.
plugin :tmp_restart
before_fork do
require 'puma_worker_killer'
PumaWorkerKiller.config do |config|
```
end
PumaWorkerKiller.start
end
on_worker_boot do
ActiveRecord::Base.establish_connection if defined?(ActiveRecord::Base)
if CONFIG['prometheus']['enabled']
require 'prometheus_exporter/instrumentation'
PrometheusExporter::Instrumentation::Process.start type: 'web',
labels: CONFIG['prometheus']['default_labels']
end
end
after_worker_boot do
if CONFIG['prometheus']['enabled']
require 'prometheus_exporter/instrumentation'
PrometheusExporter::Instrumentation::Puma.start
end
end
intializer
# frozen_string_literal: true
if Rails.env != 'test' && CONFIG['prometheus']['enabled'] && !defined?(::Rake)
# NOTE: as we have different processes but want 1 interface for prometheus to scrape the metrics
# we send the metrics to a collector container
# this process need to be started as a separate process
#
# Prometheus Ports:
# https://github.com/prometheus/prometheus/wiki/Default-port-allocations
require 'prometheus_exporter/metric'
PrometheusExporter::Metric::Base.default_labels = CONFIG['prometheus']['default_labels']
# Connect to Prometheus Collector Process
require 'prometheus_exporter/client'
my_client = PrometheusExporter::Client.new(host: CONFIG['prometheus']['host'],
port: CONFIG['prometheus']['port'],
custom_labels: CONFIG['prometheus']['default_labels'])
# Set Default Client
PrometheusExporter::Client.default = my_client
# This reports stats per request like HTTP status and timings
require 'prometheus_exporter/middleware'
Rails.application.middleware.unshift PrometheusExporter::Middleware
# this reports basic process stats like RSS and GC info
require 'prometheus_exporter/instrumentation'
PrometheusExporter::Instrumentation::DelayedJob.register_plugin
PrometheusExporter::Instrumentation::Process.start(type: 'master', labels: CONFIG['prometheus']['default_labels'])
end
after some time prometheus exporter logs contain ''' Generating Prometheus metrics text timed out '''
and exporter doesn't return metrics