monitorbit 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: e527895d02987c82544b3aec09e6dc40f2682f01184e6a4f506d22bc3dbe9cc0
4
+ data.tar.gz: 8e590f8d86766fa68d4b30fe95b0dcf49e4e24eaabf6b782eabcdf5d021691e2
5
+ SHA512:
6
+ metadata.gz: c459926063fd32b4f2921141f913274093b219cb845d482eb120d02bb171c5a2008e7a651e7e5deda5f08cb67b0c55a1b7ea450727fc4148cc4316d3a5f4a0f0
7
+ data.tar.gz: 54148af6bce8d0796c8e70847a0256f2ddfee5c47f4dd2fe72c5ca97271b68e556f6a3037b602f9f8f0940a127aee0eb748f3f9b4125331dc1b78347d8c369a1
@@ -0,0 +1,76 @@
1
+ defaults: &defaults
2
+ working_directory: ~/monitorbit
3
+ docker:
4
+ - image: circleci/ruby:2.6.4
5
+
6
+ references:
7
+ install_bundler: &install_bundler
8
+ run:
9
+ name: Installing bundler
10
+ command: gem i bundler -v $(tail -1 Gemfile.lock | tr -d ' ')
11
+
12
+ restore_bundle_cache: &restore_bundle_cache
13
+ restore_cache:
14
+ keys:
15
+ - monitorbit-{{ checksum "Gemfile.lock" }}
16
+
17
+ bundle_install: &bundle_install
18
+ run:
19
+ name: Installing gems
20
+ command: bundle --deployment --jobs=$(nproc)
21
+
22
+ save_bundle_cache: &save_bundle_cache
23
+ save_cache:
24
+ key: monitorbit-{{ checksum "Gemfile.lock" }}
25
+ paths:
26
+ - vendor/bundle
27
+
28
+ version: 2
29
+
30
+ jobs:
31
+ linters:
32
+ <<: *defaults
33
+
34
+ steps:
35
+ - checkout
36
+
37
+ - <<: *install_bundler
38
+ - <<: *restore_bundle_cache
39
+ - <<: *bundle_install
40
+ - <<: *save_bundle_cache
41
+
42
+ - run:
43
+ name: Update overcommit config
44
+ command: bundle exec overcommit --sign && bundle exec overcommit --sign pre-commit
45
+
46
+ - run:
47
+ name: Running overcommit
48
+ command: |
49
+ bundle exec overcommit -s
50
+ SKIP=AuthorEmail,AuthorName bundle exec overcommit -r
51
+
52
+ tests:
53
+ <<: *defaults
54
+
55
+ steps:
56
+ - checkout
57
+
58
+ - <<: *install_bundler
59
+ - <<: *restore_bundle_cache
60
+ - <<: *bundle_install
61
+ - <<: *save_bundle_cache
62
+
63
+ - run:
64
+ name: Running tests
65
+ command: bundle exec rspec
66
+
67
+ - store_artifacts:
68
+ path: ~/monitorbit/coverage
69
+ destination: coverage
70
+
71
+ workflows:
72
+ version: 2
73
+ build:
74
+ jobs:
75
+ - linters
76
+ - tests
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /example_app/log/
10
+ /example_app/node_modules/
11
+ /example_app/tmp/
@@ -0,0 +1,29 @@
1
+ PreCommit:
2
+ AuthorEmail:
3
+ enabled: true
4
+ required: false
5
+
6
+ AuthorName:
7
+ enabled: false
8
+
9
+ BundleAudit:
10
+ enabled: true
11
+
12
+ Brakeman:
13
+ enabled: true
14
+ flags: ['--exit-on-warn', '--quiet', '--summary']
15
+
16
+ RuboCop:
17
+ enabled: true
18
+ flags: ['--format=emacs', '--force-exclusion', '--display-cop-names']
19
+
20
+ Reek:
21
+ enabled: true
22
+ flags: ['--force-exclusion']
23
+
24
+ PostCheckout:
25
+ ALL:
26
+ quiet: true
27
+
28
+ IndexTags:
29
+ enabled: true
@@ -0,0 +1,9 @@
1
+ detectors:
2
+ IrresponsibleModule:
3
+ enabled: false
4
+
5
+ FeatureEnvy:
6
+ exclude:
7
+ - Monitorbit::ErrorsNotificationsLayer#call
8
+ exclude_paths:
9
+ - example_app/
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
@@ -0,0 +1,15 @@
1
+ AllCops:
2
+ Exclude:
3
+ - 'example_app/**/*'
4
+
5
+ Metrics/LineLength:
6
+ Max: 120
7
+
8
+ Documentation:
9
+ Enabled: false
10
+
11
+ Metrics/MethodLength:
12
+ Max: 15
13
+
14
+ Metrics/BlockLength:
15
+ Max: 35
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at mrthefoton@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in monitorbit.gemspec
6
+ gemspec
@@ -0,0 +1,254 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ monitorbit (0.1.1)
5
+ prometheus-client
6
+ yabeda-prometheus
7
+ yabeda-puma-plugin
8
+ yabeda-rails
9
+ yabeda-sidekiq
10
+
11
+ GEM
12
+ remote: https://rubygems.org/
13
+ specs:
14
+ actioncable (6.0.0)
15
+ actionpack (= 6.0.0)
16
+ nio4r (~> 2.0)
17
+ websocket-driver (>= 0.6.1)
18
+ actionmailbox (6.0.0)
19
+ actionpack (= 6.0.0)
20
+ activejob (= 6.0.0)
21
+ activerecord (= 6.0.0)
22
+ activestorage (= 6.0.0)
23
+ activesupport (= 6.0.0)
24
+ mail (>= 2.7.1)
25
+ actionmailer (6.0.0)
26
+ actionpack (= 6.0.0)
27
+ actionview (= 6.0.0)
28
+ activejob (= 6.0.0)
29
+ mail (~> 2.5, >= 2.5.4)
30
+ rails-dom-testing (~> 2.0)
31
+ actionpack (6.0.0)
32
+ actionview (= 6.0.0)
33
+ activesupport (= 6.0.0)
34
+ rack (~> 2.0)
35
+ rack-test (>= 0.6.3)
36
+ rails-dom-testing (~> 2.0)
37
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
38
+ actiontext (6.0.0)
39
+ actionpack (= 6.0.0)
40
+ activerecord (= 6.0.0)
41
+ activestorage (= 6.0.0)
42
+ activesupport (= 6.0.0)
43
+ nokogiri (>= 1.8.5)
44
+ actionview (6.0.0)
45
+ activesupport (= 6.0.0)
46
+ builder (~> 3.1)
47
+ erubi (~> 1.4)
48
+ rails-dom-testing (~> 2.0)
49
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
50
+ activejob (6.0.0)
51
+ activesupport (= 6.0.0)
52
+ globalid (>= 0.3.6)
53
+ activemodel (6.0.0)
54
+ activesupport (= 6.0.0)
55
+ activerecord (6.0.0)
56
+ activemodel (= 6.0.0)
57
+ activesupport (= 6.0.0)
58
+ activestorage (6.0.0)
59
+ actionpack (= 6.0.0)
60
+ activejob (= 6.0.0)
61
+ activerecord (= 6.0.0)
62
+ marcel (~> 0.3.1)
63
+ activesupport (6.0.0)
64
+ concurrent-ruby (~> 1.0, >= 1.0.2)
65
+ i18n (>= 0.7, < 2)
66
+ minitest (~> 5.1)
67
+ tzinfo (~> 1.1)
68
+ zeitwerk (~> 2.1, >= 2.1.8)
69
+ ast (2.4.0)
70
+ axiom-types (0.1.1)
71
+ descendants_tracker (~> 0.0.4)
72
+ ice_nine (~> 0.11.0)
73
+ thread_safe (~> 0.3, >= 0.3.1)
74
+ builder (3.2.3)
75
+ bundler-audit (0.6.1)
76
+ bundler (>= 1.2.0, < 3)
77
+ thor (~> 0.18)
78
+ childprocess (3.0.0)
79
+ codeclimate-engine-rb (0.4.1)
80
+ virtus (~> 1.0)
81
+ coercible (1.0.0)
82
+ descendants_tracker (~> 0.0.1)
83
+ concurrent-ruby (1.1.5)
84
+ connection_pool (2.2.2)
85
+ crass (1.0.4)
86
+ descendants_tracker (0.0.4)
87
+ thread_safe (~> 0.3, >= 0.3.1)
88
+ diff-lcs (1.3)
89
+ docile (1.3.2)
90
+ dry-initializer (3.0.1)
91
+ equalizer (0.0.11)
92
+ erubi (1.9.0)
93
+ globalid (0.4.2)
94
+ activesupport (>= 4.2.0)
95
+ i18n (1.6.0)
96
+ concurrent-ruby (~> 1.0)
97
+ ice_nine (0.11.2)
98
+ iniparse (1.4.4)
99
+ jaro_winkler (1.5.3)
100
+ json (2.2.0)
101
+ kwalify (0.7.2)
102
+ loofah (2.3.0)
103
+ crass (~> 1.0.2)
104
+ nokogiri (>= 1.5.9)
105
+ mail (2.7.1)
106
+ mini_mime (>= 0.1.1)
107
+ marcel (0.3.3)
108
+ mimemagic (~> 0.3.2)
109
+ method_source (0.9.2)
110
+ mimemagic (0.3.3)
111
+ mini_mime (1.0.2)
112
+ mini_portile2 (2.4.0)
113
+ minitest (5.12.2)
114
+ nio4r (2.5.2)
115
+ nokogiri (1.10.4)
116
+ mini_portile2 (~> 2.4.0)
117
+ overcommit (0.50.0)
118
+ childprocess (>= 0.6.3, < 4)
119
+ iniparse (~> 1.4)
120
+ parallel (1.17.0)
121
+ parser (2.6.4.1)
122
+ ast (~> 2.4.0)
123
+ prometheus-client (0.9.0)
124
+ quantile (~> 0.2.1)
125
+ psych (3.1.0)
126
+ puma (4.2.0)
127
+ nio4r (~> 2.0)
128
+ quantile (0.2.1)
129
+ rack (2.0.7)
130
+ rack-protection (2.0.7)
131
+ rack
132
+ rack-test (1.1.0)
133
+ rack (>= 1.0, < 3)
134
+ rails (6.0.0)
135
+ actioncable (= 6.0.0)
136
+ actionmailbox (= 6.0.0)
137
+ actionmailer (= 6.0.0)
138
+ actionpack (= 6.0.0)
139
+ actiontext (= 6.0.0)
140
+ actionview (= 6.0.0)
141
+ activejob (= 6.0.0)
142
+ activemodel (= 6.0.0)
143
+ activerecord (= 6.0.0)
144
+ activestorage (= 6.0.0)
145
+ activesupport (= 6.0.0)
146
+ bundler (>= 1.3.0)
147
+ railties (= 6.0.0)
148
+ sprockets-rails (>= 2.0.0)
149
+ rails-dom-testing (2.0.3)
150
+ activesupport (>= 4.2.0)
151
+ nokogiri (>= 1.6)
152
+ rails-html-sanitizer (1.2.0)
153
+ loofah (~> 2.2, >= 2.2.2)
154
+ railties (6.0.0)
155
+ actionpack (= 6.0.0)
156
+ activesupport (= 6.0.0)
157
+ method_source
158
+ rake (>= 0.8.7)
159
+ thor (>= 0.20.3, < 2.0)
160
+ rainbow (3.0.0)
161
+ rake (13.0.0)
162
+ redis (4.1.3)
163
+ reek (5.4.0)
164
+ codeclimate-engine-rb (~> 0.4.0)
165
+ kwalify (~> 0.7.0)
166
+ parser (>= 2.5.0.0, < 2.7, != 2.5.1.1)
167
+ psych (~> 3.1.0)
168
+ rainbow (>= 2.0, < 4.0)
169
+ rspec (3.8.0)
170
+ rspec-core (~> 3.8.0)
171
+ rspec-expectations (~> 3.8.0)
172
+ rspec-mocks (~> 3.8.0)
173
+ rspec-core (3.8.2)
174
+ rspec-support (~> 3.8.0)
175
+ rspec-expectations (3.8.4)
176
+ diff-lcs (>= 1.2.0, < 2.0)
177
+ rspec-support (~> 3.8.0)
178
+ rspec-mocks (3.8.1)
179
+ diff-lcs (>= 1.2.0, < 2.0)
180
+ rspec-support (~> 3.8.0)
181
+ rspec-support (3.8.2)
182
+ rubocop (0.75.0)
183
+ jaro_winkler (~> 1.5.1)
184
+ parallel (~> 1.10)
185
+ parser (>= 2.6)
186
+ rainbow (>= 2.2.2, < 4.0)
187
+ ruby-progressbar (~> 1.7)
188
+ unicode-display_width (>= 1.4.0, < 1.7)
189
+ rubocop-rspec (1.36.0)
190
+ rubocop (>= 0.68.1)
191
+ ruby-progressbar (1.10.1)
192
+ sidekiq (6.0.0)
193
+ connection_pool (>= 2.2.2)
194
+ rack (>= 2.0.0)
195
+ rack-protection (>= 2.0.0)
196
+ redis (>= 4.1.0)
197
+ simplecov (0.17.1)
198
+ docile (~> 1.1)
199
+ json (>= 1.8, < 3)
200
+ simplecov-html (~> 0.10.0)
201
+ simplecov-html (0.10.2)
202
+ sprockets (3.7.2)
203
+ concurrent-ruby (~> 1.0)
204
+ rack (> 1, < 3)
205
+ sprockets-rails (3.2.1)
206
+ actionpack (>= 4.0)
207
+ activesupport (>= 4.0)
208
+ sprockets (>= 3.0.0)
209
+ thor (0.20.3)
210
+ thread_safe (0.3.6)
211
+ tzinfo (1.2.5)
212
+ thread_safe (~> 0.1)
213
+ unicode-display_width (1.6.0)
214
+ virtus (1.0.5)
215
+ axiom-types (~> 0.1)
216
+ coercible (~> 1.0)
217
+ descendants_tracker (~> 0.0, >= 0.0.3)
218
+ equalizer (~> 0.0, >= 0.0.9)
219
+ websocket-driver (0.7.1)
220
+ websocket-extensions (>= 0.1.0)
221
+ websocket-extensions (0.1.4)
222
+ yabeda (0.1.3)
223
+ concurrent-ruby
224
+ dry-initializer
225
+ yabeda-prometheus (0.1.4)
226
+ yabeda
227
+ yabeda-puma-plugin (0.1.0)
228
+ json
229
+ puma
230
+ yabeda
231
+ yabeda-rails (0.1.3)
232
+ rails
233
+ yabeda
234
+ yabeda-sidekiq (0.1.3)
235
+ sidekiq
236
+ yabeda
237
+ zeitwerk (2.1.10)
238
+
239
+ PLATFORMS
240
+ ruby
241
+
242
+ DEPENDENCIES
243
+ bundler (~> 2.0.0)
244
+ bundler-audit
245
+ monitorbit!
246
+ overcommit
247
+ reek
248
+ rspec
249
+ rubocop
250
+ rubocop-rspec
251
+ simplecov
252
+
253
+ BUNDLED WITH
254
+ 2.0.2
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 dyachenko-yaroslav
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,101 @@
1
+ # Monitorbit
2
+ Gem provides quick way to set up monitoring system for state of your application and node on which it's running.
3
+
4
+ Features:
5
+ - monitoring puma(loading, threads capacity, etc.), sidekiq(successful / failed jobs, etc.), application state(slowest endpoints, 4xx/5xx errors count, etc.)
6
+ - monitoring node state (CPU,- RAM-, SWAP-, Disk usage)
7
+ - warning notifications with captured chart images via slack channel
8
+ - version controlled configurations for all ecosystem
9
+
10
+ Monitorbit contains:
11
+ - Yabeda gems, exporting puma, sidekiq and rails metrics
12
+ - Middleware, exporting 4xx / 5xx errors' metrics
13
+ - Docker-compose configuration for running grafana, prometheus and node_exporter
14
+ - Prometheus and Grafana settings
15
+ - Preconfigured dashboards
16
+
17
+ Right after running application with all ecosystem, you have 4 dashboards out of the box:
18
+ - Rails:
19
+ - Puma overload (Puma loading percentage)
20
+ - Puma Metrics (Counters of max-, running- and capacity threads)
21
+ - Throughput (Number of requests per minute)
22
+ - Rails average response time (Total, db and view)
23
+ - Rails throughput per endpoint (Number of requests per minute, grouped by endpoint)
24
+ - Rails 95% response time by endpoint (Maximum response time for 95% of requests, grouped by endpoint)
25
+ - Total jobs processed (Number of successful / failure jobs processed per second)
26
+ - Sidekiq queues (Number of enqueued jobs, grouped by quque)
27
+ - Job processing time 95 percentile (Maximux duration of 95% jobs)
28
+ - Job processing time 95% by job type (Maximux duration of 95% jobs, grouped by job type)
29
+ - Sidekiq jobs pushed by queue (Number of pushed jobs per minute, grouped by queue)
30
+ - Sidekiq jobs Retry Set by queue (Maximum number of job retries, grouped by quque)
31
+ - Sedekiq jobs processed by queue (Number of processed jobs per second, grouped by queue)
32
+ - Sidekiq jobs processed by job type (Number of processed jobs per second, grouped by job type)
33
+ - Client(4xx) / Server(5xx) errors:
34
+ - Client errors (4xx) (Number of 4xx errors, grouped by request method, path, status)
35
+ - Server errors (5xx) (Number of 5xx errors, grouped by request method, path, status)
36
+ - Node:
37
+ - CPU Busy (CPU loading percentage, grouped by core)
38
+ - Used RAM Memory (RAM memory usage percentage)
39
+ - Disk space usage (Disk space usage percentage)
40
+ - Used SWAP (SWAP usage percentage)
41
+ - Slowest queries:
42
+ - Slowest queries (SQL queries, sorted by last query execution time)
43
+
44
+ ## Installation
45
+
46
+ Add this line to your application's Gemfile:
47
+
48
+ ```ruby
49
+ gem 'monitorbit'
50
+ ```
51
+
52
+ And then execute:
53
+
54
+ $ bundle
55
+
56
+ Or install it yourself as:
57
+
58
+ $ gem install monitorbit
59
+
60
+
61
+ $ rails g monitorbit:install
62
+
63
+ $ cp docker_compose_config/.grafana /$app_root
64
+ $ cp docker_compose_config/.prometheus /$app_root
65
+
66
+ Add grafana, prometheus and node_exporter services, specified in our docker_compose_config/docker-compose.yml to your docker-compose.yml
67
+
68
+ ## Grafana settings:
69
+ ### Notifiers:
70
+ You need to create application in slack account. It will give you ability to receive text notifications. If you waant to receive captured chart images, you need to create slack bot
71
+ settings file location - .grafana/provisioning/notifiers/all.yml
72
+
73
+ keys to tweak:
74
+ - settings.url - webhook_url
75
+ - keys for capturing chart images:
76
+ - uploadImage: true
77
+ - token: your_slack_bot_token
78
+
79
+ ### Datasources:
80
+ settings file location - .grafana/provisioning/datasources/all.yml
81
+
82
+ keys to tweak:
83
+ - url - check for matching specified host and port with yours, configured within docker-compose.yml
84
+
85
+ ### Dashboards:
86
+ settings file location - .grafana/provisioning/dashboards/all.yml
87
+
88
+ keys to tweak:
89
+ - path - check for matching value of that key with configured withing docker-compose.yml
90
+
91
+ ## Prometheus settings:
92
+ All, you need is to check job names and ports. They have to correspond those, specified within docker-compose.yml
93
+ settings file location - .prometheus/config.yml
94
+
95
+ ## License
96
+
97
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
98
+
99
+ ## Code of Conduct
100
+
101
+ Everyone interacting in the Monitorbit project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/monitorbit/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ task default: :spec
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'monitorbit'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Monitorbit
4
+ class Install < Rails::Generators::Base
5
+ def create_initializer_file
6
+ append_to_file 'config/puma.rb', "activate_control_app\nplugin :yabeda"
7
+ end
8
+
9
+ def add_middleware
10
+ gsub_file(
11
+ 'config.ru',
12
+ 'run Rails.application', "use Monitorbit::ErrorsNotificationsLayer\n\nrun Rails.application"
13
+ )
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'monitorbit/railtie'
4
+ require 'monitorbit/errors_notifications_layer'
5
+ require 'monitorbit/version'
6
+
7
+ module Monitorbit
8
+ class Error < StandardError; end
9
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Monitorbit
4
+ class ErrorsNotificationsLayer
5
+ def initialize(app)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ status, headers, body = @app.call(env)
11
+
12
+ if status.between?(400, 600)
13
+ request = Rack::Request.new(env)
14
+
15
+ ActiveSupport::Notifications.instrument(
16
+ 'monitorbit.4xx_5xx_errors',
17
+ path: request.path,
18
+ ip: request.ip,
19
+ params: request.params,
20
+ method: request.request_method,
21
+ status: status
22
+ )
23
+ end
24
+
25
+ [status, headers, body]
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,81 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'yabeda/rails'
4
+ require 'yabeda/sidekiq'
5
+ require 'yabeda/prometheus'
6
+ require 'yabeda/puma/plugin'
7
+ require 'prometheus/client'
8
+
9
+ module Monitorbit
10
+ class Railtie < Rails::Railtie
11
+ LONG_RUNNING_SQL_QUERY_BUCKETS = [
12
+ 0.00005, 0.0001, 0.0005, 0.001, 0.0025,
13
+ 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10,
14
+ 30, 60, 120, 300, 600
15
+ ].freeze
16
+
17
+ initializer 'monitorbit.use_yabeda_prometheus_exporter_middleware' do |app|
18
+ app.middleware.use Yabeda::Prometheus::Exporter
19
+ end
20
+
21
+ initializer 'monitorbit.set_up_sidekiq' do |_app|
22
+ Sidekiq.configure_server { |_config| Yabeda::Prometheus::Exporter.start_metrics_server! }
23
+ end
24
+
25
+ initializer 'monitorbit.install_yabeda_rails' do |_app|
26
+ Yabeda::Rails.install! unless ::Rails.const_defined?(:Server) || ::Rails.const_defined?('Puma::CLI')
27
+ end
28
+
29
+ initializer 'monitorbit.set_up_4xx_5xx_errors' do |_app|
30
+ Yabeda.configure do
31
+ group :monitorbit
32
+
33
+ counter :errors_total, comment: 'A counter of the total number of 4xx and 5xx server responses.'
34
+
35
+ ActiveSupport::Notifications.subscribe 'monitorbit.4xx_5xx_errors' do |*args|
36
+ event = ActiveSupport::Notifications::Event.new(*args)
37
+ labels = {
38
+ path: event.payload[:path],
39
+ ip: event.payload[:ip],
40
+ params: event.payload[:params],
41
+ method: event.payload[:method],
42
+ status: event.payload[:status]
43
+ }
44
+
45
+ monitorbit_errors_total.increment(labels)
46
+ end
47
+ end
48
+ end
49
+
50
+ initializer 'sql.active_record' do |_app|
51
+ Yabeda.configure do
52
+ group :monitorbit
53
+
54
+ histogram(
55
+ :sql_query_duration,
56
+ unit: :seconds,
57
+ buckets: LONG_RUNNING_SQL_QUERY_BUCKETS,
58
+ comment: 'A histogram of the query duration.'
59
+ )
60
+
61
+ ActiveSupport::Notifications.subscribe 'sql.active_record' do |name, started, finished, unique_id, data|
62
+ event = ActiveSupport::Notifications::Event.new(name, started, finished, unique_id, data)
63
+
64
+ duration = finished - started
65
+ labels = {
66
+ sql: event.payload[:sql],
67
+ name: event.payload[:name],
68
+ statement_name: event.payload[:statement_name],
69
+ duration: duration
70
+ }
71
+
72
+ monitorbit_sql_query_duration.measure(labels, duration)
73
+ end
74
+ end
75
+ end
76
+
77
+ generators do
78
+ require_relative '../generators/monitorbit/install'
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Monitorbit
4
+ VERSION = '0.1.1'
5
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'monitorbit/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'monitorbit'
9
+ spec.version = Monitorbit::VERSION
10
+ spec.authors = ['dyachenko-yaroslav']
11
+ spec.email = ['mrthefoton@gmail.com']
12
+
13
+ spec.summary = 'Performance monitoring tool'
14
+ spec.description = "Tool for monitoring application's processess state"
15
+ # spec.homepage = "git@git.git"
16
+ spec.license = 'MIT'
17
+
18
+ # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
19
+
20
+ # spec.metadata["homepage_uri"] = spec.homepage
21
+ # spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
22
+ # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
23
+
24
+ # Specify which files should be added to the gem when it is released.
25
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
26
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
27
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|example_app|docker_compose_config)/}) }
28
+ end
29
+ spec.bindir = 'exe'
30
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ['lib']
32
+
33
+ spec.add_dependency 'prometheus-client'
34
+ spec.add_dependency 'yabeda-prometheus'
35
+ spec.add_dependency 'yabeda-puma-plugin'
36
+ spec.add_dependency 'yabeda-rails'
37
+ spec.add_dependency 'yabeda-sidekiq'
38
+
39
+ spec.add_development_dependency 'bundler', '~> 2.0.0'
40
+ spec.add_development_dependency 'bundler-audit'
41
+ spec.add_development_dependency 'overcommit'
42
+ spec.add_development_dependency 'reek'
43
+ spec.add_development_dependency 'rspec'
44
+ spec.add_development_dependency 'rubocop'
45
+ spec.add_development_dependency 'rubocop-rspec'
46
+ spec.add_development_dependency 'simplecov'
47
+ end
metadata ADDED
@@ -0,0 +1,245 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: monitorbit
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - dyachenko-yaroslav
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-10-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: prometheus-client
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: yabeda-prometheus
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: yabeda-puma-plugin
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: yabeda-rails
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: yabeda-sidekiq
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: bundler
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 2.0.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 2.0.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: bundler-audit
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: overcommit
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: reek
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rspec
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: rubocop
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: rubocop-rspec
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: simplecov
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
195
+ description: Tool for monitoring application's processess state
196
+ email:
197
+ - mrthefoton@gmail.com
198
+ executables: []
199
+ extensions: []
200
+ extra_rdoc_files: []
201
+ files:
202
+ - ".circleci/config.yml"
203
+ - ".gitignore"
204
+ - ".overcommit.yml"
205
+ - ".reek.yml"
206
+ - ".rspec"
207
+ - ".rubocop.yml"
208
+ - CODE_OF_CONDUCT.md
209
+ - Gemfile
210
+ - Gemfile.lock
211
+ - LICENSE.txt
212
+ - README.md
213
+ - Rakefile
214
+ - bin/console
215
+ - bin/setup
216
+ - lib/generators/monitorbit/install.rb
217
+ - lib/monitorbit.rb
218
+ - lib/monitorbit/errors_notifications_layer.rb
219
+ - lib/monitorbit/railtie.rb
220
+ - lib/monitorbit/version.rb
221
+ - monitorbit.gemspec
222
+ homepage:
223
+ licenses:
224
+ - MIT
225
+ metadata: {}
226
+ post_install_message:
227
+ rdoc_options: []
228
+ require_paths:
229
+ - lib
230
+ required_ruby_version: !ruby/object:Gem::Requirement
231
+ requirements:
232
+ - - ">="
233
+ - !ruby/object:Gem::Version
234
+ version: '0'
235
+ required_rubygems_version: !ruby/object:Gem::Requirement
236
+ requirements:
237
+ - - ">="
238
+ - !ruby/object:Gem::Version
239
+ version: '0'
240
+ requirements: []
241
+ rubygems_version: 3.0.3
242
+ signing_key:
243
+ specification_version: 4
244
+ summary: Performance monitoring tool
245
+ test_files: []