mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-11 09:41:40 -05:00
Merge pull request #421 from Freika/feature/prometheus-monitoring
Prometheus monitoring
This commit is contained in:
commit
0de4bb1c0c
10 changed files with 54 additions and 2 deletions
|
|
@ -1 +1 @@
|
|||
0.16.5
|
||||
0.16.6
|
||||
|
|
|
|||
15
CHANGELOG.md
15
CHANGELOG.md
|
|
@ -5,6 +5,21 @@ All notable changes to this project will be documented in this file.
|
|||
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
# 0.16.6 - 2024-11-20
|
||||
|
||||
### Added
|
||||
|
||||
- Dawarich now can export metrics to Prometheus. You can find the metrics at `your.host:9394/metrics` endpoint. The metrics are being exported in the Prometheus format and can be scraped by Prometheus server. To enable exporting, set the `PROMETHEUS_EXPORTER_ENABLED` env var in your docker-compose.yml to `true`. Example:
|
||||
|
||||
```yaml
|
||||
dawarich_app:
|
||||
image: freikin/dawarich:latest
|
||||
container_name: dawarich_app
|
||||
environment:
|
||||
...
|
||||
PROMETHEUS_EXPORTER_ENABLED: "true"
|
||||
```
|
||||
|
||||
# 0.16.5 - 2024-11-18
|
||||
|
||||
### Changed
|
||||
|
|
|
|||
1
Gemfile
1
Gemfile
|
|
@ -18,6 +18,7 @@ gem 'kaminari'
|
|||
gem 'lograge'
|
||||
gem 'oj'
|
||||
gem 'pg'
|
||||
gem 'prometheus_exporter'
|
||||
gem 'puma'
|
||||
gem 'pundit'
|
||||
gem 'rails'
|
||||
|
|
|
|||
|
|
@ -236,6 +236,8 @@ GEM
|
|||
patience_diff (1.2.0)
|
||||
optimist (~> 3.0)
|
||||
pg (1.5.9)
|
||||
prometheus_exporter (2.1.1)
|
||||
webrick
|
||||
pry (0.14.2)
|
||||
coderay (~> 1.1)
|
||||
method_source (~> 1.0)
|
||||
|
|
@ -413,6 +415,7 @@ GEM
|
|||
addressable (>= 2.8.0)
|
||||
crack (>= 0.3.2)
|
||||
hashdiff (>= 0.4.0, < 2.0.0)
|
||||
webrick (1.9.0)
|
||||
websocket-driver (0.7.6)
|
||||
websocket-extensions (>= 0.1.0)
|
||||
websocket-extensions (0.1.5)
|
||||
|
|
@ -446,6 +449,7 @@ DEPENDENCIES
|
|||
lograge
|
||||
oj
|
||||
pg
|
||||
prometheus_exporter
|
||||
pry-byebug
|
||||
pry-rails
|
||||
puma
|
||||
|
|
|
|||
2
Procfile.prometheus.dev
Normal file
2
Procfile.prometheus.dev
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
web: bin/rails server -p 3000 -b 0.0.0.0
|
||||
prometheus_exporter: bundle exec prometheus_exporter
|
||||
8
bin/dev
8
bin/dev
|
|
@ -6,4 +6,10 @@ then
|
|||
gem install foreman
|
||||
fi
|
||||
|
||||
foreman start -f Procfile.dev
|
||||
if [ "$PROMETHEUS_EXPORTER_ENABLED" = "true" ]; then
|
||||
echo "Starting Foreman with Procfile.prometheus.dev..."
|
||||
foreman start -f Procfile.prometheus.dev
|
||||
else
|
||||
echo "Starting Foreman with Procfile.dev..."
|
||||
foreman start -f Procfile.dev
|
||||
fi
|
||||
|
|
|
|||
12
config/initializers/prometheus.rb
Normal file
12
config/initializers/prometheus.rb
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
# in config/initializers/prometheus.rb
|
||||
if Rails.env != "test"
|
||||
require 'prometheus_exporter/middleware'
|
||||
require 'prometheus_exporter/instrumentation'
|
||||
|
||||
# This reports stats per request like HTTP status and timings
|
||||
Rails.application.middleware.unshift PrometheusExporter::Middleware
|
||||
|
||||
# this reports basic process stats like RSS and GC info, type master
|
||||
# means it is instrumenting the master process
|
||||
PrometheusExporter::Instrumentation::Process.start(type: "master")
|
||||
end
|
||||
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
Sidekiq.configure_server do |config|
|
||||
config.redis = { url: ENV['REDIS_URL'] }
|
||||
|
||||
config.server_middleware do |chain|
|
||||
require 'prometheus_exporter/instrumentation'
|
||||
chain.add PrometheusExporter::Instrumentation::Sidekiq
|
||||
end
|
||||
end
|
||||
|
||||
Sidekiq.configure_client do |config|
|
||||
|
|
|
|||
|
|
@ -41,3 +41,9 @@ pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
|
|||
|
||||
# Allow puma to be restarted by `bin/rails restart` command.
|
||||
plugin :tmp_restart
|
||||
|
||||
# Promethues exporter
|
||||
after_worker_boot do
|
||||
require 'prometheus_exporter/instrumentation'
|
||||
PrometheusExporter::Instrumentation::Process.start(type:"web")
|
||||
end
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@ services:
|
|||
DISTANCE_UNIT: km
|
||||
PHOTON_API_HOST: photon.komoot.io
|
||||
PHOTON_API_USE_HTTPS: true
|
||||
PROMETHEUS_EXPORTER_ENABLED: false
|
||||
logging:
|
||||
driver: "json-file"
|
||||
options:
|
||||
|
|
|
|||
Loading…
Reference in a new issue