fix support for multiple dashboards 08/76108/4
authorDibya Prakash Das <dibyadascool@gmail.com>
Sat, 15 Sep 2018 10:33:39 +0000 (16:03 +0530)
committerLuis Gomez <ecelgp@gmail.com>
Sat, 15 Sep 2018 16:50:31 +0000 (16:50 +0000)
Change-Id: I7d8f9f2403ff1c0bfbc22cf16ce6a8e214c99fec
Signed-off-by: Dibya Prakash Das <dibyadascool@gmail.com>
csit/scripts/push_to_elk.py
dashboard/dash_config.yaml

index 483ab98e6aa2b1a7b79c2ba0609ba5602bdefaec..4bbc270c638fbd26833c7d6df62aebef0c02f237 100755 (executable)
@@ -190,52 +190,52 @@ with open(viz_config_path, 'r') as f:
     viz_config = yaml.safe_load(f)
 
 
-for _, i in dash_config['dashboard']['viz'].items():
-    intermediate_format, visState = vis_gen.generate(
-        i, viz_config[i['viz-template']])
-
-    searchSourceJSON = searchSourceJSON_gen.generate(
-        i, viz_config[i['viz-template']], intermediate_format['index_pattern'])
-
-    uiStateJSON = uiStateJSON_gen.generate(
-        i, viz_config[i['viz-template']])
-
-    # p(intermediate_format)
-    # p(visState)
-
-    VIZ_BODY = {
-        'type': 'visualization',
-        'visualization': {
-            "title": None,
-            "visState": None,
-            "uiStateJSON": "{}",
-            "description": None,
-            "version": 1,
-            "kibanaSavedObjectMeta": {
-                "searchSourceJSON": None
+for dashboard_id, dashboard_content in dash_config.items():
+
+    for _, i in dash_config[dashboard_id]['viz'].items():
+        intermediate_format, visState = vis_gen.generate(
+            i, viz_config[i['viz-template']])
+
+        searchSourceJSON = searchSourceJSON_gen.generate(
+            i, viz_config[i['viz-template']],
+            intermediate_format['index_pattern'])
+
+        uiStateJSON = uiStateJSON_gen.generate(
+            i, viz_config[i['viz-template']])
+
+        # p(intermediate_format)
+        # p(visState)
+
+        VIZ_BODY = {
+            'type': 'visualization',
+            'visualization': {
+                "title": None,
+                "visState": None,
+                "uiStateJSON": "{}",
+                "description": None,
+                "version": 1,
+                "kibanaSavedObjectMeta": {
+                    "searchSourceJSON": None
+                }
             }
         }
-    }
-
-    VIZ_BODY['visualization']['title'] = intermediate_format['title']
-    VIZ_BODY['visualization']['visState'] = JSONToString(visState)
-    VIZ_BODY['visualization']['uiStateJSON'] = JSONToString(uiStateJSON)
-    VIZ_BODY['visualization']['description'] = intermediate_format['desc']
-    VIZ_BODY['visualization']['kibanaSavedObjectMeta']['searchSourceJSON']  \
-        = JSONToString(
-        searchSourceJSON)
-
-    p(VIZ_BODY)
-    index = '.kibana'
-    ES_ID = 'visualization:{}'.format(i['id'])
-    res = es.index(index=index, doc_type='doc', id=ES_ID, body=VIZ_BODY)
-    print(json.dumps(res, indent=4))
 
+        VIZ_BODY['visualization']['title'] = intermediate_format['title']
+        VIZ_BODY['visualization']['visState'] = JSONToString(visState)
+        VIZ_BODY['visualization']['uiStateJSON'] = JSONToString(uiStateJSON)
+        VIZ_BODY['visualization']['description'] = intermediate_format['desc']
+        VIZ_BODY['visualization']['kibanaSavedObjectMeta']['searchSourceJSON']\
+            = JSONToString(
+            searchSourceJSON)
 
-# Create and push dashboards
+        p(VIZ_BODY)
+        index = '.kibana'
+        ES_ID = 'visualization:{}'.format(i['id'])
+        res = es.index(index=index, doc_type='doc', id=ES_ID, body=VIZ_BODY)
+        print(json.dumps(res, indent=4))
 
+    # Create and push dashboards
 
-for _, i in dash_config.items():
     DASH_BODY = {
         'type': 'dashboard',
         'dashboard': {
@@ -254,14 +254,14 @@ for _, i in dash_config.items():
         }
     }
 
-    DASH_BODY['dashboard']['title'] = i['title']
-    DASH_BODY['dashboard']['description'] = i['desc']
+    DASH_BODY['dashboard']['title'] = dashboard_content['title']
+    DASH_BODY['dashboard']['description'] = dashboard_content['desc']
     DASH_BODY['dashboard']['panelsJSON'] = JSONToString(
-        dash_gen.generate(i['viz']))
+        dash_gen.generate(dashboard_content['viz']))
 
     p(DASH_BODY)
 
     index = '.kibana'
-    ES_ID = 'dashboard:{}'.format(i['id'])
+    ES_ID = 'dashboard:{}'.format(dashboard_content['id'])
     res = es.index(index=index, doc_type='doc', id=ES_ID, body=DASH_BODY)
     print(json.dumps(res, indent=4))
index 9b153caaa22500eb3fe1e9d101b751dfad3ae2a3..6ea4d3c06bf4961c188aba98d6decd544cf093e4 100644 (file)
@@ -1,4 +1,4 @@
-dashboard:
+bgpcep:
   id: bgpcep
   title: BGP and PCEP
   desc: Dashboard for bgpcep project
@@ -7,7 +7,6 @@ dashboard:
       id: bgpcep-features-oxygen
       title: BGPCEP Features Oxygen
       viz-template: opendaylight-test-feature
-      job-name: bgpcep-csit-1node-userfeatures-all-oxygen
       y-axis:
         value_axes:
             1:
@@ -25,7 +24,6 @@ dashboard:
       id: bgpcep-features-fluorine
       title: BGPCEP Features Fluorine
       viz-template: opendaylight-test-feature
-      job-name: bgpcep-csit-1node-userfeatures-all-fluorine
       y-axis:
         value_axes:
             1:
@@ -44,7 +42,6 @@ dashboard:
       title: BGP Update Rate Oxygen
       desc: Test to measure controller BGP update rate
       viz-template: opendaylight-test-performance
-      job-name: bgpcep-csit-1node-bgp-ingest-mixed-all-oxygen
       y-axis:
         value_axes:
             1:
@@ -68,7 +65,6 @@ dashboard:
       title: BGP Update Rate Fluorine
       desc: Test to measure controller BGP update rate
       viz-template: opendaylight-test-performance
-      job-name: bgpcep-csit-1node-bgp-ingest-mixed-all-fluorine
       y-axis:
         value_axes:
             1:
@@ -87,7 +83,8 @@ dashboard:
         w: 6
         x: 6
         y: 3
-dashboard:
+
+openflowplugin:
   id: openflowplugin
   title: OpenFlow
   desc: Dashboard for openflowplugin project
@@ -96,7 +93,6 @@ dashboard:
       id: openflowplugin-features-oxygen
       title: OpenFlow Features Oxygen
       viz-template: opendaylight-test-feature
-      job-name: openflowplugin-csit-1node-flow-services-only-oxygen
       y-axis:
         value_axes:
             1:
@@ -114,7 +110,6 @@ dashboard:
       id: openflowplugin-features-fluorine
       title: OpenFlow Features Fluorine
       viz-template: opendaylight-test-feature
-      job-name: openflowplugin-csit-1node-flow-services-only-fluorine
       y-axis:
         value_axes:
             1:
@@ -132,7 +127,6 @@ dashboard:
       id: openflowplugin-clustering-oxygen
       title: OpenFlow Clustering Oxygen
       viz-template: opendaylight-test-feature
-      job-name: openflowplugin-csit-3node-clustering-only-oxygen
       y-axis:
         value_axes:
             1:
@@ -150,7 +144,6 @@ dashboard:
       id: openflowplugin-clustering-fluorine
       title: OpenFlow Clustering Fluorine
       viz-template: opendaylight-test-feature
-      job-name: openflowplugin-csit-3node-clustering-only-fluorine
       y-axis:
         value_axes:
             1:
@@ -169,7 +162,6 @@ dashboard:
       title: OpenFlow Flow Add Rate Oxygen
       desc: Test to measure controller flow add rate
       viz-template: opendaylight-test-performance
-      job-name: openflowplugin-csit-1node-perf-bulkomatic-only-oxygen
       y-axis:
         value_axes:
             1:
@@ -201,7 +193,6 @@ dashboard:
       title: OpenFlow Flow Add Rate Fluorine
       desc: Test to measure controller flow add rate
       viz-template: opendaylight-test-performance
-      job-name: openflowplugin-csit-1node-perf-bulkomatic-only-fluorine
       y-axis:
         value_axes:
             1:
@@ -233,7 +224,6 @@ dashboard:
       title: OpenFlow Cluster Flow Add Rate Oxygen
       desc: Test to measure controller flow add rate
       viz-template: opendaylight-test-performance
-      job-name: openflowplugin-csit-3node-clustering-perf-bulkomatic-only-oxygen
       y-axis:
         value_axes:
             1:
@@ -265,7 +255,6 @@ dashboard:
       title: OpenFlow Cluster Flow Add Rate Fluorine
       desc: Test to measure controller flow add rate
       viz-template: opendaylight-test-performance
-      job-name: openflowplugin-csit-3node-clustering-perf-bulkomatic-only-fluorine
       y-axis:
         value_axes:
             1: