datalab.stackdriver.monitoring Module

class datalab.stackdriver.monitoring.Groups(project_id=None, context=None)[source]

Represents a list of Stackdriver groups for a project.

Initializes the Groups for a Stackdriver project.

Parameters:
  • project_id – An optional project ID or number to override the one provided by the context.
  • context – An optional Context object to use instead of the global default.
as_dataframe(pattern=u'*', max_rows=None)[source]

Creates a pandas dataframe from the groups that match the filters.

Parameters:
  • pattern – An optional pattern to further filter the groups. This can include Unix shell-style wildcards. E.g. "Production *", "*-backend".
  • max_rows – The maximum number of groups to return. If None, return all.
Returns:

A pandas dataframe containing matching groups.

list(pattern=u'*')[source]

Returns a list of groups that match the filters.

Parameters:pattern – An optional pattern to filter the groups based on their display name. This can include Unix shell-style wildcards. E.g. "Production*".
Returns:A list of Group objects that match the filters.
class datalab.stackdriver.monitoring.MetricDescriptors(filter_string=None, type_prefix=None, project_id=None, context=None)[source]

MetricDescriptors object for retrieving the metric descriptors.

Initializes the MetricDescriptors based on the specified filters.

Parameters:
  • filter_string – An optional filter expression describing the resource descriptors to be returned.
  • type_prefix – An optional prefix constraining the selected metric types. This adds metric.type = starts_with("<prefix>") to the filter.
  • project_id – An optional project ID or number to override the one provided by the context.
  • context – An optional Context object to use instead of the global default.
as_dataframe(pattern='*', max_rows=None)[source]

Creates a pandas dataframe from the descriptors that match the filters.

Parameters:
  • pattern – An optional pattern to further filter the descriptors. This can include Unix shell-style wildcards. E.g. "compute*", "*/cpu/load_??m".
  • max_rows – The maximum number of descriptors to return. If None, return all.
Returns:

A pandas dataframe containing matching metric descriptors.

list(pattern='*')[source]

Returns a list of metric descriptors that match the filters.

Parameters:pattern – An optional pattern to further filter the descriptors. This can include Unix shell-style wildcards. E.g. "compute*", "*cpu/load_??m".
Returns:A list of MetricDescriptor objects that match the filters.
class datalab.stackdriver.monitoring.ResourceDescriptors(filter_string=None, project_id=None, context=None)[source]

ResourceDescriptors object for retrieving the resource descriptors.

Initializes the ResourceDescriptors based on the specified filters.

Parameters:
  • filter_string – An optional filter expression describing the resource descriptors to be returned.
  • project_id – An optional project ID or number to override the one provided by the context.
  • context – An optional Context object to use instead of the global default.
as_dataframe(pattern='*', max_rows=None)[source]

Creates a pandas dataframe from the descriptors that match the filters.

Parameters:
  • pattern – An optional pattern to further filter the descriptors. This can include Unix shell-style wildcards. E.g. "aws*", "*cluster*".
  • max_rows – The maximum number of descriptors to return. If None, return all.
Returns:

A pandas dataframe containing matching resource descriptors.

list(pattern='*')[source]

Returns a list of resource descriptors that match the filters.

Parameters:pattern – An optional pattern to further filter the descriptors. This can include Unix shell-style wildcards. E.g. "aws*", "*cluster*".
Returns:A list of ResourceDescriptor objects that match the filters.
class datalab.stackdriver.monitoring.Query(metric_type='compute.googleapis.com/instance/cpu/utilization', end_time=None, days=0, hours=0, minutes=0, project_id=None, context=None)[source]

Query object for retrieving metric data.

Initializes the core query parameters.

The start time (exclusive) is determined by combining the values of days, hours, and minutes, and subtracting the resulting duration from the end time.

It is also allowed to omit the end time and duration here, in which case select_interval() must be called before the query is executed.

Parameters:
  • metric_type – The metric type name. The default value is Query.DEFAULT_METRIC_TYPE, but please note that this default value is provided only for demonstration purposes and is subject to change.
  • end_time – The end time (inclusive) of the time interval for which results should be returned, as a datetime object. The default is the start of the current minute.
  • days – The number of days in the time interval.
  • hours – The number of hours in the time interval.
  • minutes – The number of minutes in the time interval.
  • project_id – An optional project ID or number to override the one provided by the context.
  • context – An optional Context object to use instead of the global default.
Raises:

ValueErrorend_time was specified but days, hours, and minutes are all zero. If you really want to specify a point in time, use select_interval().

metadata()[source]

Retrieves the metadata for the query.

class datalab.stackdriver.monitoring.QueryMetadata(query)[source]

QueryMetadata object contains the metadata of a timeseries query.

Initializes the QueryMetadata given the query object.

Parameters:query – A Query object.
as_dataframe(max_rows=None)[source]

Creates a pandas dataframe from the query metadata.

Parameters:max_rows – The maximum number of timeseries metadata to return. If None, return all.
Returns:A pandas dataframe containing the resource type, resource labels and metric labels. Each row in this dataframe corresponds to the metadata from one time series.
metric_type

Returns the metric type in the underlying query.

resource_types

Returns a set containing resource types in the query result.