-
Notifications
You must be signed in to change notification settings - Fork 43
Allow dashboards created with API v1 to be uploaded to API v2 #86
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
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
3bc5205
Scaffolding dashboard conversions
davideschiera 0c1f1d2
Initial implementation of v1 => v2 migration
davideschiera ce26a83
Scaffolding dashboard conversions
davideschiera 88dc25a
Initial implementation of v1 => v2 migration
davideschiera 387e011
Fix migration
davideschiera 1b50dbe
Add migration example
davideschiera 1b85df8
Merge remote-tracking branch 'origin/dashboard-convert-v1-to-v2' into…
davideschiera 92d4f05
Fixes and support for scope migration
davideschiera 49c4bee
Temporary change
davideschiera aa6aeac
More fixes
davideschiera 22f1bae
Comment
davideschiera cd05735
Merge branch 'dashboards-api-v2' into dashboard-convert-v1-to-v2
davideschiera fbaf5d9
Remove panel ID
davideschiera d7585cf
Merge branch 'dashboards-api-v2' into dashboard-convert-v1-to-v2
davideschiera 2f15a11
Merge branch 'dashboards-api-v2' into dashboard-convert-v1-to-v2
davideschiera dc89e1d
Fix fn name
davideschiera 8512fa6
Improve script output
davideschiera 8292983
Improve script
davideschiera 5c29924
Keep as is the GridConfiguration for panels
papajulio f895357
Merge branch 'dashboards-api-v2' into dashboard-convert-v1-to-v2
davideschiera 9dd861b
Drop layout property
davideschiera 43c4dc8
Print all errors, not just the first one
davideschiera f98d049
Fix conversion of metrics and topology panels
davideschiera File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#!/usr/bin/env python | ||
# | ||
# Save the first user dashboard to file and then use create_dashboard_from_file() | ||
# to apply the stored dasboard again with a different filter. | ||
# | ||
import os | ||
import sys | ||
import json | ||
sys.path.insert( | ||
0, os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])), '..')) | ||
from sdcclient import SdMonitorClient | ||
from sdcclient import SdMonitorClientV1 | ||
|
||
# | ||
# Parse arguments | ||
# | ||
if len(sys.argv) != 5: | ||
print( | ||
'usage: %s <sysdig-v1-url> <sysdig-v1-token> <sysdig-v2-url> <sysdig-v2-token>' | ||
% sys.argv[0]) | ||
print( | ||
'You can find your token at https://app.sysdigcloud.com/#/settings/user' | ||
) | ||
sys.exit(1) | ||
|
||
sdc_v1_url = sys.argv[1] | ||
sdc_v1_token = sys.argv[2] | ||
sdc_v2_url = sys.argv[3] | ||
sdc_v2_token = sys.argv[4] | ||
|
||
# | ||
# Instantiate the SDC client | ||
# | ||
sdclient_v2 = SdMonitorClient(sdc_v2_token, sdc_url=sdc_v2_url) | ||
sdclient_v1 = SdMonitorClientV1(sdc_v1_token, sdc_url=sdc_v1_url) | ||
|
||
# | ||
# Serialize the first user dashboard to disk | ||
# | ||
ok, res = sdclient_v1.get_dashboards() | ||
|
||
if not ok: | ||
print(res) | ||
sys.exit(1) | ||
|
||
for dashboard in res['dashboards']: | ||
file_name = '{}.json'.format(dashboard['id']) | ||
print('Saving v1 dashboard {} to file {}...'.format( | ||
dashboard['name'], file_name)) | ||
sdclient_v1.save_dashboard_to_file(dashboard, file_name) | ||
|
||
print('Importing dashboard to v2...') | ||
ok, res = sdclient_v2.create_dashboard_from_file( | ||
u'import of {}'.format(dashboard['name']), | ||
file_name, | ||
None, | ||
shared=dashboard['isShared'], | ||
public=dashboard['isPublic']) | ||
|
||
if ok: | ||
print('Dashboard {} imported!'.format(dashboard['name'])) | ||
sdclient_v2.delete_dashboard(res['dashboard']) | ||
else: | ||
print('Dashboard {} import failed:'.format(dashboard['name'])) | ||
print(res) | ||
|
||
print('\n') |
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should include the dashboard ID at this message. Otherwise the user won't be able to recognise which dashboard had a problem.