Merge pull request #46218 from votdev/issue_55595_prometheus_external_url

cephadm: prometheus: The generatorURL in alerts is only using hostname

Reviewed-by: Adam King <adking@redhat.com>
Reviewed-by: Michael Fritch <mfritch@suse.com>
Reviewed-by: Redouane Kachach <rkachach@redhat.com>
This commit is contained in:
Adam King 2022-05-17 17:15:44 -04:00 committed by GitHub
commit 15648422de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View File

@ -2546,6 +2546,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

View 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()