health-monitor-rails 8.4.0 → 8.5.0
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54a0e9ca8f2f1fcb6f6d1d4ffd1db0be2f1d62fa712314b7d87960fe1ad10afb
|
4
|
+
data.tar.gz: cc2752aa4c9328401c81cf283a8a7b47f34fe06013abe08b6c8bd9225c8435d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 202a5a3d0bc1fbc2f7acd00e6f2e7ab0426705faf818c8b488fa623d3f6160329a7da5c8826958e8f53774e12d19e07bba025840eb665186b4db7c77f0bb918e
|
7
|
+
data.tar.gz: 34b10f0e4ec669e9f1299720c37e387a8e3480b6f19b242a6d4266d387da78a1768026eeda1aaecea3c6b89aa429952e17c6eef6d7e5e10f7fa9722cbcd77c22
|
data/README.md
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
[](http://badge.fury.io/rb/health-monitor-rails)
|
4
4
|
[](https://travis-ci.org/lbeder/health-monitor-rails)
|
5
|
-
[](https://gemnasium.com/lbeder/health-monitor-rails)
|
6
5
|
[](https://coveralls.io/r/lbeder/health-monitor-rails)
|
7
6
|
|
8
7
|
This is a health monitoring Rails mountable plug-in, which checks various services (db, cache, sidekiq, redis, etc.).
|
@@ -150,16 +149,17 @@ gem 'health-monitor-rails'
|
|
150
149
|
Then run:
|
151
150
|
|
152
151
|
```bash
|
153
|
-
|
152
|
+
bundle install
|
154
153
|
```
|
155
154
|
|
156
|
-
Otherwise install the gem:
|
155
|
+
Otherwise, install the gem:
|
157
156
|
|
158
157
|
```bash
|
159
|
-
|
158
|
+
gem install health-monitor-rails
|
160
159
|
```
|
161
160
|
|
162
161
|
## Usage
|
162
|
+
|
163
163
|
You can mount this inside your app routes by adding this to config/routes.rb:
|
164
164
|
|
165
165
|
```ruby
|
@@ -167,7 +167,9 @@ mount HealthMonitor::Engine, at: '/'
|
|
167
167
|
```
|
168
168
|
|
169
169
|
## Supported Service Providers
|
170
|
+
|
170
171
|
The following services are currently supported:
|
172
|
+
|
171
173
|
* DB
|
172
174
|
* Cache
|
173
175
|
* Redis
|
@@ -178,6 +180,7 @@ The following services are currently supported:
|
|
178
180
|
## Configuration
|
179
181
|
|
180
182
|
### Adding Providers
|
183
|
+
|
181
184
|
By default, only the database check is enabled. You can add more service providers by explicitly enabling them via an initializer:
|
182
185
|
|
183
186
|
```ruby
|
@@ -214,7 +217,7 @@ end
|
|
214
217
|
# To configure specific queues
|
215
218
|
HealthMonitor.configure do |config|
|
216
219
|
config.sidekiq.configure do |sidekiq_config|
|
217
|
-
sidekiq_config.add_queue_configuration(
|
220
|
+
sidekiq_config.add_queue_configuration('critical', latency: 10.seconds, queue_size: 20)
|
218
221
|
end
|
219
222
|
end
|
220
223
|
|
@@ -236,22 +239,23 @@ The currently supported settings are:
|
|
236
239
|
#### Sidekiq
|
237
240
|
|
238
241
|
* `latency`: the latency (in seconds) of a queue (now - when the oldest job was enqueued) which is considered unhealthy (the default is 30 seconds, but larger processing queue should have a larger latency value).
|
239
|
-
* `queue_size`: the size (
|
242
|
+
* `queue_size`: the size (maximum) of a queue which is considered unhealthy (the default is 100).
|
240
243
|
|
241
244
|
#### Redis
|
242
245
|
|
243
|
-
* `url`: the
|
244
|
-
* `connection`: Use custom
|
246
|
+
* `url`: the URL used to connect to your Redis instance - note, this is an optional configuration and will use the default connection if not specified
|
247
|
+
* `connection`: Use custom Redis connection (e.g., `Redis.current`).
|
245
248
|
* `max_used_memory`: Set maximum expected memory usage of Redis in megabytes. Prevent memory leaks and keys overstore.
|
246
249
|
|
247
250
|
#### Delayed Job
|
248
251
|
|
249
|
-
* `queue_size`: the size (
|
252
|
+
* `queue_size`: the size (maximum) of a queue which is considered unhealthy (the default is 100).
|
250
253
|
|
251
254
|
### Adding a Custom Provider
|
255
|
+
|
252
256
|
It's also possible to add custom health check providers suited for your needs (of course, it's highly appreciated and encouraged if you'd contribute useful providers to the project).
|
253
257
|
|
254
|
-
|
258
|
+
To add a custom provider, you'd need to:
|
255
259
|
|
256
260
|
* Implement the `HealthMonitor::Providers::Base` class and its `check!` method (a check is considered as failed if it raises an exception):
|
257
261
|
|
@@ -262,6 +266,7 @@ class CustomProvider < HealthMonitor::Providers::Base
|
|
262
266
|
end
|
263
267
|
end
|
264
268
|
```
|
269
|
+
|
265
270
|
* Add its class to the configuration:
|
266
271
|
|
267
272
|
```ruby
|
@@ -271,6 +276,7 @@ end
|
|
271
276
|
```
|
272
277
|
|
273
278
|
### Adding a Custom Error Callback
|
279
|
+
|
274
280
|
If you need to perform any additional error handling (for example, for additional error reporting), you can configure a custom error callback:
|
275
281
|
|
276
282
|
```ruby
|
@@ -284,6 +290,7 @@ end
|
|
284
290
|
```
|
285
291
|
|
286
292
|
### Adding Authentication Credentials
|
293
|
+
|
287
294
|
By default, the `/check` endpoint is not authenticated and is available to any user. You can authenticate using HTTP Basic Auth by providing authentication credentials:
|
288
295
|
|
289
296
|
```ruby
|
@@ -296,7 +303,8 @@ end
|
|
296
303
|
```
|
297
304
|
|
298
305
|
### Adding Environment Variables
|
299
|
-
|
306
|
+
|
307
|
+
By default, environment variables are `nil`, so if you'd want to include additional parameters in the results JSON, all you need is to provide a `Hash` with your custom environment variables:
|
300
308
|
|
301
309
|
```ruby
|
302
310
|
HealthMonitor.configure do |config|
|
@@ -311,7 +319,7 @@ end
|
|
311
319
|
|
312
320
|
A Nagios/Shinken/Icinga/Icinga2 plugin is available in `extra` directory.
|
313
321
|
|
314
|
-
It takes one argument
|
322
|
+
It takes one argument: `-u` or `--uri`
|
315
323
|
|
316
324
|
```sh
|
317
325
|
nicolas@desktop:$ ./check_rails.rb
|
@@ -325,7 +333,7 @@ Common options:
|
|
325
333
|
-h, --help Displays Help
|
326
334
|
```
|
327
335
|
|
328
|
-
|
336
|
+
Also, it generates an output with the right status code for your monitoring system:
|
329
337
|
|
330
338
|
```sh
|
331
339
|
nicolas@desktop:$ ./check_rails.rb -u http://admin:admin@localhost:5000/check.json
|
@@ -11,15 +11,31 @@ module HealthMonitor
|
|
11
11
|
DEFAULT_LATENCY_TIMEOUT = 30
|
12
12
|
DEFAULT_QUEUES_SIZE = 100
|
13
13
|
|
14
|
-
attr_accessor :latency, :queue_size, :queue_name
|
15
14
|
attr_reader :queues
|
16
15
|
|
17
16
|
def initialize
|
18
|
-
@queue_name = DEFAULT_QUEUE_NAME
|
19
|
-
@latency = DEFAULT_LATENCY_TIMEOUT
|
20
|
-
@queue_size = DEFAULT_QUEUES_SIZE
|
21
17
|
@queues = {}
|
22
|
-
@queues[
|
18
|
+
@queues[DEFAULT_QUEUE_NAME] = { latency: DEFAULT_LATENCY_TIMEOUT, queue_size: DEFAULT_QUEUES_SIZE }
|
19
|
+
end
|
20
|
+
|
21
|
+
def latency=(value)
|
22
|
+
default_queue[:latency] = value
|
23
|
+
end
|
24
|
+
|
25
|
+
def latency
|
26
|
+
default_queue[:latency]
|
27
|
+
end
|
28
|
+
|
29
|
+
def queue_size=(value)
|
30
|
+
default_queue[:queue_size] = value
|
31
|
+
end
|
32
|
+
|
33
|
+
def queue_size
|
34
|
+
default_queue[:queue_size]
|
35
|
+
end
|
36
|
+
|
37
|
+
def default_queue
|
38
|
+
queues[DEFAULT_QUEUE_NAME]
|
23
39
|
end
|
24
40
|
|
25
41
|
def add_queue_configuration(queue_name, latency: DEFAULT_LATENCY_TIMEOUT, queue_size: DEFAULT_QUEUES_SIZE)
|
File without changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: health-monitor-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 8.
|
4
|
+
version: 8.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leonid Beder
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -224,16 +224,16 @@ dependencies:
|
|
224
224
|
name: sqlite3
|
225
225
|
requirement: !ruby/object:Gem::Requirement
|
226
226
|
requirements:
|
227
|
-
- - "
|
227
|
+
- - "~>"
|
228
228
|
- !ruby/object:Gem::Version
|
229
|
-
version:
|
229
|
+
version: 1.3.6
|
230
230
|
type: :development
|
231
231
|
prerelease: false
|
232
232
|
version_requirements: !ruby/object:Gem::Requirement
|
233
233
|
requirements:
|
234
|
-
- - "
|
234
|
+
- - "~>"
|
235
235
|
- !ruby/object:Gem::Version
|
236
|
-
version:
|
236
|
+
version: 1.3.6
|
237
237
|
- !ruby/object:Gem::Dependency
|
238
238
|
name: timecop
|
239
239
|
requirement: !ruby/object:Gem::Requirement
|
@@ -261,7 +261,6 @@ files:
|
|
261
261
|
- app/controllers/health_monitor/health_controller.rb
|
262
262
|
- app/views/health_monitor/health/check.html.erb
|
263
263
|
- config/routes.rb
|
264
|
-
- lib/health-monitor-rails.rb
|
265
264
|
- lib/health_monitor/configuration.rb
|
266
265
|
- lib/health_monitor/engine.rb
|
267
266
|
- lib/health_monitor/monitor.rb
|
@@ -273,6 +272,7 @@ files:
|
|
273
272
|
- lib/health_monitor/providers/resque.rb
|
274
273
|
- lib/health_monitor/providers/sidekiq.rb
|
275
274
|
- lib/health_monitor/version.rb
|
275
|
+
- lib/health_monitor_rails.rb
|
276
276
|
homepage: https://github.com/lbeder/health-monitor-rails
|
277
277
|
licenses:
|
278
278
|
- MIT
|
@@ -293,7 +293,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
293
293
|
version: '0'
|
294
294
|
requirements: []
|
295
295
|
rubyforge_project:
|
296
|
-
rubygems_version: 2.7.
|
296
|
+
rubygems_version: 2.7.8
|
297
297
|
signing_key:
|
298
298
|
specification_version: 4
|
299
299
|
summary: Health monitoring Rails plug-in, which checks various services (db, cache,
|