summaryrefslogtreecommitdiffstats
path: root/src/pybind/mgr/cephadm/services/monitoring.py
diff options
context:
space:
mode:
authorAdam King <47704447+adk3798@users.noreply.github.com>2024-03-19 15:03:16 +0100
committerGitHub <noreply@github.com>2024-03-19 15:03:16 +0100
commit920886ac64286bdc4c9eec10bdb0deabdd89a9e2 (patch)
tree21afd238a7476d1acb89a07089e145dfefb915e2 /src/pybind/mgr/cephadm/services/monitoring.py
parentMerge pull request #52760 from thotz/add-healthchecker-timeout-haproxy (diff)
parentmgr/cephadm: adapting unit tests to include provider file (diff)
downloadceph-920886ac64286bdc4c9eec10bdb0deabdd89a9e2.tar.xz
ceph-920886ac64286bdc4c9eec10bdb0deabdd89a9e2.zip
Merge pull request #55615 from rhcs-dashboard/grafana-mount-dashboards
mgr/cephadm: mount grafana dashboards from the path Reviewed-by: Adam King <adking@redhat.com> Reviewed-by: Pedro Gonzalez Gomez <pegonzal@redhat.com>
Diffstat (limited to 'src/pybind/mgr/cephadm/services/monitoring.py')
-rw-r--r--src/pybind/mgr/cephadm/services/monitoring.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/pybind/mgr/cephadm/services/monitoring.py b/src/pybind/mgr/cephadm/services/monitoring.py
index a8aef7377e6..4f9102d1c11 100644
--- a/src/pybind/mgr/cephadm/services/monitoring.py
+++ b/src/pybind/mgr/cephadm/services/monitoring.py
@@ -80,6 +80,14 @@ class GrafanaService(CephadmService):
self.mgr.check_mon_command(
{'prefix': 'dashboard set-grafana-api-password'}, inbuf=spec.initial_admin_password)
+ # the path of the grafana dashboards are assumed from the providers.yml.j2 file by grafana
+ grafana_dashboards_path = self.mgr.grafana_dashboards_path or '/etc/grafana/dashboards/ceph-dashboard/'
+ grafana_providers = self.mgr.template.render(
+ 'services/grafana/providers.yml.j2', {
+ 'grafana_dashboards_path': grafana_dashboards_path
+ }
+ )
+
cert, pkey = self.prepare_certificates(daemon_spec)
config_file = {
'files': {
@@ -87,8 +95,18 @@ class GrafanaService(CephadmService):
'provisioning/datasources/ceph-dashboard.yml': grafana_data_sources,
'certs/cert_file': '# generated by cephadm\n%s' % cert,
'certs/cert_key': '# generated by cephadm\n%s' % pkey,
+ 'provisioning/dashboards/default.yml': grafana_providers
}
}
+
+ # include dashboards, if present in the container
+ if os.path.exists(grafana_dashboards_path):
+ files = os.listdir(grafana_dashboards_path)
+ for file_name in files:
+ with open(os.path.join(grafana_dashboards_path, file_name), 'r', encoding='utf-8') as f:
+ dashboard = f.read()
+ config_file['files'][f'/etc/grafana/provisioning/dashboards/{file_name}'] = dashboard
+
return config_file, sorted(deps)
def prepare_certificates(self, daemon_spec: CephadmDaemonDeploySpec) -> Tuple[str, str]: