GitLab Maintenance Mode should be exported via a Prometheus Metric
Background
GitLab Maintenance Mode is a administrator-controlled mode which disables non-admin users from using a GitLab instance.
This can be useful during an upgrade, a planned Geo failover and for other purposes.
For the purposes of monitoring and measuring how much time an instance is in maintenance mode, it would be useful to expose the status of maintenance mode via a Prometheus metric.
This metric is required for GitLab Dedicated / ~"theme::horse" - see https://gitlab.com/gitlab-com/gl-infra/gitlab-dedicated/team/-/issues/1231 for further details.
Proposal
- Rails/web worker expose the status of maintenance mode via a new Prometheus gauge metric. The gauge can have two values -
0
indicates the worker is not running maintenance mode,1
indicates the worker is running in maintenance mode. - The name of the Prometheus gauge metric is
gitlab_maintenance_mode
.
Implementation
Alternative implementations may exist, this is just one illustrative example.
The current value for maintenance_mode
could be memoized in the self.maintenance_mode?
method: https://gitlab.com/gitlab-org/gitlab/-/blob/f50075762cf33d3841b88bb191770776b07ede77/lib/gitlab.rb#L111
When the value changes, the Prometheus gauge metric is updated.