yabeda-rb / yabeda-rails

Yabeda plugin to collect basic metrics for Rails applications
MIT License
155 stars 20 forks source link

Add support for Apdex #17

Closed pragmaticivan closed 2 years ago

pragmaticivan commented 3 years ago

Ref: https://medium.com/@tristan_96324/prometheus-apdex-alerting-d17a065e39d0

Accept T as optional param and default it to something like 1s.

Envek commented 3 years ago

Hm, I wonder whether separate metric for T is really required to do this? Or do you want to configure that Apdex base value at application level?

pragmaticivan commented 3 years ago

Usually, T has a default value in some platforms like NewRelic and Datadog, and you can change that value. So I would think defaulting to something and allowing the user to change would be ideal (on the application level).

Envek commented 3 years ago

I discussed it with operations folks and they said that it makes sense to add such a gauge if you define alerts in Prometheus, but in case if you manage alerts in Grafana, then it is much better to have these settings in Grafana also.

I think I will make this gauge optional, so you will need to enable it explicitly.

pragmaticivan commented 3 years ago

Yes, I actually have 2 projects that might accomplish what you mentioned.

I think it might be worth having a gauge for that but also publishing a metric for the value of T for querying purposes.

Envek commented 3 years ago

Hey, @pragmaticivan, please try #18, whether it is what you want?

  1. Point yabeda-rails in your application's Gemfile to this pull request:

    gem "yabeda-rails", git: "https://github.com/yabeda-rb/yabeda-rails", branch: "feature/apdex-target-gauge"
  2. Configure T value whether by setting YABEDA_RAILS_APDEX_TARGET or any other method supported by anyway_config gem.

    YABEDA_RAILS_APDEX_TARGET=0.1 rails server
  3. See rails_apdex_target_seconds gauge (with value of T set by you) is being reported to Prometheus

    rails_apdex_target_seconds{} 0.5
pragmaticivan commented 3 years ago

Just confirming that it was intentional. That PR only covers a small part of this ticket.

It registers the apdex target but doesn't calculate the apdex based on this target.

Envek commented 3 years ago

Application code isn't a good place to calculate Apdex score itself. It is even impossible to do as Yabeda doesn't store timestamps of measurements. Prometheus (or other monitoring system) does.

You can and should calculate Apdex in your Grafana dashboard or Prometheus config (as stated in the article you provided).

pragmaticivan commented 3 years ago

Sounds good @Envek thanks! Will test it today.