From: Sage Weil Date: Fri, 20 Mar 2020 14:27:28 +0000 (-0500) Subject: mgr/cephadm: include prom alerts, if present in the container X-Git-Tag: v15.2.1~37^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=51ff6587c872d9fc0a940980eaf233facde88a6c;p=ceph.git mgr/cephadm: include prom alerts, if present in the container The prometheus config already looks in/etc/prometheus/alerting/*, so drop this file into position. Note that the file is currently only present in SUSE builds, so that needs to be fixed still. Signed-off-by: Sage Weil (cherry picked from commit b1463998bddb67973b59930cc73901143d0961f8) --- diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index 2ebf9d29bfdc..4beab55f1647 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -630,6 +630,12 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule): 'can allow debugging daemons that encounter problems ' 'at runtime.', }, + { + 'name': 'prometheus_alerts_path', + 'type': 'str', + 'default': '/etc/prometheus/ceph/ceph_default_alerts.yml', + 'desc': 'location of alerts to include in prometheus deployments', + }, ] def __init__(self, *args, **kwargs): @@ -657,6 +663,7 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule): self.warn_on_stray_daemons = True self.warn_on_failed_host_check = True self.allow_ptrace = False + self.prometheus_alerts_path = '' self._cons = {} # type: Dict[str, Tuple[remoto.backends.BaseConnection,remoto.backends.LegacyModuleExecute]] @@ -2798,7 +2805,7 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule): """.format(", ".join(alertmgr_targets)) # generate the prometheus configuration - return { + r = { 'files': { 'prometheus.yml': """# generated by cephadm global: @@ -2820,7 +2827,15 @@ scrape_configs: alertmgr_configs=str(alertmgr_configs) ), }, - }, sorted(deps) + } + + # include alerts, if present in the container + if os.path.exists(self.prometheus_alerts_path): + with open(self.prometheus_alerts_path, "r") as f: + alerts = f.read() + r['files']['/etc/prometheus/alerting/ceph_alerts.yml'] = alerts + + return r, sorted(deps) def _generate_grafana_config(self): # type: () -> Tuple[Dict[str, Any], List[str]]