Skip to content

Commit c9fd39b

Browse files
author
Davide Schiera
committed
Replaced paging with limit parameter.
1 parent 07bc749 commit c9fd39b

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ For an example on how to parse this output, take a look at a simple example like
5353
Methods
5454
-------
5555
#### `add_dashboard_panel`
56-
**`(self, dashboard, name, type, metrics, scope=None, layout=None, sort_by=None, paging=None)`**
56+
**`(self, dashboard, name, type, metrics, scope=None, layout=None, sort_by=None, limit=None)`**
5757

5858
**Description**
5959
Adds a panel to the dashboard. A panel can be a time series, or a top chart (i.e. bar chart), or a number panel.
@@ -68,7 +68,7 @@ Adds a panel to the dashboard. A panel can be a time series, or a top chart (i.e
6868
- `number`: 1 metric only
6969
- **scope**: filter to apply to the panel; must be based on metadata available in Sysdig Cloud; Example: _kubernetes.namespace.name='production' and container.image='nginx'_.
7070
- **sort_by**: Data sorting; The parameter is optional and it's a dictionary of `metric` and `mode` (it can be `desc` or `asc`)
71-
- **paging**: Data pagination; The parameter is optional and limits the data points returned. The parameter is a dictionary of `from` and `to` with the index of the first and last point respectively
71+
- **limit**: This parameter sets the limit on the number of lines/bars shown in a `timeSeries` or `top` panel. In the case of more entities being available than the limit, the top entities according to the sort will be shown. The default value is 10 for `top` panels (for `timeSeries` the default is defined by Sysdig Cloud itself). Note that increasing the limit above 10 is not officially supported and may cause performance and rendering issues
7272
- **layout**: Size and position of the panel. The dashboard layout is defined by a grid of 12 columns, each row height is equal to the column height. For example, say you want to show 2 panels at the top: one panel might be 6 x 3 (half the width, 3 rows height) located in row 1 and column 1 (top-left corner of the viewport), the second panel might be 6 x 3 located in row 1 and position 7. The location is specified by a dictionary of `row` (row position), `col` (column position), `size_x` (width), `size_y` (height).
7373

7474
**Success Return Value**

examples/dashboard.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@
8585
{ 'id': 'cpu.used.percent', 'aggregations': { 'time': 'avg', 'group': 'avg' } }
8686
]
8787
sort_by = { 'metric': 'cpu.used.percent', 'mode': 'desc' }
88-
paging = { 'from': 0, 'to': 10 }
89-
res = sdclient.add_dashboard_panel(dashboard_configuration, panel_name, panel_type, metrics, sort_by=sort_by, paging=paging)
88+
limit = 10
89+
res = sdclient.add_dashboard_panel(dashboard_configuration, panel_name, panel_type, metrics, sort_by=sort_by, limit=limit)
9090

9191
# Check the result
9292
if res[0]:

sdcclient/_client.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -375,14 +375,12 @@ def create_dashboard(self, name):
375375
else:
376376
return [True, r.json()]
377377

378-
def add_dashboard_panel(self, dashboard, name, type, metrics, scope=None, sort_by=None, paging=None, layout=None):
378+
def add_dashboard_panel(self, dashboard, name, type, metrics, scope=None, sort_by=None, limit=None, layout=None):
379379
panel_configuration = {
380380
'name': name,
381381
'showAs': None,
382382
'showAsType': None,
383-
'format': None,
384383
'metrics': [],
385-
'filter': None,
386384
'gridConfiguration': {
387385
'col': 1,
388386
'row': 1,
@@ -448,6 +446,13 @@ def add_dashboard_panel(self, dashboard, name, type, metrics, scope=None, sort_b
448446
if type == 'timeSeries':
449447
panel_configuration['showAs'] = 'timeSeries'
450448
panel_configuration['showAsType'] = 'line'
449+
450+
if limit != None:
451+
panel_configuration['paging'] = {
452+
'from': 0,
453+
'to': limit - 1
454+
}
455+
451456
elif type == 'number':
452457
panel_configuration['showAs'] = 'summary'
453458
panel_configuration['showAsType'] = 'summary'
@@ -466,13 +471,16 @@ def add_dashboard_panel(self, dashboard, name, type, metrics, scope=None, sort_b
466471
'mode': sort_by['mode']
467472
}]
468473

469-
if paging == None:
474+
if limit == None:
470475
panel_configuration['paging'] = {
471476
'from': 0,
472477
'to': 10
473478
}
474479
else:
475-
panel_configuration['paging'] = paging
480+
panel_configuration['paging'] = {
481+
'from': 0,
482+
'to': limit - 1
483+
}
476484

477485

478486
#

0 commit comments

Comments
 (0)