]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: include prom alerts, if present in the container
authorSage Weil <sage@redhat.com>
Fri, 20 Mar 2020 14:27:28 +0000 (09:27 -0500)
committerSage Weil <sage@redhat.com>
Tue, 24 Mar 2020 20:38:14 +0000 (15:38 -0500)
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 <sage@redhat.com>
(cherry picked from commit b1463998bddb67973b59930cc73901143d0961f8)

src/pybind/mgr/cephadm/module.py

index 2ebf9d29bfdcf122cbaedcb16cf83e120a09489c..4beab55f1647a992009df408d7cea8f299ad6b51 100644 (file)
@@ -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]]