Skip to content

Instantly share code, notes, and snippets.

@Envek
Created November 7, 2022 13:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Envek/96f297c1dfbac8ae5afa7e4abff78f0b to your computer and use it in GitHub Desktop.
Save Envek/96f297c1dfbac8ae5afa7e4abff78f0b to your computer and use it in GitHub Desktop.
Example of separate metrics exporter process for Yabeda with Prometheus (Ruby)
#!/usr/bin/env ruby
# Example of how to launch separate process to export all metrics from Ruby processes on the same host/container.
# IMPORTANT:
# You MUST configure Direct File store in official Prometheus Ruby client for this to work.
# See https://github.com/yabeda-rb/yabeda-prometheus#multi-process-server-support
# Example of configuration that should be made for additional process to export all metrics
# Here: export Sidekiq metrics from not worker process. See https://github.com/yabeda-rb/yabeda-sidekiq#configuration
ENV["YABEDA_SIDEKIQ_COLLECT_CLUSTER_METRICS"] = 'true'
ENV["YABEDA_SIDEKIQ_DECLARE_PROCESS_METRICS"] = 'true'
# Boot Rails application
APP_PATH = File.expand_path('../config/application', __dir__)
require_relative '../config/boot'
require_relative '../config/environment'
# Run exporter
default_port = ENV.fetch('PORT', 9394)
::Rack::Handler::WEBrick.run(
Yabeda::Prometheus::Exporter.rack_app,
Host: ENV['PROMETHEUS_EXPORTER_BIND'] || '0.0.0.0',
Port: ENV.fetch('PROMETHEUS_EXPORTER_PORT', default_port),
AccessLog: []
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment