-
Notifications
You must be signed in to change notification settings - Fork 43
Dashboards API v2 #85
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 26 commits
Commits
Show all changes
59 commits
Select commit
Hold shift + click to select a range
d35fd0a
Make example more generic
davideschiera 49467dc
Fix dashboard/panel scope definition
davideschiera 0fed9d9
Add note and refactor name
davideschiera a7d34cd
Make API endpoints customizable
davideschiera b5f0691
Move v1 to separate module
davideschiera 394622c
Support dashboards API v2
davideschiera b0f237a
Update examples to work with dashboards API v2
davideschiera 7450251
Fix import
davideschiera 56fc518
Add versioning to dashboard backups
davideschiera b11f777
Fix URL
davideschiera 37be901
Revert temporary local change
davideschiera 2604a24
Apply reviews
davideschiera 62e11b9
Add show cases/tests
davideschiera 7211dfb
Improve scope handling
davideschiera b47139c
Missing new line
davideschiera 3ff5af8
Fix scope
davideschiera 1ca4656
Revert "Fix scope"
davideschiera b2f4600
Accept some invalid scopes for now
davideschiera 312ad79
Fix dashboard save
davideschiera b16bb17
Merge branch 'fix-dashboards-lib' into dashboards-api-v2
davideschiera 3bc5205
Scaffolding dashboard conversions
davideschiera 0c1f1d2
Initial implementation of v1 => v2 migration
davideschiera efe6a32
Accept panels without scope
davideschiera e2831be
Merge branch 'fix-dashboards-lib' into dashboards-api-v2
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 900ca41
Support "not x = y" and "not x != y"
davideschiera 49c30e0
Merge branch 'fix-dashboards-lib' into dashboards-api-v2
davideschiera 49a7274
Drop support for annotations in dashboards
davideschiera 1e39476
Remove panel ID
davideschiera cd05735
Merge branch 'dashboards-api-v2' into dashboard-convert-v1-to-v2
davideschiera fbaf5d9
Remove panel ID
davideschiera f75d491
Convert scope conversion function to public/static
davideschiera 333a172
Merge branch 'fix-dashboards-lib' into dashboards-api-v2
davideschiera d7585cf
Merge branch 'dashboards-api-v2' into dashboard-convert-v1-to-v2
davideschiera 4ffa6a0
Fix fn name
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 fb57423
Merge branch 'master' into dashboards-api-v2
davideschiera 436b005
Merge changes from #84 to API v1
davideschiera df8aabb
Handle old files
davideschiera 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 ce6999d
Allow dashboards created with API v1 to be uploaded to API v2
davideschiera 4daa2fd
Fix import of topology panels
davideschiera c1b0a4f
Fix import of default dashboards
davideschiera 87d1205
Sort metrics
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
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
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,76 @@ | ||
#!/usr/bin/env python | ||
# | ||
# This example shows some examples of scope you can use for dashboards. | ||
# | ||
|
||
import getopt | ||
import os | ||
import sys | ||
sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])), '..')) | ||
from sdcclient import SdcClient | ||
|
||
# random token, since we're not going to use the API for real | ||
sdc_token = "bb8754d5-025d-4b88-a815-358fba58c4be" | ||
|
||
# | ||
# Instantiate the SDC client | ||
# | ||
sdclient = SdcClient(sdc_token) | ||
|
||
# | ||
# Scopes can be passed to most of dashboard-related functions, e.g. create_dashboard_from_file. | ||
# | ||
# NOTE: _convert_scope_string_to_expression should never be used in a user script | ||
# We're going to use it here just to demonstrate some scope options and some constraints | ||
# | ||
def evaluate(scope, expected): | ||
parsed_scope = sdclient._convert_scope_string_to_expression(scope) | ||
print '{} is valid: {}'.format(scope, parsed_scope[0] == True) | ||
|
||
if parsed_scope[0] != expected: | ||
print('Unexpected parsing result!') | ||
sys.exit(1) | ||
|
||
|
||
# simple example: tag = value | ||
evaluate('proc.name = "cassandra"', True) | ||
|
||
# NOTE: For now you can still leave values without quotes. | ||
# The API will be more strict, so please make sure you adopt the new format! | ||
evaluate('proc.name = cassandra', True) | ||
|
||
# other operators | ||
evaluate('proc.name != "cassandra"', True) | ||
evaluate('proc.name starts with "cassandra"', True) | ||
evaluate('proc.name contains "cassandra"', True) | ||
|
||
# list operators | ||
evaluate('proc.name in ("cassandra", "mysql")', True) | ||
|
||
# not-ed expressions | ||
evaluate('not proc.name starts with "cassandra"', True) | ||
evaluate('not proc.name contains "cassandra"', True) | ||
evaluate('not proc.name in ("cassandra", "mysql")', True) | ||
|
||
# you can combine multiple expressions; note that only AND'd scopes are currently supported | ||
evaluate('kubernetes.service.name = "database" and proc.name = "cassandra"', True) | ||
|
||
# the scope can obviously be omitted in the dashboard configuration | ||
evaluate('', True) | ||
evaluate(None, True) | ||
|
||
# invalid scopes will cause errors | ||
evaluate('proc.name == "cassandra"', False) # invalid operator | ||
|
||
# currently, one space is required around operands and operators -- improvements will come soon | ||
evaluate('proc.name="cassandra"', False) | ||
|
||
# | ||
# The current grammer is unable to validate all errors -- in these cases, the API will fail! | ||
# Improvements will come soon! | ||
# | ||
# Here some errors that will not be detected by the Python library, but the API will | ||
# | ||
evaluate('proc.name = "cassandra" or proc.name = "mysql"', True) # not AND'd expressions are supported | ||
evaluate('proc.name in ("cassandra\', \'mysql")', True) # mismatching quotes | ||
evaluate('proc.name in ("cassandra", "mysql"', True) # missing parenthesis |
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
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
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
from sdcclient._monitor import SdcClient | ||
from sdcclient._monitor import SdMonitorClient | ||
from sdcclient._monitor_v1 import SdMonitorClientV1 | ||
from sdcclient._secure import SdSecureClient | ||
from sdcclient._scanning import SdScanningClient |
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.
Why don't we convert that
_convert_scope_string_to_expression
into a@staticmethod
? We are not usingself
at all at its implementation and we can avoid this line and the abovesdc_token
. That should take 2 minutes ;-)Moreover, if it is marked as a
_private
method, we shouldn't be showing this example. We could make itpublic
.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.
self
: good point. I wanted to have an easy way to access the function from 2 classes (one base of the other). Your way looks simpler.