sidekiq-prometheus-exporter 0.1.12 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.github/FUNDING.yml +12 -0
- data/.github/workflows/ci.yaml +68 -0
- data/.gitignore +3 -1
- data/.rubocop.yml +43 -296
- data/Appraisals +17 -4
- data/README.md +98 -50
- data/Rakefile +83 -0
- data/docker/Dockerfile +24 -0
- data/docker/README.md +61 -0
- data/docker/config.ru +41 -0
- data/examples/docker-compose.yml +2 -2
- data/examples/metrics/config.ru +2 -0
- data/examples/screenshot.png +0 -0
- data/examples/sidekiq/sidekiq.rb +2 -0
- data/examples/{sidekiq.json → sidekiq-dashboard.grafana-6.json} +10 -52
- data/examples/sidekiq-dashboard.grafana-7.json +845 -0
- data/gemfiles/{sidekiq_3.3.1.gemfile → sidekiq_3.3.1.Gemfile} +2 -1
- data/gemfiles/sidekiq_3.3.1.Gemfile.lock +125 -0
- data/gemfiles/{sidekiq_3.x.gemfile → sidekiq_3.x.Gemfile} +2 -1
- data/gemfiles/{sidekiq_3.x.gemfile.lock → sidekiq_3.x.Gemfile.lock} +63 -61
- data/gemfiles/{sidekiq_4.x.gemfile → sidekiq_4.x.Gemfile} +1 -1
- data/gemfiles/sidekiq_4.x.Gemfile.lock +101 -0
- data/gemfiles/{sidekiq_5.x.gemfile → sidekiq_5.x.Gemfile} +1 -1
- data/gemfiles/sidekiq_5.x.Gemfile.lock +100 -0
- data/gemfiles/sidekiq_6.x.Gemfile +8 -0
- data/gemfiles/sidekiq_6.x.Gemfile.lock +97 -0
- data/gemfiles/sidekiq_latest.Gemfile +9 -0
- data/gemfiles/sidekiq_latest.Gemfile.lock +113 -0
- data/helm/sidekiq-prometheus-exporter/.helmignore +22 -0
- data/helm/sidekiq-prometheus-exporter/Chart.yaml +6 -0
- data/helm/sidekiq-prometheus-exporter/README.md +87 -0
- data/helm/sidekiq-prometheus-exporter/templates/NOTES.txt +15 -0
- data/helm/sidekiq-prometheus-exporter/templates/_helpers.tpl +109 -0
- data/helm/sidekiq-prometheus-exporter/templates/clusterrole.yaml +20 -0
- data/helm/sidekiq-prometheus-exporter/templates/clusterrolebinding.yaml +17 -0
- data/helm/sidekiq-prometheus-exporter/templates/deployment.yaml +62 -0
- data/helm/sidekiq-prometheus-exporter/templates/service.yaml +17 -0
- data/helm/sidekiq-prometheus-exporter/templates/serviceaccount.yaml +9 -0
- data/helm/sidekiq-prometheus-exporter/templates/servicemonitor.yaml +26 -0
- data/helm/sidekiq-prometheus-exporter/values.yaml +135 -0
- data/lib/sidekiq/prometheus/exporter/standard.rb +19 -5
- data/lib/sidekiq/prometheus/exporter/templates/standard.erb +13 -1
- data/lib/sidekiq/prometheus/exporter/version.rb +1 -1
- data/lib/sidekiq/prometheus/exporter.rb +3 -1
- data/sidekiq-prometheus-exporter.gemspec +9 -7
- metadata +74 -41
- data/.codeclimate.yml +0 -16
- data/.travis.yml +0 -23
- data/gemfiles/sidekiq_3.3.1.gemfile.lock +0 -138
- data/gemfiles/sidekiq_4.x.gemfile.lock +0 -101
- data/gemfiles/sidekiq_5.x.gemfile.lock +0 -99
data/README.md
CHANGED
@@ -1,6 +1,5 @@
|
|
1
|
-
|
1
|
+

|
2
2
|
[](https://codeclimate.com/github/Strech/sidekiq-prometheus-exporter/maintainability)
|
3
|
-
[](https://codeclimate.com/github/Strech/sidekiq-prometheus-exporter/test_coverage)
|
4
3
|
|
5
4
|
# Sidekiq Prometheus Exporter
|
6
5
|
|
@@ -10,42 +9,57 @@
|
|
10
9
|
|
11
10
|

|
12
11
|
|
13
|
-
Open [dashboard example file](/examples/sidekiq.json), then open `https://<your grafana-url>/dashboard/import` and paste the content of the file.
|
12
|
+
Open [dashboard example file](/examples/sidekiq-dashboard.grafana-7.json) (grafana 7), then open `https://<your grafana-url>/dashboard/import` and paste the content of the file.
|
13
|
+
|
14
|
+
---
|
15
|
+
|
16
|
+
#### If you like the project and want to support me on my sleepless nights, you can
|
17
|
+
|
18
|
+
[](https://www.paypal.com/paypalme/onistrech/eur5.0)
|
19
|
+
[](https://ko-fi.com/W7W8367XJ)
|
14
20
|
|
15
21
|
# Available metrics
|
16
22
|
|
17
|
-
|
23
|
+
_(starting Sidekiq `v3.3.1`)_
|
18
24
|
|
19
|
-
|
25
|
+
## Standard
|
20
26
|
|
21
|
-
| Name | Type | Description
|
22
|
-
|
23
|
-
| sidekiq_processed_jobs_total | counter | The total number of processed jobs
|
24
|
-
| sidekiq_failed_jobs_total | counter | The total number of failed jobs
|
25
|
-
| sidekiq_workers | gauge | The number of workers across all the processes
|
26
|
-
| sidekiq_processes | gauge | The number of processes
|
27
|
-
| sidekiq_busy_workers | gauge | The number of workers performing the job
|
28
|
-
| sidekiq_enqueued_jobs | gauge | The number of enqueued jobs
|
29
|
-
| sidekiq_scheduled_jobs | gauge | The number of jobs scheduled for a future execution
|
30
|
-
| sidekiq_retry_jobs | gauge | The number of jobs scheduled for the next try
|
31
|
-
| sidekiq_dead_jobs | gauge | The number of jobs being dead
|
32
|
-
| sidekiq_queue_latency_seconds | gauge | The number of seconds between oldest job being pushed to the queue and current time (labels: `name`)
|
33
|
-
| sidekiq_queue_max_processing_time_seconds | gauge | The number of seconds between oldest job of the queue being executed and current time (labels: `name`)
|
34
|
-
| sidekiq_queue_enqueued_jobs | gauge | The number of enqueued jobs in the queue (labels: `name`)
|
27
|
+
| Name | Type | Description |
|
28
|
+
| ----------------------------------------- | ------- | ------------------------------------------------------------------------------------------------------ |
|
29
|
+
| sidekiq_processed_jobs_total | counter | The total number of processed jobs |
|
30
|
+
| sidekiq_failed_jobs_total | counter | The total number of failed jobs |
|
31
|
+
| sidekiq_workers | gauge | The number of workers across all the processes |
|
32
|
+
| sidekiq_processes | gauge | The number of processes |
|
33
|
+
| sidekiq_busy_workers | gauge | The number of workers performing the job |
|
34
|
+
| sidekiq_enqueued_jobs | gauge | The number of enqueued jobs |
|
35
|
+
| sidekiq_scheduled_jobs | gauge | The number of jobs scheduled for a future execution |
|
36
|
+
| sidekiq_retry_jobs | gauge | The number of jobs scheduled for the next try |
|
37
|
+
| sidekiq_dead_jobs | gauge | The number of jobs being dead |
|
38
|
+
| sidekiq_queue_latency_seconds | gauge | The number of seconds between oldest job being pushed to the queue and current time (labels: `name`) |
|
39
|
+
| sidekiq_queue_max_processing_time_seconds | gauge | The number of seconds between oldest job of the queue being executed and current time (labels: `name`) |
|
40
|
+
| sidekiq_queue_enqueued_jobs | gauge | The number of enqueued jobs in the queue (labels: `name`) |
|
41
|
+
| sidekiq_queue_workers | gauge | The number of workers serving the queue (labels: `name`) |
|
42
|
+
| sidekiq_queue_processes | gauge | The number of processes serving the queue (labels: `name`) |
|
43
|
+
| sidekiq_queue_busy_workers | gauge | The number of workers performing the job for the queue (labels: `name`) |
|
35
44
|
|
36
|
-
|
45
|
+
<details>
|
46
|
+
<summary>Click to expand for all available contribs</summary>
|
37
47
|
|
38
|
-
|
39
|
-
|-----------------------------------------------|-------|-----------------------|
|
40
|
-
| sidekiq_scheduler_jobs | gauge | The number of recurring jobs
|
41
|
-
| sidekiq_scheduler_enabled_jobs | gauge | The number of enabled recurring jobs
|
42
|
-
| sidekiq_scheduler_time_since_last_run_minutes | gauge | The number of minutes since the last recurring job was executed and current time (labels: `name`)
|
48
|
+
## [Scheduler](https://github.com/moove-it/sidekiq-scheduler)
|
43
49
|
|
44
|
-
|
50
|
+
| Name | Type | Description |
|
51
|
+
| --------------------------------------------- | ----- | ------------------------------------------------------------------------------------------------- |
|
52
|
+
| sidekiq_scheduler_jobs | gauge | The number of recurring jobs |
|
53
|
+
| sidekiq_scheduler_enabled_jobs | gauge | The number of enabled recurring jobs |
|
54
|
+
| sidekiq_scheduler_time_since_last_run_minutes | gauge | The number of minutes since the last recurring job was executed and current time (labels: `name`) |
|
45
55
|
|
46
|
-
|
47
|
-
|
48
|
-
|
|
56
|
+
## [Cron](https://github.com/ondrejbartas/sidekiq-cron)
|
57
|
+
|
58
|
+
| Name | Type | Description |
|
59
|
+
| ----------------- | ----- | ----------------------- |
|
60
|
+
| sidekiq_cron_jobs | gauge | The number of cron jobs |
|
61
|
+
|
62
|
+
</details>
|
49
63
|
|
50
64
|
# Installation
|
51
65
|
|
@@ -57,17 +71,17 @@ gem 'sidekiq-prometheus-exporter', '~> 0.1'
|
|
57
71
|
|
58
72
|
And then execute:
|
59
73
|
|
60
|
-
```
|
74
|
+
```console
|
61
75
|
$ bundle
|
62
76
|
```
|
63
77
|
|
64
78
|
Or install it yourself as:
|
65
79
|
|
66
|
-
```
|
80
|
+
```console
|
67
81
|
$ gem install sidekiq-prometheus-exporter -v '~> 0.1'
|
68
82
|
```
|
69
83
|
|
70
|
-
|
84
|
+
## Rack application
|
71
85
|
|
72
86
|
For a fresh new application to expose metrics create `config.ru` file with
|
73
87
|
next code inside
|
@@ -85,13 +99,13 @@ run Sidekiq::Prometheus::Exporter.to_app
|
|
85
99
|
|
86
100
|
Use your favorite server to start it up, like this
|
87
101
|
|
88
|
-
```
|
102
|
+
```console
|
89
103
|
$ bundle exec rackup -p9292 -o0.0.0.0
|
90
104
|
```
|
91
105
|
|
92
106
|
and then `curl https://0.0.0.0:9292/metrics`
|
93
107
|
|
94
|
-
|
108
|
+
## Rails application
|
95
109
|
|
96
110
|
When you have rails application, it's possible to mount exporter
|
97
111
|
as a rack application in your `routes.rb`
|
@@ -109,13 +123,13 @@ end
|
|
109
123
|
|
110
124
|
Use rails server from `bin` folder to start it up, like this
|
111
125
|
|
112
|
-
```
|
126
|
+
```console
|
113
127
|
$ ./bin/rails s -p 9292 -b 0.0.0.0
|
114
128
|
```
|
115
129
|
|
116
130
|
and then `curl https://0.0.0.0:9292/metrics`
|
117
131
|
|
118
|
-
|
132
|
+
## Sidekiq Web (extream)
|
119
133
|
|
120
134
|
If you are ok with metrics being exposed via Sidekiq web dashboard because
|
121
135
|
you have it inside your private network or only Prometheus scraper will have access
|
@@ -130,7 +144,52 @@ Sidekiq::Web.register(Sidekiq::Prometheus::Exporter)
|
|
130
144
|
|
131
145
|
and then `curl https://<your-sidekiq-web-uri>/metrics`
|
132
146
|
|
133
|
-
|
147
|
+
## Docker
|
148
|
+
|
149
|
+
If we are talking about isolation you can run already prepared official
|
150
|
+
rack application in the Docker container by using the [public image](https://hub.docker.com/r/strech/sidekiq-prometheus-exporter)
|
151
|
+
(check out this [README](/docker/README.md) for more)
|
152
|
+
|
153
|
+
```bash
|
154
|
+
$ docker run -it --rm \
|
155
|
+
-p 9292:9292 \
|
156
|
+
-e REDIS_URL=redis://<your-redis-host>:6379/0 \
|
157
|
+
strech/sidekiq-prometheus-exporter
|
158
|
+
```
|
159
|
+
|
160
|
+
and then `curl https://0.0.0.0:9292/metrics`
|
161
|
+
|
162
|
+
## Helm
|
163
|
+
|
164
|
+
And finally the cloud solution _(who don't these days)_. Easy to install, easy
|
165
|
+
to use. A fully-functioning Helm-package based on official [Docker
|
166
|
+
image](https://hub.docker.com/r/strech/sidekiq-prometheus-exporter), comes with lots of [configuration
|
167
|
+
options](https://github.com/Strech/sidekiq-prometheus-exporter/blob/master/helm/sidekiq-prometheus-exporter/README.md)
|
168
|
+
|
169
|
+
```console
|
170
|
+
$ helm repo add strech https://strech.github.io/sidekiq-prometheus-exporter
|
171
|
+
"strech" has been added to your repositories
|
172
|
+
|
173
|
+
$ helm install strech/sidekiq-prometheus-exporter --name sidekiq-metrics
|
174
|
+
```
|
175
|
+
|
176
|
+
to `curl` your metrics, please follow the post-installation guide
|
177
|
+
|
178
|
+
# Tips&Tricks
|
179
|
+
|
180
|
+
If you want to see at the exporter startup time a banner about which exporters
|
181
|
+
are enabled add this call to your `config.ru` (but after exporter `configure` statement)
|
182
|
+
|
183
|
+
```ruby
|
184
|
+
require 'sidekiq/prometheus/exporter'
|
185
|
+
|
186
|
+
puts Sidekiq::Prometheus::Exporter.banner
|
187
|
+
```
|
188
|
+
|
189
|
+
:anger: if you don't see your banner try to output into `STDERR` instead of
|
190
|
+
`STDOUT`
|
191
|
+
|
192
|
+
## Sidekiq Contribs
|
134
193
|
|
135
194
|
By default we try to detect as many as possible [sidekiq contribs](https://github.com/mperham/sidekiq/wiki/Related-Projects)
|
136
195
|
and add their metrics to the output.
|
@@ -150,20 +209,9 @@ Sidekiq::Prometheus::Exporter.configure do |config|
|
|
150
209
|
end
|
151
210
|
```
|
152
211
|
|
153
|
-
|
154
|
-
|
155
|
-
If you want to see at the exporter startup time a banner about which exporters
|
156
|
-
are enabled add this call to your `config.ru` (but after exporter `configure` statement)
|
157
|
-
|
158
|
-
```ruby
|
159
|
-
require 'sidekiq/prometheus/exporter'
|
160
|
-
|
161
|
-
puts Sidekiq::Prometheus::Exporter.banner
|
162
|
-
```
|
163
|
-
|
164
|
-
:anger: if you don't see your banner try to output into `STDERR` instead of `STDOUT`
|
212
|
+
:bulb: if you did't find the contrib you would like to see, don't hesitate to [open an issue](https://github.com/Strech/sidekiq-prometheus-exporter/issues/new) and describe what do you think we should export.
|
165
213
|
|
166
|
-
|
214
|
+
# Contributing
|
167
215
|
|
168
216
|
Bug reports and pull requests to support earlier versions of Sidekiq are welcome on GitHub at https://github.com/Strech/sidekiq-prometheus-exporter/issues.
|
169
217
|
|
data/Rakefile
CHANGED
@@ -4,3 +4,86 @@ require 'rspec/core/rake_task'
|
|
4
4
|
RSpec::Core::RakeTask.new(:spec)
|
5
5
|
|
6
6
|
task default: :spec
|
7
|
+
|
8
|
+
# ==============================================================================
|
9
|
+
|
10
|
+
require 'English'
|
11
|
+
require 'fileutils'
|
12
|
+
require_relative 'lib/sidekiq/prometheus/exporter/version'
|
13
|
+
|
14
|
+
VERSION = Sidekiq::Prometheus::Exporter::VERSION
|
15
|
+
|
16
|
+
def execute(command)
|
17
|
+
output = `#{command}`
|
18
|
+
|
19
|
+
unless $CHILD_STATUS.success?
|
20
|
+
warn output
|
21
|
+
exit 1
|
22
|
+
end
|
23
|
+
|
24
|
+
output
|
25
|
+
end
|
26
|
+
|
27
|
+
namespace :docker do
|
28
|
+
desc "Release new Docker image strech/sidekiq-prometheus-exporter:#{VERSION} (latest)"
|
29
|
+
task :release, %i(patch) do |_, args|
|
30
|
+
version = [VERSION, args.patch].compact.join('-')
|
31
|
+
|
32
|
+
Rake::Task['docker:build'].invoke(version)
|
33
|
+
Rake::Task['docker:push'].invoke(version)
|
34
|
+
end
|
35
|
+
|
36
|
+
task :build, %i(version) do |_, args|
|
37
|
+
args.with_defaults(version: VERSION)
|
38
|
+
image = 'strech/sidekiq-prometheus-exporter'
|
39
|
+
|
40
|
+
Dir.chdir(File.expand_path('./docker')) do
|
41
|
+
execute("docker build -t #{image}:#{args.version} -t #{image}:latest .")
|
42
|
+
end
|
43
|
+
|
44
|
+
puts "Successfully built strech/sidekiq-prometheus-exporter and tagged #{args.version} (latest)"
|
45
|
+
end
|
46
|
+
|
47
|
+
task :push, %i(version) do |_, args|
|
48
|
+
args.with_defaults(version: VERSION)
|
49
|
+
image = 'strech/sidekiq-prometheus-exporter'
|
50
|
+
|
51
|
+
execute("docker push #{image}:#{args.version}")
|
52
|
+
execute("docker push #{image}:latest")
|
53
|
+
|
54
|
+
puts "Successfully pushed strech/sidekiq-prometheus-exporter:#{args.version} (latest)"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
namespace :helm do
|
59
|
+
desc 'Generate new Helm repo index'
|
60
|
+
task :generate, %i(patch) do |_, args|
|
61
|
+
version = [VERSION, args.patch].compact.join('-')
|
62
|
+
archive_dir = File.expand_path("./tmp/archive-#{Time.now.to_i}")
|
63
|
+
|
64
|
+
Rake::Task['helm:package'].invoke(archive_dir)
|
65
|
+
Rake::Task['helm:index'].invoke(archive_dir, version)
|
66
|
+
|
67
|
+
puts "New index generated: #{File.join(archive_dir, 'index.yaml')}"
|
68
|
+
end
|
69
|
+
|
70
|
+
task :package, %i(directory) do |_, args|
|
71
|
+
chart_dir = File.expand_path('./helm/sidekiq-prometheus-exporter')
|
72
|
+
archive_dir = args.fetch(:directory) { File.expand_path("./tmp/archive-#{Time.now.to_i}") }
|
73
|
+
|
74
|
+
FileUtils.mkdir_p(archive_dir)
|
75
|
+
|
76
|
+
execute("helm package #{chart_dir} -d #{archive_dir}")
|
77
|
+
end
|
78
|
+
|
79
|
+
task :index, %i(directory version) do |_, args|
|
80
|
+
args.with_defaults(version: VERSION)
|
81
|
+
|
82
|
+
Dir.chdir(args.fetch(:directory)) do
|
83
|
+
url = "https://github.com/Strech/sidekiq-prometheus-exporter/releases/download/v#{args.version}"
|
84
|
+
|
85
|
+
execute('git show gh-pages:index.yaml > existing-index.yaml')
|
86
|
+
execute("helm repo index . --url #{url} --merge existing-index.yaml")
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
data/docker/Dockerfile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
FROM ruby:2.7.3-alpine
|
2
|
+
|
3
|
+
LABEL maintainer="Sergey Fedorov <oni.strech@gmail.com>"
|
4
|
+
LABEL repository="strech/sidekiq-prometheus-exporter"
|
5
|
+
|
6
|
+
ENV RACK_VERSION 2.0.9
|
7
|
+
ENV SIDEKIQ_VERSION 6.2.1
|
8
|
+
ENV REDIS_NAMESPACE_VERSION 1.8.1
|
9
|
+
ENV SIDEKIQ_PROMETHEUS_EXPORTER_VERSION 0.1.16
|
10
|
+
|
11
|
+
RUN addgroup -S exporter \
|
12
|
+
&& adduser -s /bin/false -SDHg exporter exporter \
|
13
|
+
&& gem install "rack:$RACK_VERSION" \
|
14
|
+
&& gem install "sidekiq:$SIDEKIQ_VERSION" \
|
15
|
+
&& gem install "redis-namespace:$REDIS_NAMESPACE_VERSION" \
|
16
|
+
&& gem install "sidekiq-prometheus-exporter:$SIDEKIQ_PROMETHEUS_EXPORTER_VERSION"
|
17
|
+
|
18
|
+
USER exporter
|
19
|
+
WORKDIR /app
|
20
|
+
COPY config.ru config.ru
|
21
|
+
|
22
|
+
EXPOSE 9292
|
23
|
+
ENTRYPOINT [ "rackup" ]
|
24
|
+
CMD [ "-p", "9292", "-o", "0.0.0.0", "config.ru" ]
|
data/docker/README.md
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# Official Docker image
|
2
|
+
|
3
|
+
[0]: https://github.com/Strech/sidekiq-prometheus-exporter
|
4
|
+
[1]: https://www.iana.org/assignments/uri-schemes/prov/redis
|
5
|
+
[2]: https://github.com/resque/redis-namespace
|
6
|
+
[3]: https://github.com/redis/redis-rb/tree/v4.1.3#sentinel-support
|
7
|
+
[4]: https://github.com/mperham/sidekiq/issues/4479
|
8
|
+
|
9
|
+
This is an official Docker image for [sidekiq-prometheus-exporter][0]
|
10
|
+
gem.
|
11
|
+
|
12
|
+
It combines some approaches which were already published as images by other
|
13
|
+
devs and at the same time brings more flexibility for the stock configuration
|
14
|
+
and applies recommended Docker best practices.
|
15
|
+
|
16
|
+
:warning: The Docker image currently supports **only** standards metrics.
|
17
|
+
|
18
|
+
## Supported ENVs
|
19
|
+
|
20
|
+
Required
|
21
|
+
|
22
|
+
- `REDIS_URL` - [RFC 3986 generic URI][1], exclusive with `REDIS_HOST`
|
23
|
+
- `REDIS_HOST` - a Redis host, exclusive with `REDIS_URL` (default: `localhost`)
|
24
|
+
|
25
|
+
Optional
|
26
|
+
|
27
|
+
- `REDIS_SSL` - a flag to enable Redis SSL URL scheme (default: `false`)
|
28
|
+
- `REDIS_PORT` - a Redis port (default: `6379`)
|
29
|
+
- `REDIS_PASSWORD` - a Redis password (if you need one)
|
30
|
+
- `REDIS_DB_NUMBER` - a Redis database number (default: `0`)
|
31
|
+
- `REDIS_NAMESPACE` - a Redis [namespace][2] name (if you have separated sidekiq)
|
32
|
+
- `REDIS_SENTINELS` - a list of comma separated Redis urls (like `REDIS_URL`, but for sentinels)
|
33
|
+
- `REDIS_SENTINEL_ROLE` - a role within the [sentinel][3] to connect (default: `master`)
|
34
|
+
- `REDIS_DISABLE_CLIENT_ID` - a flag to disable `CLIENT` command in [Sidekiq][4]
|
35
|
+
|
36
|
+
:bulb: Note, that `REDIS_URL` and `REDIS_HOST` are exclusive. Since `REDIS_HOST` is more
|
37
|
+
atomic value it will be checked after `REDIS_URL`.
|
38
|
+
|
39
|
+
:bulb: `REDIS_SENTINELS` will be parsed with `URI`, because of that it's
|
40
|
+
mandatory for them to be formatted with protocol `redis://...`.
|
41
|
+
|
42
|
+
:bulb: `REDIS_DISABLE_CLIENT_ID` might be required if a SaaS Redis provider is being used.
|
43
|
+
|
44
|
+
## Examples
|
45
|
+
|
46
|
+
If you don't have a running Redis instance, you can quickly spin an empty to
|
47
|
+
practice.
|
48
|
+
|
49
|
+
```bash
|
50
|
+
$ docker run -d --rm --name redis-instance redis
|
51
|
+
```
|
52
|
+
|
53
|
+
and then run an exporter
|
54
|
+
|
55
|
+
```bash
|
56
|
+
$ docker run -it --rm \
|
57
|
+
--link redis-instance \
|
58
|
+
-p 9292:9292 \
|
59
|
+
-e REDIS_URL=redis://redis-instance \
|
60
|
+
strech/sidekiq-prometheus-exporter
|
61
|
+
```
|
data/docker/config.ru
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'sidekiq'
|
4
|
+
require 'sidekiq/prometheus/exporter'
|
5
|
+
|
6
|
+
config = {}
|
7
|
+
config[:url] = ENV['REDIS_URL'] if ENV.key?('REDIS_URL')
|
8
|
+
|
9
|
+
unless config.key?(:url)
|
10
|
+
scheme = (ENV.fetch('REDIS_SSL', 'false') == 'true') ? 'rediss' : 'redis'
|
11
|
+
host = ENV.fetch('REDIS_HOST', 'localhost')
|
12
|
+
port = ENV.fetch('REDIS_PORT', 6379)
|
13
|
+
db_number = ENV.fetch('REDIS_DB_NUMBER', 0)
|
14
|
+
password = ":#{ENV['REDIS_PASSWORD']}" if ENV.key?('REDIS_PASSWORD')
|
15
|
+
|
16
|
+
config[:url] = "#{scheme}://#{password}@#{host}:#{port}/#{db_number}"
|
17
|
+
end
|
18
|
+
|
19
|
+
if ENV.key?('REDIS_NAMESPACE')
|
20
|
+
require 'redis-namespace'
|
21
|
+
|
22
|
+
config[:namespace] = ENV['REDIS_NAMESPACE']
|
23
|
+
end
|
24
|
+
|
25
|
+
if ENV.key?('REDIS_SENTINELS')
|
26
|
+
require 'uri'
|
27
|
+
|
28
|
+
config[:role] = ENV.fetch('REDIS_SENTINEL_ROLE', :master).to_sym
|
29
|
+
config[:sentinels] = ENV['REDIS_SENTINELS'].split(',').map do |url|
|
30
|
+
uri = URI.parse(url.strip)
|
31
|
+
cfg = {host: uri.host || 'localhost', port: uri.port || 26379} # rubocop:disable Style/NumericLiterals
|
32
|
+
cfg[:password] = ":#{uri.password}" if uri.password
|
33
|
+
cfg
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
config[:id] = nil if ENV.key?('REDIS_DISABLE_CLIENT_ID')
|
38
|
+
|
39
|
+
Sidekiq.configure_client { |client| client.redis = config }
|
40
|
+
|
41
|
+
run Sidekiq::Prometheus::Exporter.to_app
|
data/examples/docker-compose.yml
CHANGED
data/examples/metrics/config.ru
CHANGED
data/examples/screenshot.png
CHANGED
Binary file
|
data/examples/sidekiq/sidekiq.rb
CHANGED
@@ -22,11 +22,7 @@
|
|
22
22
|
"cacheTimeout": null,
|
23
23
|
"colorBackground": false,
|
24
24
|
"colorValue": false,
|
25
|
-
"colors": [
|
26
|
-
"#299c46",
|
27
|
-
"rgba(237, 129, 40, 0.89)",
|
28
|
-
"#d44a3a"
|
29
|
-
],
|
25
|
+
"colors": ["#299c46", "rgba(237, 129, 40, 0.89)", "#d44a3a"],
|
30
26
|
"datasource": null,
|
31
27
|
"format": "none",
|
32
28
|
"gauge": {
|
@@ -102,11 +98,7 @@
|
|
102
98
|
"cacheTimeout": null,
|
103
99
|
"colorBackground": false,
|
104
100
|
"colorValue": false,
|
105
|
-
"colors": [
|
106
|
-
"#d44a3a",
|
107
|
-
"rgba(237, 129, 40, 0.89)",
|
108
|
-
"#299c46"
|
109
|
-
],
|
101
|
+
"colors": ["#d44a3a", "rgba(237, 129, 40, 0.89)", "#299c46"],
|
110
102
|
"datasource": null,
|
111
103
|
"format": "none",
|
112
104
|
"gauge": {
|
@@ -182,11 +174,7 @@
|
|
182
174
|
"cacheTimeout": null,
|
183
175
|
"colorBackground": false,
|
184
176
|
"colorValue": true,
|
185
|
-
"colors": [
|
186
|
-
"#299c46",
|
187
|
-
"rgba(237, 129, 40, 0.89)",
|
188
|
-
"#d44a3a"
|
189
|
-
],
|
177
|
+
"colors": ["#299c46", "rgba(237, 129, 40, 0.89)", "#d44a3a"],
|
190
178
|
"datasource": null,
|
191
179
|
"format": "none",
|
192
180
|
"gauge": {
|
@@ -262,11 +250,7 @@
|
|
262
250
|
"cacheTimeout": null,
|
263
251
|
"colorBackground": false,
|
264
252
|
"colorValue": true,
|
265
|
-
"colors": [
|
266
|
-
"#299c46",
|
267
|
-
"rgba(237, 129, 40, 0.89)",
|
268
|
-
"#d44a3a"
|
269
|
-
],
|
253
|
+
"colors": ["#299c46", "rgba(237, 129, 40, 0.89)", "#d44a3a"],
|
270
254
|
"datasource": null,
|
271
255
|
"format": "none",
|
272
256
|
"gauge": {
|
@@ -342,11 +326,7 @@
|
|
342
326
|
"cacheTimeout": null,
|
343
327
|
"colorBackground": false,
|
344
328
|
"colorValue": true,
|
345
|
-
"colors": [
|
346
|
-
"#299c46",
|
347
|
-
"rgba(237, 129, 40, 0.89)",
|
348
|
-
"#d44a3a"
|
349
|
-
],
|
329
|
+
"colors": ["#299c46", "rgba(237, 129, 40, 0.89)", "#d44a3a"],
|
350
330
|
"datasource": null,
|
351
331
|
"format": "none",
|
352
332
|
"gauge": {
|
@@ -422,11 +402,7 @@
|
|
422
402
|
"cacheTimeout": null,
|
423
403
|
"colorBackground": false,
|
424
404
|
"colorValue": false,
|
425
|
-
"colors": [
|
426
|
-
"#299c46",
|
427
|
-
"rgba(237, 129, 40, 0.89)",
|
428
|
-
"#d44a3a"
|
429
|
-
],
|
405
|
+
"colors": ["#299c46", "rgba(237, 129, 40, 0.89)", "#d44a3a"],
|
430
406
|
"datasource": null,
|
431
407
|
"format": "none",
|
432
408
|
"gauge": {
|
@@ -502,11 +478,7 @@
|
|
502
478
|
"cacheTimeout": null,
|
503
479
|
"colorBackground": false,
|
504
480
|
"colorValue": false,
|
505
|
-
"colors": [
|
506
|
-
"#299c46",
|
507
|
-
"rgba(237, 129, 40, 0.89)",
|
508
|
-
"#d44a3a"
|
509
|
-
],
|
481
|
+
"colors": ["#299c46", "rgba(237, 129, 40, 0.89)", "#d44a3a"],
|
510
482
|
"datasource": null,
|
511
483
|
"format": "none",
|
512
484
|
"gauge": {
|
@@ -582,11 +554,7 @@
|
|
582
554
|
"cacheTimeout": null,
|
583
555
|
"colorBackground": false,
|
584
556
|
"colorValue": false,
|
585
|
-
"colors": [
|
586
|
-
"#299c46",
|
587
|
-
"rgba(237, 129, 40, 0.89)",
|
588
|
-
"#d44a3a"
|
589
|
-
],
|
557
|
+
"colors": ["#299c46", "rgba(237, 129, 40, 0.89)", "#d44a3a"],
|
590
558
|
"datasource": null,
|
591
559
|
"format": "none",
|
592
560
|
"gauge": {
|
@@ -860,20 +828,10 @@
|
|
860
828
|
"2h",
|
861
829
|
"1d"
|
862
830
|
],
|
863
|
-
"time_options": [
|
864
|
-
"5m",
|
865
|
-
"15m",
|
866
|
-
"1h",
|
867
|
-
"6h",
|
868
|
-
"12h",
|
869
|
-
"24h",
|
870
|
-
"2d",
|
871
|
-
"7d",
|
872
|
-
"30d"
|
873
|
-
]
|
831
|
+
"time_options": ["5m", "15m", "1h", "6h", "12h", "24h", "2d", "7d", "30d"]
|
874
832
|
},
|
875
833
|
"timezone": "",
|
876
|
-
"title": "Sidekiq",
|
834
|
+
"title": "Sidekiq Dashboard",
|
877
835
|
"uid": "SwCwV7qkz",
|
878
836
|
"version": 2
|
879
837
|
}
|