Skip to content

Commit d6c452b

Browse files
author
Davide Schiera
committed
Point to documentation on sysdig.gitbooks.io
1 parent f5e30b5 commit d6c452b

File tree

1 file changed

+2
-372
lines changed

1 file changed

+2
-372
lines changed

README.md

Lines changed: 2 additions & 372 deletions
Original file line numberDiff line numberDiff line change
@@ -50,377 +50,7 @@ Every method in the SdcClient class returns **a list with two entries**. The fir
5050

5151
For an example on how to parse this output, take a look at a simple example like [get_data_simple.py](examples/get_data_simple.py)
5252

53-
Methods
53+
Reference
5454
-------
55-
#### `add_dashboard_panel`
56-
**`(self, dashboard, name, panel_type, metrics, scope=None, layout=None, sort_by=None, limit=None)`**
5755

58-
**Description**
59-
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.
60-
61-
**Arguments**
62-
- **dashboard**: dashboard to edit
63-
- **name**: name of the new panel
64-
- **panel_type**: type of the new panel. Valid values are: `timeSeries`, `top`, `number`
65-
- **metrics**: a list of dictionaries, specifying the metrics to show in the panel, and optionally, if there is only one metric, a grouping key to segment that metric by. A metric is any of the entries that can be found in the _Metrics_ section of the Explore page in Sysdig Cloud. Metric entries require an _aggregations_ section specifying how to aggregate the metric across time and groups of containers/hosts. A grouping key is any of the entries that can be found in the _Show_ or _Segment By_ sections of the Explore page in Sysdig Cloud. Refer to the examples section below for ready to use code snippets. Note, certain panels allow certain combinations of metrics and grouping keys:
66-
- `timeSeries`: 1 or more metrics OR 1 metric + 1 grouping key
67-
- `top`: 1 or more metrics OR 1 metric + 1 grouping key
68-
- `number`: 1 metric only
69-
- **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'_.
70-
- **sort_by**: Data sorting; The parameter is optional and it's a dictionary of `metric` and `mode` (it can be `desc` or `asc`)
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
72-
- **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).
73-
74-
**Success Return Value**
75-
A dictionary showing the details of the edited dashboard.
76-
77-
**Example**
78-
[examples/dashboard.py](examples/dashboard.py).
79-
80-
#### `add_email_notification_recipient`
81-
**`(self, email)`**
82-
83-
**Description**
84-
Add a new recipient for email alert notifications.
85-
**Arguments**
86-
- **email**: the email target to add.
87-
88-
**Success Return Value**
89-
A dictionary showing the updated user notifications configuration.
90-
**Example**
91-
[examples/add_notification_email.py](examples/add_notification_email.py).
92-
93-
#### `create_alert`
94-
**`(self, name, description, severity, for_atleast_s, condition, segmentby = [], segment_condition = 'ANY', user_filter = '', notify='', enabled=True, annotations={})`**
95-
96-
**Description**
97-
Create a threshold-based alert.
98-
**Arguments**
99-
- **name**: the alert name. This will appear in the Sysdig Cloud UI and in notification emails.
100-
- **description**: the alert description. This will appear in the Sysdig Cloud UI and in notification emails.
101-
- **severity**: syslog-encoded alert severity. This is a number from 0 to 7 where 0 means 'emergency' and 7 is 'debug'.
102-
- **for_atleast_s**: the number of consecutive seconds the condition must be satisfied for the alert to fire.
103-
- **condition**: the alert condition, as described here https://app.sysdigcloud.com/apidocs/#!/Alerts/post_api_alerts
104-
- **segmentby**: a list of Sysdig Cloud segmentation criteria that can be used to apply the alert to multiple entities. For example, segmenting a CPU alert by ['host.mac', 'proc.name'] allows to apply it to any process in any machine.
105-
- **segment_condition**: When _segmentby_ is specified (and therefore the alert will cover multiple entities) this field is used to determine when it will fire. In particular, you have two options for _segment_condition_: **ANY** (the alert will fire when at least one of the monitored entities satisfies the condition) and **ALL** (the alert will fire when all of the monitored entities satisfy the condition).
106-
- **user_filter**: a boolean expression combining Sysdig Cloud segmentation criteria that makes it possible to reduce the scope of the alert. For example: _kubernetes.namespace.name='production' and container.image='nginx'_.
107-
- **notify**: the type of notification you want this alert to generate. Options are _EMAIL_, _SNS_, _PAGER_DUTY_, _SYSDIG_DUMP_.
108-
- **enabled**: if True, the alert will be enabled when created.
109-
- **annotations**: an optional dictionary of custom properties that you can associate to this alert for automation or management resons
110-
111-
**Success Return Value**
112-
A dictionary describing the just created alert, with the format described at [this link](https://app.sysdigcloud.com/apidocs/#!/Alerts/post_api_alerts).
113-
**Example**
114-
[examples/create_alert.py](examples/create_alert.py).
115-
116-
#### `create_dashboard`
117-
**`(self, name)`**
118-
119-
**Description**
120-
Creates an empty dashboard. You can then add panels by using `add_dashboard_panel`.
121-
122-
**Arguments**
123-
- **name**: the name of the dashboard that will be created.
124-
125-
**Success Return Value**
126-
A dictionary showing the details of the new dashboard.
127-
128-
**Example**
129-
[examples/dashboard.py](examples/dashboard.py).
130-
131-
#### `create_dashboard_from_dashboard`
132-
**`(self, newdashname, templatename, filter)`**
133-
134-
**Description**
135-
Create a new dasboard using one of the existing dashboards as a template. You will be able to define the scope of the new dasboard.
136-
**Arguments**
137-
- **newdashname**: the name of the dashboard that will be created.
138-
- **viewname**: the name of the dasboard to use as the template, as it appears in the Sysdig Cloud dashboard page.
139-
- **filter**: a boolean expression combining Sysdig Cloud segmentation criteria defines what the new dasboard will be applied to. For example: _kubernetes.namespace.name='production' and container.image='nginx'_.
140-
141-
**Success Return Value**
142-
A dictionary showing the details of the new dashboard.
143-
**Example**
144-
[examples/create_dashboard.py](examples/create_dashboard.py).
145-
146-
#### `create_dashboard_from_view`
147-
**`(self, newdashname, viewname, filter)`**
148-
149-
**Description**
150-
Create a new dasboard using one of the Sysdig Cloud views as a template. You will be able to define the scope of the new dasboard.
151-
**Arguments**
152-
- **newdashname**: the name of the dashboard that will be created.
153-
- **viewname**: the name of the view to use as the template for the new dashboard. Thia corresponds to the name that the view has in the explore page.
154-
- **filter**: a boolean expression combining Sysdig Cloud segmentation criteria defines what the new dasboard will be applied to. For example: _kubernetes.namespace.name='production' and container.image='nginx'_.
155-
156-
**Success Return Value**
157-
A dictionary showing the details of the new dashboard.
158-
**Example**
159-
[examples/create_dashboard.py](examples/create_dashboard.py).
160-
161-
#### `create_sysdig_capture`
162-
**`(self, hostname, capture_name, duration, capture_filter='', folder='/')`**
163-
164-
**Description**
165-
Create a new sysdig capture. The capture will be immediately started.
166-
**Arguments**
167-
- **hostname**: the hostname of the instrumented host where the capture will be taken.
168-
- **capture_name**: the name of the capture.
169-
- **duration**: the duration of the capture, in seconds.
170-
- **capture_filter**: a sysdig filter expression.
171-
- **folder**: directory in the S3 bucket where the capture will be saved.
172-
173-
**Success Return Value**
174-
A dictionary showing the details of the new capture.
175-
**Example**
176-
[examples/create_sysdig_capture.py](examples/create_sysdig_capture.py).
177-
178-
#### `delete_alert`
179-
**`(self, alert)`**
180-
181-
**Description**
182-
Deletes an alert.
183-
**Arguments**
184-
- **alert**: the alert object as returned by `get_alerts()`.
185-
186-
**Success Return Value**
187-
`None`.
188-
**Example**
189-
[examples/delete_alert.py](examples/delete_alert.py).
190-
191-
#### `delete_dashboard`
192-
**`(self, dashboard)`**
193-
194-
**Description**
195-
Deletes a dashboard.
196-
**Arguments**
197-
- **dashboard**: the dashboard object as returned by `get_dashboards()`.
198-
199-
**Success Return Value**
200-
`None`.
201-
**Example**
202-
[examples/delete_dashboard.py](examples/delete_dashboard.py).
203-
204-
#### `delete_event`
205-
**`(self, event)`**
206-
207-
**Description**
208-
Deletes an event.
209-
**Arguments**
210-
- **event**: the event object as returned by `get_events()`.
211-
212-
**Success Return Value**
213-
`None`.
214-
**Example**
215-
[examples/delete_event.py](examples/delete_event.py).
216-
217-
#### `get_alerts`
218-
**`(self)`**
219-
220-
**Description**
221-
Retrieve the list of alerts configured by the user.
222-
**Success Return Value**
223-
An array of alert json objects, with the format described at [this link](https://app.sysdigcloud.com/apidocs/#!/Alerts/get_api_alerts).
224-
**Example**
225-
[examples/list_alerts.py](examples/list_alerts.py).
226-
227-
#### `get_connected_agents`
228-
**`(self)`**
229-
230-
**Description**
231-
Return the agents currently connected to Sysdig Cloud for the current user.
232-
**Success Return Value**
233-
A list of the agents with all their attributes.
234-
235-
#### `get_data`
236-
**`(self, metrics, start_ts, end_ts=0, sampling_s = 0, filter='', datasource_type='host')`**
237-
238-
**Description**
239-
This is the method you use to export metric data. It's flexible enough to offer both time-series and table-based data export.
240-
**Arguments**
241-
- **metrics**: a list of dictionaries, specifying the metrics and grouping keys that the query will return. A metric is any of the entries that can be found in the _Metrics_ section of the Explore page in sysdig cloud. Metric entries require an _aggregations_ section specifying how to aggregate the metric across time and containers/host. A grouping key is any of the entries that can be found in the _Show_ or _Segment By_ sections of the Explore page in sysdig cloud. These entries are used to apply single or hierarchical segmentation to the returned data and don't require the aggregations section. Refer to the examples section below for ready to use code snippets.
242-
- **start_ts**: the UTC time (in seconds) of the beginning of the data window. A negative value can be optionally used to indicate a relative time in the past from now. For example, -3600 means "one hour ago".
243-
- **end_ts**: the UTC time (in seconds) of the end of the data window, or 0 to indicate "now". A negative value can also be optionally used to indicate a relative time in the past from now. For example, -3600 means "one hour ago".
244-
- **sampling_s**: the duration of the samples that will be returned. 0 Means that the whole data will be returned as a single sample.
245-
- **filter**: a boolean expression combining Sysdig Cloud segmentation criteria defines what the query will be applied to. For example: _kubernetes.namespace.name='production' and container.image='nginx'_.
246-
- **datasource_type**: specify the metric source for the request, can be `container` or `host`. Most metrics, for example `cpu.used.percent` or `memory.bytes.used`, are reported by both hosts and containers. By default, host metrics are used, but if the request contains a container-specific grouping key in the metric list/filter (e.g. `container.name`), then the container source is used. In cases where grouping keys are missing or apply to both hosts and containers (e.g. `tag.Name`), datasource_type can be explicitly set to avoid any ambiguity and allow the user to select precisely what kind of data should be used for the request. [examples/get_data_datasource.py](examples/get_data_datasource.py) contains a few examples that should clarify the use of this argument.
247-
248-
**Success Return Value**
249-
A dictionary with the requested data. Data is organized in a list of time samples, each of which includes a UTC timestamp and a list of values, whose content and order reflect what was specified in the _metrics_ argument.
250-
**Examples**
251-
[examples/get_data_simple.py](examples/get_data_simple.py), [examples/get_data_advanced.py](examples/get_data_advanced.py), [examples/list_hosts.py](examples/list_hosts.py), [examples/get_data_datasource.py](examples/get_data_datasource.py).
252-
253-
#### `get_dashboards`
254-
**`(self)`**
255-
256-
**Description**
257-
Return the list of dashboards available under the given user account. This includes the dashboards created by the user and the ones shared with her by other users.
258-
**Success Return Value**
259-
A dictionary containing the list of available sampling intervals.
260-
**Example**
261-
[examples/list_dashboards.py](examples/list_dashboards.py).
262-
263-
#### `get_data_retention_info`
264-
**`(self)`**
265-
266-
**Description**
267-
Return the list of data retention intervals, with beginning and end UTC time for each of them. Sysdig Cloud performs rollups of the data it stores. This means that data is stored at different time granularities depending on how far in time it is. This call can be used to know what precision you can expect before you make a call to `get_data()`.
268-
**Success Return Value**
269-
A dictionary containing the list of available sampling intervals.
270-
**Example**
271-
[examples/print_data_retention_info.py](examples/print_data_retention_info.py).
272-
273-
#### `get_events`
274-
**`(self, name=None, from_ts=None, to_ts=None, tags=None)`**
275-
276-
**Description**
277-
Returns the list of Sysdig Cloud events.
278-
**Arguments**
279-
- **name**: filter events by name.
280-
- **from_ts**: filter events by start time. Timestamp format is in UTC (seconds).
281-
- **to_ts**: filter events by end time. Timestamp format is in UTC (seconds).
282-
- **tags**: filter events by tags. Can be, for example `tag1 = 'value1'`.
283-
284-
**Success Return Value**
285-
A dictionary containing the list of events.
286-
**Example**
287-
[examples/list_events.py](examples/list_events.py).
288-
289-
#### `get_explore_grouping_hierarchy`
290-
**`(self)`**
291-
292-
**Description**
293-
Return the user's current Explore gourping hierarchy.
294-
**Success Return Value**
295-
A list containing the list of the user's Explore grouping criteria.
296-
**Example**
297-
[examples/print_explore_grouping.py](examples/print_explore_grouping.py).
298-
299-
#### `get_metrics`
300-
**`(self)`**
301-
302-
**Description**
303-
Return the metric list that can be used for data requests/alerts/dashboards.
304-
**Success Return Value**
305-
A dictionary containing the list of available metrics.
306-
**Example**
307-
[examples/list_metrics.py](examples/list_metrics.py).
308-
309-
#### `get_n_connected_agents`
310-
**`(self)`**
311-
312-
**Description**
313-
Return the number of agents currently connected to Sysdig Cloud for the current user.
314-
**Success Return Value**
315-
An integer number.
316-
317-
#### `get_notifications`
318-
**`(self, from_ts, to_ts, state=None, resolved=None)`**
319-
320-
**Description**
321-
Returns the list of Sysdig Cloud alert notifications.
322-
**Arguments**
323-
- **from_ts**: filter events by start time. Timestamp format is in UTC (seconds).
324-
- **to_ts**: filter events by start time. Timestamp format is in UTC (seconds).
325-
- **state**: filter events by alert state. Supported values are `OK` and `ACTIVE`.
326-
- **resolved**: filter events by resolution status. Supported values are `True` and `False.
327-
328-
**Success Return Value**
329-
A dictionary containing the list of notifications.
330-
**Example**
331-
[examples/list_alert_notifications.py](examples/list_alert_notifications.py).
332-
333-
#### `get_sysdig_captures`
334-
**`(self)`**
335-
336-
**Description**
337-
Returns the list of sysdig captures for the user.
338-
**Success Return Value**
339-
A dictionary containing the list of captures.
340-
**Example**
341-
[examples/list_sysdig_captures.py](examples/list_sysdig_captures.py).
342-
343-
#### `get_user_info`
344-
**`(self)`**
345-
346-
**Description**
347-
Get details about the current user.
348-
**Success Return Value**
349-
A dictionary containing information about the user, for example its email and the maximum number of agents it can install.
350-
**Example**
351-
[examples/print_user_info.py](examples/print_user_info.py).
352-
353-
#### `find_dashboard_by`
354-
**`(self, name)`**
355-
356-
**Description**
357-
Finds dashboards with the specified name. You can then delete the dashboard (with `delete_dashboard`) or edit panels (with `add_dashboard_panel` and `remove_dashboard_panel`)
358-
359-
**Arguments**
360-
- **name**: the name of the dashboards to find.
361-
362-
**Success Return Value**
363-
A list of dictionaries of dashboards matching the specified name.
364-
365-
**Example**
366-
[examples/dashboard.py](examples/dashboard.py).
367-
368-
#### `poll_sysdig_capture`
369-
**`(self, capture)`**
370-
371-
**Description**
372-
Fetch the updated state of a sysdig capture. Can be used to poll the status of a capture that has been previously created and started with `create_sysdig_capture`.
373-
**Arguments**
374-
- **capture**: the capture object as returned by `get_sysdig_captures()` or `create_sysdig_capture()`.
375-
376-
**Success Return Value**
377-
A dictionary showing the updated details of the capture. Use the `status` field to check the progress of a capture.
378-
**Example**
379-
[examples/create_sysdig_capture.py](examples/create_sysdig_capture.py).
380-
381-
#### `post_event`
382-
**`(self, name, description=None, severity=None, event_filter=None, tags=None)`**
383-
384-
**Description**
385-
You can use this method you use to send an event to Sysdig Cloud. The events you post are available in the Events tab in the Sysdig Cloud UI and can be overlied to charts.
386-
**Arguments**
387-
- **name**: the name of the new event.
388-
- **description**: a longer description offering detailed information about the event.
389-
- **severity**: syslog style from 0 (high) to 7 (low).
390-
- **event_filter**: metadata, in Sysdig Cloud format, of nodes to associate with the event, e.g. `host.hostName = 'ip-10-1-1-1' and container.name = 'foo'`.
391-
- **tags**: a list of key-value dictionaries that can be used to tag the event. Can be used for filtering/segmenting purposes in Sysdig Cloud.
392-
393-
**Success Return Value**
394-
A dictionary describing the new event.
395-
**Example**
396-
[examples/post_event_simple.py](examples/post_event_simple.py)
397-
[examples/post_event.py](examples/post_event.py).
398-
399-
#### `remove_dashboard_panel`
400-
**`(self, dashboard, panel_name)`**
401-
402-
**Description**
403-
Removes a panel from the dashboard. The panel to remove is identified by the specified `name`.
404-
405-
**Arguments**
406-
- **name**: name of the panel to find and remove
407-
408-
**Success Return Value**
409-
A dictionary showing the details of the edited dashboard.
410-
411-
**Example**
412-
[examples/dashboard.py](examples/dashboard.py).
413-
414-
#### `update_notification_resolution`
415-
**`(self, notification, resolved)`**
416-
417-
**Description**
418-
Updates the resolution status of an alert notification.
419-
**Arguments**
420-
- **notification**: notification object as returned by `get_notifications()`.
421-
- **resolved**: new resolution status. Supported values are `True` and `False`.
422-
423-
**Success Return Value**
424-
The updated notification.
425-
**Example**
426-
[examples/resolve_alert_notifications.py](examples/resolve_alert_notifications.py).
56+
Please Refer to the [Python Script Library documentation page](https://sysdig.gitbooks.io/sysdig-cloud-api/content/python_script_library.html) for a more complete documentation of the library.

0 commit comments

Comments
 (0)