Skip to content

Commit

Permalink
Merge pull request #231 from alphagov/prometheus-k8s-switch
Browse files Browse the repository at this point in the history
Add flag to only use prometheus exporter on kubernetes cluster
  • Loading branch information
marcpomfret authored Apr 7, 2022
2 parents 9f2eebd + d493c8b commit 2d38dbb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Unreleased

- Fix prometheus_exporter to only be enabled when the GOVUK_PROMETHEUS_EXPORTER env var is set to "true" ([#231](https://github.com/alphagov/govuk_app_config/pull/231)).
- Add Prometheus monitoring for EKS section to README.md ([#231](https://github.com/alphagov/govuk_app_config/pull/231)).
- Fix govuk_error being incompatible with Ruby >= 3 ([#233](https://github.com/alphagov/govuk_app_config/pull/233))
- Require Ruby 2.7 as the minimum supported Ruby version ([#233](https://github.com/alphagov/govuk_app_config/pull/233))
- Require Sentry 5 and Unicorn 6 major versions ([#237](https://github.com/alphagov/govuk_app_config/pull/237))
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Adds the basics of a GOV.UK application:
- Statsd client for reporting stats
- Rails logging
- Content Security Policy generation for frontend apps
- Prometheus monitoring for EKS

## Installation

Expand Down Expand Up @@ -166,6 +167,15 @@ GovukContentSecurityPolicy.configure

Some frontend apps support languages that are not defined in the i18n gem. This provides them with our own custom rules for these languages.

## Prometheus monitoring for EKS

Create a `/config/initializers/prometheus.rb` file in the app and add the following

```ruby
require "govuk_app_config/govuk_prometheus_exporter"
GovukPrometheusExporter.configure
```

## License

[MIT License](LICENSE.md)
2 changes: 1 addition & 1 deletion lib/govuk_app_config/govuk_prometheus_exporter.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module GovukPrometheusExporter
def self.configure
unless Rails.env == "test"
unless Rails.env == "test" || (ENV["GOVUK_PROMETHEUS_EXPORTER"]) != "true"
require "prometheus_exporter"
require "prometheus_exporter/server"
require "prometheus_exporter/middleware"
Expand Down

0 comments on commit 2d38dbb

Please sign in to comment.