Slide 1

Slide 1 text

Fullstack monitoring Monitor any layer of your Ruby application Dmitry Salahutdinov Summer Saint P Rubyconf 2021

Slide 2

Slide 2 text

Save people time for something that matters! Is a leading e-grocery company in Russia

Slide 3

Slide 3 text

Me on GitHub

Slide 4

Slide 4 text

Why you do need Ruby-app monitoring? • To know how application performs • Ensure application works as expected (SRE) • What limit of capacity is has • To prevent degradations • Investigate degradations (when happen) • To evaluate results of optimisations

Slide 5

Slide 5 text

Yabeda framework Tooling extended extendable framework!

Slide 6

Slide 6 text

Yabeda DSL

Slide 7

Slide 7 text

Yabeda adapters

Slide 8

Slide 8 text

Yabeda adapters Developer friendly: “get up and running” or “run example & explore”

Slide 9

Slide 9 text

Common Ruby-application Is complicated and has multi-layer stack

Slide 10

Slide 10 text

1. Puma 2. Rails 3. Rack / Rack-attack 4. Sidekiq 5. Kafka 6. External Services/HTTP requests 7. Non-standard metrics usage (memory profiling) We will cover

Slide 11

Slide 11 text

Puma monitoring With yabeda-puma-plugin ruby gem

Slide 12

Slide 12 text

Metrics

Slide 13

Slide 13 text

Capacity

Slide 14

Slide 14 text

Capacity gap

Slide 15

Slide 15 text

Lack of capacity alert

Slide 16

Slide 16 text

Application Busy metric

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

Rails monitoring With yabeda-rails ruby gem

Slide 19

Slide 19 text

Yabeda::Rails dashbord

Slide 20

Slide 20 text

Slowest queries

Slide 21

Slide 21 text

SLO: serve 95% of requests within 250ms

Slide 22

Slide 22 text

APDEX score

Slide 23

Slide 23 text

APDEX (by endpoint): Yabeda version

Slide 24

Slide 24 text

Error rate

Slide 25

Slide 25 text

Rack monitoring

Slide 26

Slide 26 text

Rack custom logger

Slide 27

Slide 27 text

Rack::Attack monitoring With yabeda-rack-attack ruby gem

Slide 28

Slide 28 text

Rack::Attack monitoring

Slide 29

Slide 29 text

Throttled requests

Slide 30

Slide 30 text

- rule can works incorrect - periodically call outrange? - bad requests produces workload Why to monitor abusive requests?

Slide 31

Slide 31 text

Tracked requests Research the number of specific requests

Slide 32

Slide 32 text

Sidekiq monitoring With yabeda-sidekiq ruby gem

Slide 33

Slide 33 text

Sidekiq dashbord

Slide 34

Slide 34 text

Latency - critical jobs SLO - any other jobs default SLO max(sidekiq_queue_latency{queue=”sms”}) by (queue) > 300

Slide 35

Slide 35 text

Job Error rate (by queue)

Slide 36

Slide 36 text

max (sidekiq_running_job_runtime) by (queue) > 300 Job execution time

Slide 37

Slide 37 text

- prevent capacity lack - investigate bottlenecks Why to monitor Sidekick?

Slide 38

Slide 38 text

Kafka client monitoring With yabeda-kafka ruby gem

Slide 39

Slide 39 text

Kafka metrics With ruby-kafka

Slide 40

Slide 40 text

Kafka metrics With yabeda-kafka ruby gem MVP

Slide 41

Slide 41 text

Kafka metrics

Slide 42

Slide 42 text

External HTTP request monitoring With yabeda-http_requests ruby gem

Slide 43

Slide 43 text

Why to monitor - how good HTTP requests are made - how many times they consume - what is the distribution of HTTP response statuses

Slide 44

Slide 44 text

Metrics

Slide 45

Slide 45 text

Log memory profiling (research) With memory_profiler gem

Slide 46

Slide 46 text

No content

Slide 47

Slide 47 text

Results

Slide 48

Slide 48 text

Why to monitor? - determine hungry jobs - Its parameters (you can log them)

Slide 49

Slide 49 text

Research execution time (research)

Slide 50

Slide 50 text

Server side rendering execution time

Slide 51

Slide 51 text

Product metrics (for developers)

Slide 52

Slide 52 text

Metrics: - yabeda-rb/yabeda-puma-plugin - Built-in metrics for rack-attack monitoring out of the box! - yabeda-rb/yabeda-rails - Yabeda plugin to collect basic metrics for Rails applications - yabeda-rb/yabeda-graphql - Measure and understand how good your GraphQL-Ruby application works - yabeda-rb/yabeda-sidekiq -Yabeda plugin for complete monitoring of Sidekiq - yabeda-rb/yabeda-faktory - Built-in metrics for monitoring Faktory worker for Ruby out of the box - yabeda-rb/yabeda-http_requests - monitor how many outgoing HTTP calls your application does (uses Sniffer) - dsalahutdinov/yabeda-kafka - metrics for ruby-kafka Kafka client - dsalahutdinov/yabeda-rack_attack - Built-in metrics for rack-attack monitoring out of the box! - efigence/yabeda-grape - Metrics for monitoring Grape endpoints - Placewise/yabeda-gruf - metrics for gRPC Ruby Framework - ianks/yabeda-gc - Built in metrics for monitoring the Ruby garbage collector. Exporters: - yabeda-rb/yabeda-prometheus - Adapter to expose metrics collected by Yabeda plugins to Prometheus - yabeda-rb/yabeda-prometheus-mmap - Yabeda Prometheus exporter based on prometheus-client-mmap Adapters: - yabeda-rb/yabeda-datadog - Yabeda Datadog adapter. Collect and send custom metrics from Ruby apps to Datadog. - yabeda-rb/yabeda-newrelic - NewRelic adapter for Yabeda monitoring framework - asusikov/yabeda-statsd - Yabeda adapter for easy exporting collected custom metrics from your application to the Statsd server. Existing tools

Slide 53

Slide 53 text

Non-yet-existing tools

Slide 54

Slide 54 text

Why to invent new bicycle? - Flexibility (g.e. the APDEX in context of endpoint) - Newrelic does not logs specific metrics and tools (g.e. sidekiq latency, Kafka client) - Yabeda can complement NewRelic (with specific metrics & NewRelic adapter) - Modularity (use what you need) - Cost/Maintenance (self-hosted vs SaaS) - Yabeda is the research tool - Better developer experience - SRE-ready Why not just use Newrelic?

Slide 55

Slide 55 text

Thank you 🧡