Skip to content

Commit

Permalink
prometheus_exporter installed and initial docu written
Browse files Browse the repository at this point in the history
  • Loading branch information
henrixapp committed Jun 5, 2021
1 parent 141a2c9 commit ae939d0
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,4 @@ end
group :test, :development, :docker_development do
gem 'cypress-on-rails', '~> 1.0'
end
gem 'prometheus_exporter'
4 changes: 4 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,8 @@ GEM
progress_bar (1.3.3)
highline (>= 1.6, < 3)
options (~> 2.3.0)
prometheus_exporter (0.7.0)
webrick
public_suffix (4.0.6)
puma (4.3.7)
nio4r (~> 2.0)
Expand Down Expand Up @@ -606,6 +608,7 @@ GEM
rack-proxy (>= 0.6.1)
railties (>= 5.2)
semantic_range (>= 2.3.0)
webrick (1.7.0)
websocket-driver (0.7.3)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
Expand Down Expand Up @@ -668,6 +671,7 @@ DEPENDENCIES
pgreset
premailer-rails
progress_bar
prometheus_exporter
puma (~> 4.1)
rack
rails (~> 6.1)
Expand Down
30 changes: 30 additions & 0 deletions MONITORING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Monitoring

## Getting started (development mode): Setting up prometheus & grafana

0. Start prometheus_exporter in the mampf container
`sudo docker-compose exec mampf prometheus_exporter -b 0.0.0.0`
1. Setup prometheus in development

```sh
cd docker/development
sudo docker run -d \
-p 9090:9090 \
--name prometheus -v $(pwd)/prometheus.yml:/etc/prometheus/prometheus.yml \
prom/prometheus
# Add to mampf dev network
sudo docker network connect development_default prometheus
```
2. setup Grafana:

```sh
sudo docker run -d \
-p 2345:2345 \
--name grafana \
-e "GF_SERVER_HTTP_PORT=2345" \
grafana/grafana
```
3. Now visit localhost:2345 and configure the datasource (`prometheus:9090`)
4. Setup the dashboard, interisting metrics:
- `rate(ruby_collector_sessions_total[5m])`
- `rate(ruby_http_requests_total[5m])`
7 changes: 7 additions & 0 deletions config/initializers/prometheus_exporter.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# in config/initializers/prometheus.rb
if Rails.env != "test"
require 'prometheus_exporter/middleware'

# This reports stats per request like HTTP status and timings
Rails.application.middleware.unshift PrometheusExporter::Middleware
end

0 comments on commit ae939d0

Please sign in to comment.