Skip to content

Commit a4caff7

Browse files
Adityashankar KiniAdityashankar Kini
authored andcommitted
Enhanced restore capability
1 parent e4f64f0 commit a4caff7

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

examples/restore_dashboards.py

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,16 @@
2828

2929
zipf = zipfile.ZipFile(dashboard_state_file, 'r')
3030

31-
32-
dashboard_conf_items = ['showAsType', 'filterRoot', 'linkMetrics',
33-
'singleTimeNavigation', 'gridConfiguration', 'responsive',
34-
'nodesNoiseFilter', 'compareWith', 'format', 'linksNoiseFilter',
35-
'filterProcesses', 'isLegendExpanded', 'inhertitTimeNavigation',
36-
'schema', 'sortAscending', 'mapDataLimit', 'metrics', 'filterExtNodes',
37-
'sorting', 'name', 'sourceExploreView', 'items', 'showAs', 'eventsFilter',
38-
'timeMode', 'isShared', 'sourceDrilldownView']
39-
4031
for info in zipf.infolist():
4132
data = zipf.read(info.filename)
42-
j = json.loads(data)
43-
k = {}
44-
for item in j.keys():
45-
if item in dashboard_conf_items:
46-
k[item] = j[item]
47-
48-
res = sdclient.create_dashboard_with_configuration(k)
33+
dboard = json.loads(data)
34+
35+
dboard['timeMode'] = {'mode' : 1}
36+
dboard['time'] = {'last' : 2 * 60 * 60 * 1000000, 'sampling' : 2 * 60 * 60 * 1000000}
37+
38+
# Single filter support for all restored dashboards
39+
# TODO: add support to get filter from saved dashboard
40+
dashboardFilter = "proc.name = cassandra"
41+
res = sdclient.create_dashboard_from_template(dboard['name'] + '-restored', dboard, dashboardFilter)
4942
if res[0] == False:
5043
print "Dashboard creation failed for dashboard name %s with error %s" % (j['name'], res[1])

0 commit comments

Comments
 (0)