]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
cephadm: prometheus: The generatorURL in alerts is only using hostname
authorVolker Theile <vtheile@suse.com>
Tue, 10 May 2022 13:25:54 +0000 (15:25 +0200)
committerVolker Theile <vtheile@suse.com>
Wed, 11 May 2022 10:42:18 +0000 (12:42 +0200)
Prometheus is currently using only the hostname in the 'generatorURL' of an alert which causes issues when clicking on the URL in the Ceph Dashboard or somewhere else, because in most cases the hostname of the node that is running the Prometheus container is not resolvable.

To fix that the command line argument '--web.external-url' must be appended in the systemd unit file of the Prometheus container, e.g. '--web.external-url http://foo.bar:9095' whereas a FQDN hostname is used.

Fixes: https://tracker.ceph.com/issues/55595
Signed-off-by: Volker Theile <vtheile@suse.com>
src/cephadm/cephadm
src/cephadm/tests/test_cephadm.py

index 5eb3f1e321a8befa4e7129ce337d59b50eca1be9..e19f05f1990ec610fee218d43b32c911fc20025b 100755 (executable)
@@ -2545,6 +2545,10 @@ def get_daemon_args(ctx, fsid, daemon_type, daemon_id):
                 if 'ports' in meta and meta['ports']:
                     port = meta['ports'][0]
             r += [f'--web.listen-address={ip}:{port}']
+            if daemon_type == 'prometheus':
+                scheme = 'http'
+                host = get_fqdn()
+                r += [f'--web.external-url={scheme}://{host}:{port}']
         if daemon_type == 'alertmanager':
             config = get_parm(ctx.config_json)
             peers = config.get('peers', list())  # type: ignore
index 597f4047c810bf46a0ac71081f2b3260ed9ec434..aed95d85fc058e7655b95c3fad1cd2748497c5d0 100644 (file)
@@ -1079,6 +1079,14 @@ class TestMonitoring(object):
         version = cd.Monitoring.get_version(ctx, 'container_id', daemon_type)
         assert version == '0.16.1'
 
+    def test_prometheus_external_url(self):
+        ctx = cd.CephadmContext()
+        daemon_type = 'prometheus'
+        daemon_id = 'home'
+        fsid = 'aaf5a720-13fe-4a3b-82b9-2d99b7fd9704'
+        args = cd.get_daemon_args(ctx, fsid, daemon_type, daemon_id)
+        assert any([x.startswith('--web.external-url=http://') for x in args])
+
     @mock.patch('cephadm.call')
     def test_get_version_node_exporter(self, _call):
         ctx = cd.CephadmContext()