yabeda-rb / yabeda-sidekiq

Yabeda plugin for complete monitoring of Sidekiq
MIT License
124 stars 15 forks source link

export Sidekiq metrics on rails default server. #27

Closed hannan228 closed 2 years ago

hannan228 commented 2 years ago

Hi, first thanks for the work you put into this project.

I am using Yabeda for collecting rails, puma and sidekiq metrics. Rails and puma's metrics are showing on rails default server port:3000 but sidekiq metrics are not showing accurately just main heading showing. sidekiq metrics are showing metrics after adding additional configuration in config/initializers/sidekiq but on Prometheus default port:9394 accurately.

How i can configure its port for rails server as configured for puma and rails. How i can change this following code to get on rails server.

`# config/initializers/sidekiq or elsewhere

Sidekiq.configure_server do |_config| Yabeda::Prometheus::Exporter.start_metrics_server! end` This what I am getting on default server Screenshot from 2022-06-20 12-28-38

This what I am getting on configured port. I need this types of result on rails:3000 port

Screenshot from 2022-06-20 12-31-11

Envek commented 2 years ago

This is because of Prometheus Ruby client stores metrics in memory and every process has its own set of metrics.

In development, you can fix it by

  1. either setting up official Prometheus client to use file store instead of in-memory store, see https://github.com/yabeda-rb/yabeda-prometheus#multi-process-server-support
  2. or switching to https://github.com/yabeda-rb/yabeda-prometheus-mmap which uses memory-mapped files to sync data between processes.

Note that processes must be able to access common disk and/or memory, so this won't work in containerized environments.

See https://github.com/yabeda-rb/yabeda-prometheus/issues/4 for more details