Last active
January 24, 2019 14:18
-
-
Save valeriocos/3faa9febde318ac6b9f5191429a812e0 to your computer and use it in GitHub Desktop.
Import/Export Kibana dashboards with Archimedes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# | |
# Copyright (C) 2014-2018 Bitergia | |
# | |
# This program is free software; you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation; either version 3 of the License, or | |
# (at your option) any later version. | |
# | |
# This program is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
# GNU General Public License for more details. | |
# | |
# You should have received a copy of the GNU General Public License | |
# along with this program; if not, write to the Free Software | |
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
# | |
# Authors: | |
# Valerio Cosentino <[email protected]> | |
# | |
import argparse | |
from archimedes.archimedes import Archimedes | |
DASHBOARD_TITLE2ID = [ | |
('About', 'About'), | |
('Affiliations', 'Affiliations'), | |
('Apache', 'Apache'), | |
('Askbot', 'Askbot'), | |
('Bugzilla', 'Bugzilla'), | |
('Bugzilla Backlog', 'Bugzilla-Backlog'), | |
('Bugzilla Timing', 'Bugzilla-Timing'), | |
('Confluence', 'Confluence'), | |
('Data Status', 'Data-Status'), | |
('Demographics', '15e4b020-d075-11e8-8aac-ef7fd4d8cbad'), | |
('Discourse', 'Discourse'), | |
('DockerHub', 'DockerHub'), | |
('Gerrit', 'Gerrit'), | |
('Gerrit Backlog', 'Gerrit-Backlog'), | |
('Gerrit Efficiency', '8c515590-e1de-11e8-8aac-ef7fd4d8cbad'), | |
('Gerrit Timing', 'Gerrit-Timing'), | |
('Git', 'Git'), | |
('Git Areas of Code', 'Git-Areas-of-Code'), | |
('Git Demographics', 'Git-Demographics'), | |
('Git Pair Programming', 'Git-Pair-Programming'), | |
('GitHub Issues', 'GitHub-Issues'), | |
('GitHub Issues Backlog', 'GitHub-Issues-Backlog'), | |
('GitHub Issues Efficiency', 'c3da5c20-e1c3-11e8-8aac-ef7fd4d8cbad'), | |
('GitHub Issues Timing', 'GitHub-Issues-Timing'), | |
('GitHub Pull Requests', 'GitHub-Pull-Requests'), | |
('GitHub Pull Requests Backlog', 'GitHub-Pull-Requests-Backlog'), | |
('GitHub Pull Requests Efficiency', '9663d5a0-e1dc-11e8-8aac-ef7fd4d8cbad'), | |
('GitHub Pull Requests Timing', 'GitHub-Pull-Requests-Timing'), | |
('GitLab Issues', '2e968fe0-b1bb-11e8-8aac-ef7fd4d8cbad'), | |
('Gitlab Issues Backlog', '5e03cfb0-b4f7-11e8-8aac-ef7fd4d8cbad'), | |
('GitLab Issues Efficiency', '38fe7980-f6f2-11e8-8aac-ef7fd4d8cbad'), | |
('GitLab Issues Timing', '5a542570-b508-11e8-8aac-ef7fd4d8cbad'), | |
('GitLab Merge Requests', 'b2218fd0-bc11-11e8-8aac-ef7fd4d8cbad'), | |
('GitLab Merge Requests Backlog', '078d8780-bcad-11e8-8aac-ef7fd4d8cbad'), | |
('GitLab Merge Requests Efficiency', 'bff9e0c0-fe16-11e8-8aac-ef7fd4d8cbad'), | |
('GitLab Merge Requests Timing', '3eae8110-bc1c-11e8-8aac-ef7fd4d8cbad'), | |
('Google Hits', 'Google-Hits'), | |
('IRC', 'IRC'), | |
('Jenkins', 'Jenkins'), | |
('Jenkins Export (Slow)', 'Jenkins-Export-(Slow)'), | |
('Jenkins Jobs', '00862e30-bbf7-11e8-8aac-ef7fd4d8cbad'), | |
('Jenkins Nodes', 'a41a9940-bcb1-11e8-8aac-ef7fd4d8cbad'),('Jira', 'Jira'), | |
('Jira Backlog', 'Jira-Backlog'), | |
('Jira Effort', 'Jira-Effort'), | |
('Jira Timing', 'Jira-Timing'), | |
('KIP', 'KIP'), | |
('Lifecycle', '999ea330-f7b2-11e8-865a-85ff6467a442'), | |
('Mailing Lists', 'MailingLists'), | |
('Maniphest', 'Maniphest'), | |
('Maniphest Backlog', 'Maniphest-Backlog'), | |
('Maniphest Timing', 'Maniphest-Timing'), | |
('Mattermost', 'Mattermost'), | |
('Mediawiki', 'Mediawiki'), | |
('Meetup', 'Meetup'), | |
('Meetup Locations', 'Meetup-Locations'), | |
('Mozilla Club', 'Mozilla-Club'), | |
('Community Structure by Organization', 'Community-Structure-by-Organization'), | |
('Overall Community Structure', 'Overall-Community-Structure'), | |
('Community Structure by Project', 'Community-Structure-by-Project'), | |
('Overview', 'Overview'), | |
('Redmine', 'Redmine'), | |
('Redmine Backlog', 'Redmine-Backlog'), | |
('Redmine Timing', 'Redmine-Timing'), | |
('Reps Activities', 'Reps-Activities'), | |
('Reps Events', 'Reps-Events'), | |
('RSS', 'RSS'), | |
('Slack', 'Slack'), | |
('StackOverflow', 'Stackoverflow'), | |
('Telegram', 'Telegram'), | |
('Testing', 'Testing'), | |
('Functest', 'Functest'), | |
('Twitter', 'Twitter') | |
] | |
def import_batch(archimedes, by='id', force=False, find=False): | |
for title, id in DASHBOARD_TITLE2ID: | |
print("Importing dashboard %s" % title) | |
try: | |
if by == 'id': | |
archimedes.import_from_disk(obj_type="dashboard", obj_id=id, force=force, find=find) | |
else: | |
archimedes.import_from_disk(obj_type="dashboard", obj_title=title, force=force, find=find) | |
except Exception: | |
continue | |
def export_batch(archimedes, by='id', force=False): | |
for title, id in DASHBOARD_TITLE2ID: | |
print("Exporting dashboard %s" % title) | |
try: | |
if by == 'id': | |
archimedes.export_to_disk(obj_type="dashboard", obj_id=id, force=force) | |
else: | |
archimedes.export_to_disk(obj_type="dashboard", obj_title=title, force=force) | |
except Exception: | |
continue | |
def get_params(): | |
parser = argparse.ArgumentParser(add_help=False) | |
# ex: | |
# url: 'http://admin:admin@localhost:5601' | |
# root_path: '/home/archimedes' | |
parser.add_argument('url', help='Kibana URL') | |
parser.add_argument('root_path', help='Archimedes folder') | |
args = parser.parse_args() | |
return args | |
def main(): | |
args = get_params() | |
archimedes = Archimedes(args.url, args.root_path) | |
import_batch(archimedes, by='id', force=True, find=True) | |
import_batch(archimedes, by='title', force=True, find=True) | |
export_batch(archimedes, by='id', force=True) | |
export_batch(archimedes, by='title', force=True) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment