README.md in sidekiq_prometheus-1.8.3 vs README.md in sidekiq_prometheus-1.9.0
- old
+ new
@@ -77,10 +77,11 @@
* `preset_labels`: Hash of labels that will be included with every metric when they are registered. `Hash{Symbol (label name) => String (label value)}`
* `custom_labels`: Hash of metrics and labels that can be applied to specific metrics. The metric name must be a registered metric. `Hash{Symbol (metric name) => Array<Symbol> (label names)}`
* `gc_metrics_enabled`: Boolean that determines whether to record object allocation metrics per job. The default is `true`. Setting this to `false` if you don't need this metric.
* `global_metrics_enabled`: Boolean that determines whether to report global metrics from the PeriodicMetrics reporter. When `true` this will report on a number of stats from the Sidekiq API for the cluster. This requires Sidekiq::Enterprise as the reporter uses the leader election functionality to ensure that only one worker per cluster is reporting metrics.
+* `init_label_sets`: Hash of metrics and label sets that are initialized by calling `metric.init_label_set` after the metric is registered. See[ prometheus-client docs](https://github.com/prometheus/client_ruby/tree/e144d6225d3c346e9a4dd0a11f41f8acde386dd8#init_label_set) for details. `Hash{Symbol (metric name) => Array<Hash> (label sets)}`.
* `periodic_metrics_enabled`: Boolean that determines whether to run the periodic metrics reporter. `PeriodicMetrics` runs a separate thread that reports on global metrics (if enabled) as well worker GC stats (if enabled). It reports metrics on the interval defined by `periodic_reporting_interval`. Defaults to `true`.
* `periodic_reporting_interval`: interval in seconds for reporting periodic metrics. Default: `30`
* `metrics_server_enabled`: Boolean that determines whether to run the rack server. Defaults to `true`
* `metrics_server_logger_enabled`: Boolean that determines if the metrics server will log access logs. Defaults to `true`
* `metrics_host`: Host on which the rack server will listen. Defaults to
@@ -92,18 +93,19 @@
SidekiqPrometheus.configure do |config|
config.preset_labels = { service: 'myapp' }
config.custom_labels = { sidekiq_job_count: [:worker_class, :job_type, :any_other_label] }
config.gc_metrics_enabled = false
config.global_metrics_enabled = true
+ config.init_label_sets = { sidekiq_job_count: [{worker_class: "class", job_type: "single", any_other_label: "value"}, {worker_class: "class", job_type: "batch", any_other_label: "other-value"}] }
config.periodic_metrics_enabled = true
config.periodic_reporting_interval = 20
config.metrics_server_enabled = true
config.metrics_port = 8675
end
```
-Custom labels may be added by defining the `prometheus_labels` method in the worker class,
+Custom labels may be added by defining the `prometheus_labels` method in the worker class,
prior you need to register the custom labels as of the above example:
```ruby
class SomeWorker
include Sidekiq::Worker
@@ -128,14 +130,17 @@
| sidekiq_job_count | counter | Count of Sidekiq jobs |
| sidekiq_job_duration | histogram | Sidekiq job processing duration |
| sidekiq_job_success | counter | Count of successful Sidekiq jobs |
| sidekiq_job_allocated_objects | histogram | Count of ruby objects allocated by a Sidekiq job |
| sidekiq_job_failed | counter | Count of failed Sidekiq jobs |
+| sidekiq_job_over_limit | counter | Count of over limit Sidekiq jobs |
+
Notes:
* when a job fails only `sidekiq_job_count` and `sidekiq_job_failed` will be reported.
+* when a job fails due to Sidekiq::Limiter::OverLimit error, only `sidekiq_job_count` and `sidekiq_job_over_limit` will be reported.
* `sidekiq_job_allocated_objects` will only be reported if `SidekiqPrometheus.gc_metrics_enabled? == true`
### Periodic GC Metrics
These require `SidekiqPrometheus.gc_metrics_enabled? == true` and `SidekiqPrometheus.periodic_metrics_enabled? == true`
@@ -215,10 +220,10 @@
```ruby
customer_worker_metrics = [
{
name: :file_count, type: :counter, docstring: 'Number of active files',
- name: :file_size, type: :gauge, docstring: 'Size of files in bytes',
+ name: :file_size, type: :gauge, docstring: 'Size of files in bytes',
}
]
SidekiqPrometheus::Metrics.register_metrics(customer_worker_metrics)
```