prometheus_exporter 0.5.1 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +42 -0
- data/.gitignore +2 -0
- data/.rubocop.yml +7 -1
- data/Appraisals +10 -0
- data/CHANGELOG +36 -3
- data/README.md +278 -5
- data/bin/prometheus_exporter +21 -0
- data/gemfiles/.bundle/config +2 -0
- data/gemfiles/ar_60.gemfile +5 -0
- data/gemfiles/ar_61.gemfile +7 -0
- data/lib/prometheus_exporter.rb +2 -0
- data/lib/prometheus_exporter/client.rb +27 -3
- data/lib/prometheus_exporter/instrumentation.rb +2 -0
- data/lib/prometheus_exporter/instrumentation/active_record.rb +14 -7
- data/lib/prometheus_exporter/instrumentation/delayed_job.rb +3 -2
- data/lib/prometheus_exporter/instrumentation/method_profiler.rb +2 -1
- data/lib/prometheus_exporter/instrumentation/process.rb +2 -0
- data/lib/prometheus_exporter/instrumentation/puma.rb +16 -4
- data/lib/prometheus_exporter/instrumentation/resque.rb +40 -0
- data/lib/prometheus_exporter/instrumentation/sidekiq.rb +44 -3
- data/lib/prometheus_exporter/instrumentation/sidekiq_queue.rb +50 -0
- data/lib/prometheus_exporter/metric/base.rb +4 -0
- data/lib/prometheus_exporter/metric/counter.rb +4 -0
- data/lib/prometheus_exporter/metric/gauge.rb +4 -0
- data/lib/prometheus_exporter/metric/histogram.rb +6 -0
- data/lib/prometheus_exporter/metric/summary.rb +7 -0
- data/lib/prometheus_exporter/middleware.rb +40 -17
- data/lib/prometheus_exporter/server.rb +2 -0
- data/lib/prometheus_exporter/server/active_record_collector.rb +3 -1
- data/lib/prometheus_exporter/server/collector.rb +2 -0
- data/lib/prometheus_exporter/server/delayed_job_collector.rb +20 -8
- data/lib/prometheus_exporter/server/hutch_collector.rb +6 -0
- data/lib/prometheus_exporter/server/puma_collector.rb +9 -1
- data/lib/prometheus_exporter/server/resque_collector.rb +54 -0
- data/lib/prometheus_exporter/server/runner.rb +24 -2
- data/lib/prometheus_exporter/server/shoryuken_collector.rb +8 -0
- data/lib/prometheus_exporter/server/sidekiq_collector.rb +11 -2
- data/lib/prometheus_exporter/server/sidekiq_queue_collector.rb +46 -0
- data/lib/prometheus_exporter/server/web_collector.rb +7 -5
- data/lib/prometheus_exporter/server/web_server.rb +29 -17
- data/lib/prometheus_exporter/version.rb +1 -1
- data/prometheus_exporter.gemspec +9 -5
- metadata +67 -17
- data/.travis.yml +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 562647915cd81e672056a83fc79a031d2a0ebb2b4a7a5e32f5786ae5c7d480a7
|
4
|
+
data.tar.gz: 525e28d0cbe4e853c91bb463970fd231b134dba6b5a190c61a2ff7710074fb7b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 324b3b0acd1c97e8b5535dff8f57500b4dc3f2433456372c609accbc78d1baf839d82a1e38eabb543f043bbc9fefb401ab1460ba252ee8b9330fe0a91acffc1d
|
7
|
+
data.tar.gz: b2a0082d4e2431cc1f24f11a6af86d6965e2db7c93df1021ed58b38ff8651c84d1e8939b42a13b1b7cac60c9237435ff838a24918ed0ee18d13c3df2aece76d4
|
@@ -0,0 +1,42 @@
|
|
1
|
+
name: Test Exporter
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
pull_request:
|
6
|
+
schedule:
|
7
|
+
- cron: '0 0 * * 0' # weekly
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
build:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
name: Ruby ${{ matrix.ruby }}
|
13
|
+
strategy:
|
14
|
+
matrix:
|
15
|
+
ruby: ["2.7", "2.6", "2.5"]
|
16
|
+
steps:
|
17
|
+
- uses: actions/checkout@master
|
18
|
+
with:
|
19
|
+
fetch-depth: 1
|
20
|
+
- uses: actions/setup-ruby@v1
|
21
|
+
with:
|
22
|
+
ruby-version: ${{ matrix.ruby }}
|
23
|
+
- uses: actions/cache@v2
|
24
|
+
with:
|
25
|
+
path: vendor/bundle
|
26
|
+
key: ${{ runner.os }}-${{ matrix.ruby }}-gems-v2-${{ hashFiles('**/Gemfile.lock') }}
|
27
|
+
restore-keys: |
|
28
|
+
${{ runner.os }}-${{ matrix.ruby }}-gems-v2-
|
29
|
+
- name: Setup gems
|
30
|
+
run: |
|
31
|
+
gem install bundler
|
32
|
+
# for Ruby <= 2.6 , details https://github.com/rubygems/rubygems/issues/3284
|
33
|
+
gem update --system 3.0.8 && gem update --system
|
34
|
+
bundle config path vendor/bundle
|
35
|
+
bundle install --jobs 4
|
36
|
+
bundle exec appraisal install
|
37
|
+
- name: Rubocop
|
38
|
+
run: bundle exec rubocop
|
39
|
+
- name: install gems
|
40
|
+
run: bundle exec appraisal bundle
|
41
|
+
- name: Run tests
|
42
|
+
run: bundle exec appraisal rake
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/Appraisals
ADDED
data/CHANGELOG
CHANGED
@@ -1,13 +1,46 @@
|
|
1
|
-
0.
|
1
|
+
0.8.0 - 05-07-2021
|
2
|
+
|
3
|
+
- FIX: handle ThreadError more gracefully in cases where process shuts down
|
4
|
+
- FEATURE: add job_name and queue_name labels to delayed job metrics
|
5
|
+
- FEATURE: always scope puma metrics on hostname in collector
|
6
|
+
- FEATURE: add customizable labels option to puma collector
|
7
|
+
- FEATURE: support for Rescue
|
8
|
+
- DEV: Remove support for EOL ruby 2.5
|
9
|
+
- FIX: Add source location to MethodProfiler patches
|
10
|
+
- FEATURE: Improve Active Record instrumentation
|
11
|
+
- FEATURE: Support HTTP_X_AMZN_TRACE_ID when supplied
|
12
|
+
|
13
|
+
0.7.0 - 29-12-2020
|
14
|
+
|
15
|
+
- Dev: Removed support from EOL rubies, only 2.5, 2.6, 2.7 and 3.0 are supported now.
|
16
|
+
- Dev: Better support for Ruby 3.0, explicitly depending on webrick
|
17
|
+
- Dev: Rails 6.1 instrumentation support
|
18
|
+
- FEATURE: clean pattern for overriding middleware labels was introduced (in README)
|
19
|
+
- Fix: Better support for forking
|
20
|
+
|
21
|
+
0.6.0 - 17-11-2020
|
22
|
+
|
23
|
+
- FEATURE: add support for basic-auth in the prometheus_exporter web server
|
24
|
+
|
25
|
+
0.5.3 - 29-07-2020
|
26
|
+
|
27
|
+
- FEATURE: added #remove to all metric types so users can remove specific labels if needed
|
28
|
+
|
29
|
+
0.5.2 - 01-07-2020
|
30
|
+
|
31
|
+
- FEATURE: expanded instrumentation for sidekiq
|
32
|
+
- FEATURE: configurable default labels
|
33
|
+
|
34
|
+
0.5.1 - 25-02-2020
|
2
35
|
|
3
36
|
- FEATURE: Allow configuring the default client's host and port via environment variables
|
4
37
|
|
5
|
-
0.5.0 - 14-02-
|
38
|
+
0.5.0 - 14-02-2020
|
6
39
|
|
7
40
|
- Breaking change: listen only to localhost by default to prevent unintended insecure configuration
|
8
41
|
- FIX: Avoid calling `hostname` aggressively, instead cache it on the exporter instance
|
9
42
|
|
10
|
-
0.4.17 - 13-01-
|
43
|
+
0.4.17 - 13-01-2020
|
11
44
|
|
12
45
|
- FEATURE: add support for `to_h` on all metrics which can be used to query existing key/values
|
13
46
|
|
data/README.md
CHANGED
@@ -19,6 +19,7 @@ To learn more see [Instrumenting Rails with Prometheus](https://samsaffron.com/a
|
|
19
19
|
* [Hutch metrics](#hutch-message-processing-tracer)
|
20
20
|
* [Puma metrics](#puma-metrics)
|
21
21
|
* [Unicorn metrics](#unicorn-process-metrics)
|
22
|
+
* [Resque metrics](#resque-metrics)
|
22
23
|
* [Custom type collectors](#custom-type-collectors)
|
23
24
|
* [Multi process mode with custom collector](#multi-process-mode-with-custom-collector)
|
24
25
|
* [GraphQL support](#graphql-support)
|
@@ -33,7 +34,7 @@ To learn more see [Instrumenting Rails with Prometheus](https://samsaffron.com/a
|
|
33
34
|
|
34
35
|
## Requirements
|
35
36
|
|
36
|
-
Minimum Ruby of version 2.
|
37
|
+
Minimum Ruby of version 2.5.0 is required, Ruby 2.4.0 is EOL as of 2020-04-05
|
37
38
|
|
38
39
|
## Installation
|
39
40
|
|
@@ -190,6 +191,64 @@ Ensure you run the exporter in a monitored background process:
|
|
190
191
|
$ bundle exec prometheus_exporter
|
191
192
|
```
|
192
193
|
|
194
|
+
#### Metrics collected by Rails integration middleware
|
195
|
+
|
196
|
+
| Type | Name | Description |
|
197
|
+
| --- | --- | --- |
|
198
|
+
| Counter | `http_requests_total` | Total HTTP requests from web app |
|
199
|
+
| Summary | `http_duration_seconds` | Time spent in HTTP reqs in seconds |
|
200
|
+
| Summary | `http_redis_duration_seconds`¹ | Time spent in HTTP reqs in Redis, in seconds |
|
201
|
+
| Summary | `http_sql_duration_seconds`² | Time spent in HTTP reqs in SQL in seconds |
|
202
|
+
| Summary | `http_queue_duration_seconds`³ | Time spent queueing the request in load balancer in seconds |
|
203
|
+
|
204
|
+
All metrics have a `controller` and an `action` label.
|
205
|
+
`http_requests_total` additionally has a (HTTP response) `status` label.
|
206
|
+
|
207
|
+
To add your own labels to the default metrics, create a subclass of `PrometheusExporter::Middleware`, override `custom_labels`, and use it in your initializer.
|
208
|
+
```ruby
|
209
|
+
class MyMiddleware < PrometheusExporter::Middleware
|
210
|
+
def custom_labels(env)
|
211
|
+
labels = {}
|
212
|
+
|
213
|
+
if env['HTTP_X_PLATFORM']
|
214
|
+
labels['platform'] = env['HTTP_X_PLATFORM']
|
215
|
+
end
|
216
|
+
|
217
|
+
labels
|
218
|
+
end
|
219
|
+
end
|
220
|
+
```
|
221
|
+
|
222
|
+
If you're not using Rails like framework, you can extend `PrometheusExporter::Middleware#default_labels` in a way to add more relevant labels.
|
223
|
+
For example you can mimic [prometheus-client](https://github.com/prometheus/client_ruby) labels with code like this:
|
224
|
+
```ruby
|
225
|
+
class MyMiddleware < PrometheusExporter::Middleware
|
226
|
+
def default_labels(env, result)
|
227
|
+
status = (result && result[0]) || -1
|
228
|
+
path = [env["SCRIPT_NAME"], env["PATH_INFO"]].join
|
229
|
+
{
|
230
|
+
path: strip_ids_from_path(path),
|
231
|
+
method: env["REQUEST_METHOD"],
|
232
|
+
status: status
|
233
|
+
}
|
234
|
+
end
|
235
|
+
|
236
|
+
def strip_ids_from_path(path)
|
237
|
+
path
|
238
|
+
.gsub(%r{/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}(/|$)}, '/:uuid\\1')
|
239
|
+
.gsub(%r{/\d+(/|$)}, '/:id\\1')
|
240
|
+
end
|
241
|
+
end
|
242
|
+
```
|
243
|
+
That way you won't have all metrics labeled with `controller=other` and `action=other`, but have labels such as
|
244
|
+
```
|
245
|
+
ruby_http_duration_seconds{path="/api/v1/teams/:id",method="GET",status="200",quantile="0.99"} 0.009880661998977303
|
246
|
+
```
|
247
|
+
|
248
|
+
¹) Only available when Redis is used.
|
249
|
+
²) Only available when Mysql or PostgreSQL are used.
|
250
|
+
³) Only available when [Instrumenting Request Queueing Time](#instrumenting-request-queueing-time) is set up.
|
251
|
+
|
193
252
|
#### Activerecord Connection Pool Metrics
|
194
253
|
|
195
254
|
This collects activerecord connection pool metrics.
|
@@ -244,6 +303,19 @@ Sidekiq.configure_server do |config|
|
|
244
303
|
end
|
245
304
|
```
|
246
305
|
|
306
|
+
##### Metrics collected by ActiveRecord Instrumentation
|
307
|
+
|
308
|
+
| Type | Name | Description |
|
309
|
+
| --- | --- | --- |
|
310
|
+
| Gauge | `active_record_connection_pool_connections` | Total connections in pool |
|
311
|
+
| Gauge | `active_record_connection_pool_busy` | Connections in use in pool |
|
312
|
+
| Gauge | `active_record_connection_pool_dead` | Dead connections in pool |
|
313
|
+
| Gauge | `active_record_connection_pool_idle` | Idle connections in pool |
|
314
|
+
| Gauge | `active_record_connection_pool_waiting` | Connection requests waiting |
|
315
|
+
| Gauge | `active_record_connection_pool_size` | Maximum allowed connection pool size |
|
316
|
+
|
317
|
+
All metrics collected by the ActiveRecord integration include at least the following labels: `pid` (of the process the stats where collected in), `pool_name`, any labels included in the `config_labels` option (prefixed with `dbconfig_`, example: `dbconfig_host`), and all custom labels provided with the `custom_labels` option.
|
318
|
+
|
247
319
|
#### Per-process stats
|
248
320
|
|
249
321
|
You may also be interested in per-process stats. This collects memory and GC stats:
|
@@ -260,11 +332,30 @@ end
|
|
260
332
|
# in unicorn/puma/passenger be sure to run a new process instrumenter after fork
|
261
333
|
after_fork do
|
262
334
|
require 'prometheus_exporter/instrumentation'
|
263
|
-
PrometheusExporter::Instrumentation::Process.start(type:"web")
|
335
|
+
PrometheusExporter::Instrumentation::Process.start(type: "web")
|
264
336
|
end
|
265
337
|
|
266
338
|
```
|
267
339
|
|
340
|
+
##### Metrics collected by Process Instrumentation
|
341
|
+
|
342
|
+
| Type | Name | Description |
|
343
|
+
| --- | --- | --- |
|
344
|
+
| Gauge | `heap_free_slots` | Free ruby heap slots |
|
345
|
+
| Gauge | `heap_live_slots` | Used ruby heap slots |
|
346
|
+
| Gauge | `v8_heap_size`* | Total JavaScript V8 heap size (bytes) |
|
347
|
+
| Gauge | `v8_used_heap_size`* | Total used JavaScript V8 heap size (bytes) |
|
348
|
+
| Gauge | `v8_physical_size`* | Physical size consumed by V8 heaps |
|
349
|
+
| Gauge | `v8_heap_count`* | Number of V8 contexts running |
|
350
|
+
| Gauge | `rss` | Total RSS used by process |
|
351
|
+
| Counter | `major_gc_ops_total` | Major GC operations by process |
|
352
|
+
| Counter | `minor_gc_ops_total` | Minor GC operations by process |
|
353
|
+
| Counter | `allocated_objects_total` | Total number of allocated objects by process |
|
354
|
+
|
355
|
+
_Metrics marked with * are only collected when `MiniRacer` is defined._
|
356
|
+
|
357
|
+
Metrics collected by Process instrumentation include labels `type` (as given with the `type` option), `pid` (of the process the stats where collected in), and any custom labels given to `Process.start` with the `labels` option.
|
358
|
+
|
268
359
|
#### Sidekiq metrics
|
269
360
|
|
270
361
|
Including Sidekiq metrics (how many jobs ran? how many failed? how long did they take? how many are dead? how many were restarted?)
|
@@ -279,6 +370,17 @@ Sidekiq.configure_server do |config|
|
|
279
370
|
end
|
280
371
|
```
|
281
372
|
|
373
|
+
To monitor Queue size and latency:
|
374
|
+
|
375
|
+
```ruby
|
376
|
+
Sidekiq.configure_server do |config|
|
377
|
+
config.on :startup do
|
378
|
+
require 'prometheus_exporter/instrumentation'
|
379
|
+
PrometheusExporter::Instrumentation::SidekiqQueue.start
|
380
|
+
end
|
381
|
+
end
|
382
|
+
```
|
383
|
+
|
282
384
|
To monitor Sidekiq process info:
|
283
385
|
|
284
386
|
```ruby
|
@@ -300,6 +402,35 @@ Sometimes the Sidekiq server shuts down before it can send metrics, that were ge
|
|
300
402
|
end
|
301
403
|
```
|
302
404
|
|
405
|
+
##### Metrics collected by Sidekiq Instrumentation
|
406
|
+
|
407
|
+
**PrometheusExporter::Instrumentation::Sidekiq**
|
408
|
+
| Type | Name | Description |
|
409
|
+
| --- | --- | --- |
|
410
|
+
| Summary | `sidekiq_job_duration_seconds` | Time spent in sidekiq jobs |
|
411
|
+
| Counter | `sidekiq_jobs_total` | Total number of sidekiq jobs executed |
|
412
|
+
| Counter | `sidekiq_restarted_jobs_total` | Total number of sidekiq jobs that we restarted because of a sidekiq shutdown |
|
413
|
+
| Counter | `sidekiq_failed_jobs_total` | Total number of failed sidekiq jobs |
|
414
|
+
|
415
|
+
All metrics have a `job_name` label and a `queue` label.
|
416
|
+
|
417
|
+
**PrometheusExporter::Instrumentation::Sidekiq.death_handler**
|
418
|
+
| Type | Name | Description |
|
419
|
+
| --- | --- | --- |
|
420
|
+
| Counter | `sidekiq_dead_jobs_total` | Total number of dead sidekiq jobs |
|
421
|
+
|
422
|
+
This metric has a `job_name` label and a `queue` label.
|
423
|
+
|
424
|
+
**PrometheusExporter::Instrumentation::SidekiqQueue**
|
425
|
+
| Type | Name | Description |
|
426
|
+
| --- | --- | --- |
|
427
|
+
| Gauge | `sidekiq_queue_backlog_total` | Size of the sidekiq queue |
|
428
|
+
| Gauge | `sidekiq_queue_latency_seconds` | Latency of the sidekiq queue |
|
429
|
+
|
430
|
+
Both metrics will have a `queue` label with the name of the queue.
|
431
|
+
|
432
|
+
_See [Metrics collected by Process Instrumentation](#metrics-collected-by-process-instrumentation) for a list of metrics the Process instrumentation will produce._
|
433
|
+
|
303
434
|
#### Shoryuken metrics
|
304
435
|
|
305
436
|
For Shoryuken metrics (how many jobs ran? how many failed? how long did they take? how many were restarted?)
|
@@ -313,6 +444,17 @@ Shoryuken.configure_server do |config|
|
|
313
444
|
end
|
314
445
|
```
|
315
446
|
|
447
|
+
##### Metrics collected by Shoryuken Instrumentation
|
448
|
+
|
449
|
+
| Type | Name | Description |
|
450
|
+
| --- | --- | --- |
|
451
|
+
| Counter | `shoryuken_job_duration_seconds` | Total time spent in shoryuken jobs |
|
452
|
+
| Counter | `shoryuken_jobs_total` | Total number of shoryuken jobs executed |
|
453
|
+
| Counter | `shoryuken_restarted_jobs_total` | Total number of shoryuken jobs that we restarted because of a shoryuken shutdown |
|
454
|
+
| Counter | `shoryuken_failed_jobs_total` | Total number of failed shoryuken jobs |
|
455
|
+
|
456
|
+
All metrics have labels for `job_name` and `queue_name`.
|
457
|
+
|
316
458
|
#### Delayed Job plugin
|
317
459
|
|
318
460
|
In an initializer:
|
@@ -324,6 +466,21 @@ unless Rails.env == "test"
|
|
324
466
|
end
|
325
467
|
```
|
326
468
|
|
469
|
+
##### Metrics collected by Delayed Job Instrumentation
|
470
|
+
|
471
|
+
| Type | Name | Description | Labels |
|
472
|
+
| --- | --- | --- | --- |
|
473
|
+
| Counter | `delayed_job_duration_seconds` | Total time spent in delayed jobs | `job_name` |
|
474
|
+
| Counter | `delayed_jobs_total` | Total number of delayed jobs executed | `job_name` |
|
475
|
+
| Gauge | `delayed_jobs_enqueued` | Number of enqueued delayed jobs | - |
|
476
|
+
| Gauge | `delayed_jobs_pending` | Number of pending delayed jobs | - |
|
477
|
+
| Counter | `delayed_failed_jobs_total` | Total number failed delayed jobs executed | `job_name` |
|
478
|
+
| Counter | `delayed_jobs_max_attempts_reached_total` | Total number of delayed jobs that reached max attempts | - |
|
479
|
+
| Summary | `delayed_job_duration_seconds_summary` | Summary of the time it takes jobs to execute | `status` |
|
480
|
+
| Summary | `delayed_job_attempts_summary` | Summary of the amount of attempts it takes delayed jobs to succeed | - |
|
481
|
+
|
482
|
+
All metrics have labels for `job_name` and `queue_name`.
|
483
|
+
|
327
484
|
#### Hutch Message Processing Tracer
|
328
485
|
|
329
486
|
Capture [Hutch](https://github.com/gocardless/hutch) metrics (how many jobs ran? how many failed? how long did they take?)
|
@@ -335,13 +492,23 @@ unless Rails.env == "test"
|
|
335
492
|
end
|
336
493
|
```
|
337
494
|
|
495
|
+
##### Metrics collected by Hutch Instrumentation
|
496
|
+
|
497
|
+
| Type | Name | Description |
|
498
|
+
| --- | --- | --- |
|
499
|
+
| Counter | `hutch_job_duration_seconds` | Total time spent in hutch jobs |
|
500
|
+
| Counter | `hutch_jobs_total` | Total number of hutch jobs executed |
|
501
|
+
| Counter | `hutch_failed_jobs_total` | Total number failed hutch jobs executed |
|
502
|
+
|
503
|
+
All metrics have a `job_name` label.
|
504
|
+
|
338
505
|
#### Instrumenting Request Queueing Time
|
339
506
|
|
340
507
|
Request Queueing is defined as the time it takes for a request to reach your application (instrumented by this `prometheus_exporter`) from farther upstream (as your load balancer). A high queueing time usually means that your backend cannot handle all the incoming requests in time, so they queue up (= you should see if you need to add more capacity).
|
341
508
|
|
342
509
|
As this metric starts before `prometheus_exporter` can handle the request, you must add a specific HTTP header as early in your infrastructure as possible (we recommend your load balancer or reverse proxy).
|
343
510
|
|
344
|
-
|
511
|
+
The Amazon Application Load Balancer [request tracing header](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-request-tracing.html) is natively supported. If you are using another upstream entrypoint, you may configure your HTTP server / load balancer to add a header `X-Request-Start: t=<MSEC>` when passing the request upstream. For more information, please consult your software manual.
|
345
512
|
|
346
513
|
Hint: we aim to be API-compatible with the big APM solutions, so if you've got requests queueing time configured for them, it should be expected to also work with `prometheus_exporter`.
|
347
514
|
|
@@ -359,6 +526,42 @@ after_worker_boot do
|
|
359
526
|
end
|
360
527
|
```
|
361
528
|
|
529
|
+
#### Metrics collected by Puma Instrumentation
|
530
|
+
|
531
|
+
| Type | Name | Description |
|
532
|
+
| --- | --- | --- |
|
533
|
+
| Gauge | `puma_workers_total` | Number of puma workers |
|
534
|
+
| Gauge | `puma_booted_workers_total` | Number of puma workers booted |
|
535
|
+
| Gauge | `puma_old_workers_total` | Number of old puma workers |
|
536
|
+
| Gauge | `puma_running_threads_total` | Number of puma threads currently running |
|
537
|
+
| Gauge | `puma_request_backlog_total` | Number of requests waiting to be processed by a puma thread |
|
538
|
+
| Gauge | `puma_thread_pool_capacity_total` | Number of puma threads available at current scale |
|
539
|
+
| Gauge | `puma_max_threads_total` | Number of puma threads at available at max scale |
|
540
|
+
|
541
|
+
All metrics may have a `phase` label and all custom labels provided with the `labels` option.
|
542
|
+
|
543
|
+
### Resque metrics
|
544
|
+
|
545
|
+
The resque metrics are using the `Resque.info` method, which queries Redis internally. To start monitoring your resque
|
546
|
+
installation, you'll need to start the instrumentation:
|
547
|
+
|
548
|
+
```ruby
|
549
|
+
# e.g. config/initializers/resque.rb
|
550
|
+
require 'prometheus_exporter/instrumentation'
|
551
|
+
PrometheusExporter::Instrumentation::Resque.start
|
552
|
+
```
|
553
|
+
|
554
|
+
#### Metrics collected by Resque Instrumentation
|
555
|
+
|
556
|
+
| Type | Name | Description |
|
557
|
+
| --- | --- | --- |
|
558
|
+
| Gauge | `processed_jobs_total` | Total number of processed Resque jobs |
|
559
|
+
| Gauge | `failed_jobs_total` | Total number of failed Resque jobs |
|
560
|
+
| Gauge | `pending_jobs_total` | Total number of pending Resque jobs |
|
561
|
+
| Gauge | `queues_total` | Total number of Resque queues |
|
562
|
+
| Gauge | `workers_total` | Total number of Resque workers running |
|
563
|
+
| Gauge | `working_total` | Total number of Resque workers working |
|
564
|
+
|
362
565
|
### Unicorn process metrics
|
363
566
|
|
364
567
|
In order to gather metrics from unicorn processes, we use `rainbows`, which exposes `Rainbows::Linux.tcp_listener_stats` to gather information about active workers and queued requests. To start monitoring your unicorn processes, you'll need to know both the path to unicorn PID file and the listen address (`pid_file` and `listen` in your unicorn config file)
|
@@ -374,6 +577,14 @@ prometheus_exporter --unicorn-master /var/run/unicorn.pid --unicorn-listen-addre
|
|
374
577
|
|
375
578
|
Note: You must install the `raindrops` gem in your `Gemfile` or locally.
|
376
579
|
|
580
|
+
#### Metrics collected by Unicorn Instrumentation
|
581
|
+
|
582
|
+
| Type | Name | Description |
|
583
|
+
| --- | --- | --- |
|
584
|
+
| Gauge | `unicorn_workers_total` | Number of unicorn workers |
|
585
|
+
| Gauge | `unicorn_active_workers_total` | Number of active unicorn workers |
|
586
|
+
| Gauge | `unicorn_request_backlog_total` | Number of requests waiting to be processed by a unicorn worker |
|
587
|
+
|
377
588
|
### Custom type collectors
|
378
589
|
|
379
590
|
In some cases you may have custom metrics you want to ship the collector in a batch. In this case you may still be interested in the base collector behavior, but would like to add your own special messages.
|
@@ -432,8 +643,8 @@ Then you can collect the metrics you need on demand:
|
|
432
643
|
|
433
644
|
```ruby
|
434
645
|
def metrics
|
435
|
-
|
436
|
-
|
646
|
+
user_count_gauge = PrometheusExporter::Metric::Gauge.new('user_count', 'number of users in the app')
|
647
|
+
user_count_gauge.observe User.count
|
437
648
|
[user_count_gauge]
|
438
649
|
end
|
439
650
|
```
|
@@ -542,6 +753,68 @@ ruby_web_requests{hostname="app-server-01",route="test/route"} 1
|
|
542
753
|
ruby_web_requests{hostname="app-server-01"} 1
|
543
754
|
```
|
544
755
|
|
756
|
+
### Exporter Process Configuration
|
757
|
+
|
758
|
+
When running the process for `prometheus_exporter` using `bin/prometheus_exporter`, there are several configurations that
|
759
|
+
can be passed in:
|
760
|
+
|
761
|
+
```
|
762
|
+
Usage: prometheus_exporter [options]
|
763
|
+
-p, --port INTEGER Port exporter should listen on (default: 9394)
|
764
|
+
-b, --bind STRING IP address exporter should listen on (default: localhost)
|
765
|
+
-t, --timeout INTEGER Timeout in seconds for metrics endpoint (default: 2)
|
766
|
+
--prefix METRIC_PREFIX Prefix to apply to all metrics (default: ruby_)
|
767
|
+
--label METRIC_LABEL Label to apply to all metrics (default: {})
|
768
|
+
-c, --collector FILE (optional) Custom collector to run
|
769
|
+
-a, --type-collector FILE (optional) Custom type collectors to run in main collector
|
770
|
+
-v, --verbose
|
771
|
+
--auth FILE (optional) enable basic authentication using a htpasswd FILE
|
772
|
+
--realm REALM (optional) Use REALM for basic authentication (default: "Prometheus Exporter")
|
773
|
+
--unicorn-listen-address ADDRESS
|
774
|
+
(optional) Address where unicorn listens on (unix or TCP address)
|
775
|
+
--unicorn-master PID_FILE (optional) PID file of unicorn master process to monitor unicorn
|
776
|
+
```
|
777
|
+
|
778
|
+
#### Example
|
779
|
+
|
780
|
+
The following will run the process at
|
781
|
+
- Port `8080` (default `9394`)
|
782
|
+
- Bind to `0.0.0.0` (default `localhost`)
|
783
|
+
- Timeout in `1 second` for metrics endpoint (default `2 seconds`)
|
784
|
+
- Metric prefix as `foo_` (default `ruby_`)
|
785
|
+
- Default labels as `{environment: "integration", foo: "bar"}`
|
786
|
+
|
787
|
+
```bash
|
788
|
+
prometheus_exporter -p 8080 \
|
789
|
+
-b 0.0.0.0 \
|
790
|
+
-t 1 \
|
791
|
+
--label '{"environment": "integration", "foo": "bar"}' \
|
792
|
+
--prefix 'foo_'
|
793
|
+
```
|
794
|
+
|
795
|
+
#### Enabling Basic Authentication
|
796
|
+
|
797
|
+
If you desire authentication on your `/metrics` route, you can enable basic authentication with the `--auth` option.
|
798
|
+
|
799
|
+
```
|
800
|
+
$ prometheus_exporter --auth my-htpasswd-file
|
801
|
+
```
|
802
|
+
|
803
|
+
Additionally, the `--realm` option may be used to provide a customized realm for the challenge request.
|
804
|
+
|
805
|
+
Notes:
|
806
|
+
|
807
|
+
* You will need to create a `htpasswd` formatted file before hand which contains one or more user:password entries
|
808
|
+
* Only the basic `crypt` encryption is currently supported
|
809
|
+
|
810
|
+
A simple `htpasswd` file can be created with the Apache `htpasswd` utility; e.g:
|
811
|
+
|
812
|
+
```
|
813
|
+
$ htpasswd -cdb my-htpasswd-file my-user my-unencrypted-password
|
814
|
+
```
|
815
|
+
|
816
|
+
This will create a file named `my-htpasswd-file` which is suitable for use the `--auth` option.
|
817
|
+
|
545
818
|
### Client default labels
|
546
819
|
|
547
820
|
You can specify a default label for instrumentation metrics sent by a specific client. For example:
|