Skip to content

Commit 1564842

Browse files
authored
Merge pull request ceph#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>
2 parents 63aab1c + 4281dc1 commit 1564842

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/cephadm/cephadm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2546,6 +2546,10 @@ def get_daemon_args(ctx, fsid, daemon_type, daemon_id):
25462546
if 'ports' in meta and meta['ports']:
25472547
port = meta['ports'][0]
25482548
r += [f'--web.listen-address={ip}:{port}']
2549+
if daemon_type == 'prometheus':
2550+
scheme = 'http'
2551+
host = get_fqdn()
2552+
r += [f'--web.external-url={scheme}://{host}:{port}']
25492553
if daemon_type == 'alertmanager':
25502554
config = get_parm(ctx.config_json)
25512555
peers = config.get('peers', list()) # type: ignore

src/cephadm/tests/test_cephadm.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,6 +1079,14 @@ def test_get_version_prometheus(self, _call):
10791079
version = cd.Monitoring.get_version(ctx, 'container_id', daemon_type)
10801080
assert version == '0.16.1'
10811081

1082+
def test_prometheus_external_url(self):
1083+
ctx = cd.CephadmContext()
1084+
daemon_type = 'prometheus'
1085+
daemon_id = 'home'
1086+
fsid = 'aaf5a720-13fe-4a3b-82b9-2d99b7fd9704'
1087+
args = cd.get_daemon_args(ctx, fsid, daemon_type, daemon_id)
1088+
assert any([x.startswith('--web.external-url=http://') for x in args])
1089+
10821090
@mock.patch('cephadm.call')
10831091
def test_get_version_node_exporter(self, _call):
10841092
ctx = cd.CephadmContext()

0 commit comments

Comments
 (0)