]> git-server-git.apps.pok.os.sepia.ceph.com Git - cephmetrics.git/commitdiff
dashUpdater: remove $domain from dashboards, if domain is not configured
authorPaul Cuzner <pcuzner@redhat.com>
Fri, 7 Jul 2017 04:01:50 +0000 (16:01 +1200)
committerPaul Cuzner <pcuzner@redhat.com>
Tue, 11 Jul 2017 23:18:26 +0000 (11:18 +1200)
For environments that don't use dns, collectd will not provide a FQDN
on the metric name. In these circumstances, the dashboards are empty.

This fix looks for the domain setting, and if it's not supplied the
$domain reference in all queries is removed before the dashboard is loaded
into grafana.

dashUpdater.py

index 0d25eaf48b23898fd7afbfa236ed7a380b1eedc1..ed4bf4661d1f83701e371414d30944c7b07d086a 100644 (file)
@@ -104,6 +104,7 @@ def get_config(file_name):
             cfg.grafana_port = yaml_config.get('_grafana_port', 3000)
             cfg.home_dashboard = yaml_config.get('_home_dashboard',
                                                  'ceph-at-a-glance')
+            cfg.domain = yaml_config.get('domain', '')
             cfg.yaml = yaml_config
             return cfg
 
@@ -165,6 +166,11 @@ def load_dashboard(dashboard_dir, dashboard_name):
     if os.path.exists(sample_dashboard):
         # load it in
         dashboard_data = fread(sample_dashboard)
+
+        # if domain has not been given, we need to remove it from the queries
+        if not config.domain:
+            dashboard_data = dashboard_data.replace('$domain.', '')
+
         try:
             dashjson = json.loads(dashboard_data)
         except:
@@ -306,6 +312,9 @@ def main():
     if config.dashboards:
         vars_to_update = {k: config.yaml[k] for k in config.yaml
                           if not k.startswith('_')}
+        if 'domain' not in vars_to_update:
+            vars_to_update['domain'] = config.domain
+
     else:
         logger.error("Config file doesn't contain dashboards! Unable "
                      "to continue")