.. confval:: stale_cache_strategy
.. confval:: rbd_stats_pools
.. confval:: rbd_stats_pools_refresh_interval
+.. confval:: standby_behaviour
+.. confval:: standby_error_status_code
By default the module will accept HTTP requests on port ``9283`` on all IPv4
and IPv6 addresses on the host. The port and listen address are both
ceph config set mgr mgr/prometheus/cache false
+If you are using the prometheus module behind some kind of reverse proxy or
+loadbalancer, you can simplify discovering the active instance by switching
+to ``error``-mode::
+
+ ceph config set mgr mgr/prometheus/standby_behaviour error
+
+If set, the prometheus module will repond with a HTTP error when requesting ``/``
+from the standby instance. The default error code is 500, but you can configure
+the HTTP response code with::
+
+ ceph config set mgr mgr/prometheus/standby_error_status_code 503
+
+Valid error codes are between 400-599.
+
+To switch back to the default behaviour, simply set the config key to ``default``::
+
+ ceph config set mgr mgr/prometheus/standby_behaviour default
+
.. _prometheus-rbd-io-statistics:
RBD IO statistics
name='rbd_stats_pools_refresh_interval',
type='int',
default=300
+ ),
+ Option(
+ name='standby_behaviour',
+ type='str',
+ default='default',
+ enum_allowed=['default', 'error'],
+ runtime=True
+ ),
+ Option(
+ name='standby_error_status_code',
+ type='int',
+ default=500,
+ min=400,
+ max=599,
+ runtime=True
)
]
cherrypy.config.update({
'server.socket_host': server_addr,
'server.socket_port': server_port,
- 'engine.autoreload.on': False
+ 'engine.autoreload.on': False,
+ 'request.show_tracebacks': False
})
module = self
class Root(object):
@cherrypy.expose
def index(self) -> str:
- active_uri = module.get_active_uri()
- return '''<!DOCTYPE html>
+ standby_behaviour = module.get_module_option('standby_behaviour')
+ if standby_behaviour == 'default':
+ active_uri = module.get_active_uri()
+ return '''<!DOCTYPE html>
<html>
<head><title>Ceph Exporter</title></head>
<body>
<p><a href='{}metrics'>Metrics</a></p>
</body>
</html>'''.format(active_uri)
+ else:
+ status = module.get_module_option('standby_error_status_code')
+ raise cherrypy.HTTPError(status, message="Keep on looking")
@cherrypy.expose
def metrics(self) -> str: