Skip to content

Added code to update grafana dashboards on monitoring-integration start #576

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ def run(self):
'console_scripts': [
'tendrl-monitoring-integration = \
tendrl.monitoring_integration.manager:main',
'tendrl-upgrade = \
tendrl.monitoring_integration.upgrades.delete_dashboards:main',
],
},
url="http://www.redhat.com",
Expand Down
20 changes: 13 additions & 7 deletions tendrl/monitoring_integration/grafana/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,21 @@ def upload_default_dashboards():
datasource.create()
dashboards = dashboard_utils.get_all_dashboards()
for dashboard_json in dashboards:
title.append(dashboard_json["uri"].split('/')[1])

for dashboard_json in NS.config.data["dashboards"]:
if dashboard_json in title:
Copy link
Member Author

@anmolsachan anmolsachan Sep 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This if condition is checking two completely different things:
["cluster-dashboard", "brick-dashboard", "host-dashboard", "volume-dashboard"] &
['tendrl-gluster-at-a-glance', 'tendrl-gluster-hosts', 'tendrl-gluster-volumes', 'tendrl-gluster-bricks']

But its not failing as we are going down straight to creating the dashboard again. The dashboards cannot get updated as the grafana rejects the request with : {u'status': u'name-exists', u'message': u'A dashboard with the same name already exists'} .

msg = '\n' + "Dashboard " + str(dashboard_json) + \
" already exists" + '\n'
dashboard = dashboard_json["uri"].split('/')[1]
title.append(dashboard)
# Deleting already existing dashboards if present
response = dashboard_utils.delete_dashboard(dashboard)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want to delete all dashboards in every sync. I think we need to find a better way of handling this situation.

We need to see if there is an intersection/difference between the two files then only we need to update it. Otherwise, the will keep refreshing the dashboards and can cause a problem(while a user is at a particular dashboard) also it increases the number of calls on the server.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cloudbehl agreed, will see to it.

if 'title' in response:
msg = "\n Already existing %s deleted. \n" % dashboard
logger.log("debug", NS.get("publisher_id", None),
{'message': msg})
else:
msg = "\n%s delete failed with error: %s \n" % (dashboard,
str(response))
logger.log("debug", NS.get("publisher_id", None),
{'message': msg})
continue

for dashboard_json in NS.config.data["dashboards"]:
response = dashboard_utils.create_dashboard(dashboard_json)

if response.status_code == 200:
Expand Down
Empty file.
82 changes: 0 additions & 82 deletions tendrl/monitoring_integration/upgrades/delete_dashboards.py

This file was deleted.