Created
November 7, 2022 13:03
-
-
Save Envek/96f297c1dfbac8ae5afa7e4abff78f0b to your computer and use it in GitHub Desktop.
Example of separate metrics exporter process for Yabeda with Prometheus (Ruby)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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