Metric Descriptors#
Metric Descriptors for the Google Stackdriver Monitoring API (V3).
-
class
google.cloud.monitoring.metric.
Metric
[source]# Bases:
google.cloud.monitoring.metric.Metric
A specific metric identified by specifying values for all labels.
The preferred way to construct a metric object is using the
metric()
factory method of theClient
class.Parameters: - type (string) – The metric type name.
- labels (dict) – A mapping from label names to values for all labels
enumerated in the associated
MetricDescriptor
.
-
class
google.cloud.monitoring.metric.
MetricDescriptor
(client, type_, metric_kind='METRIC_KIND_UNSPECIFIED', value_type='VALUE_TYPE_UNSPECIFIED', labels=(), unit='', description='', display_name='', name=None)[source]# Bases:
object
Specification of a metric type and its schema.
The preferred way to construct a metric descriptor object is using the
metric_descriptor()
factory method of theClient
class.Parameters: - client (
google.cloud.monitoring.client.Client
) – A client for operating on the metric descriptor. - type (string) – The metric type including a DNS name prefix. For example:
"compute.googleapis.com/instance/cpu/utilization"
- metric_kind (string) – The kind of measurement. It must be one of
MetricKind.GAUGE
,MetricKind.DELTA
, orMetricKind.CUMULATIVE
. SeeMetricKind
. - value_type (string) – The value type of the metric. It must be one of
ValueType.BOOL
,ValueType.INT64
,ValueType.DOUBLE
,ValueType.STRING
, orValueType.DISTRIBUTION
. SeeValueType
. - labels (list of
LabelDescriptor
) – A sequence of zero or more label descriptors specifying the labels used to identify a specific instance of this metric. - unit (string) – An optional unit in which the metric value is reported.
- description (string) – An optional detailed description of the metric.
- display_name (string) – An optional concise name for the metric.
- name (string or None) – The “resource name” of the metric descriptor. For example:
"projects/<project_id>/metricDescriptors/<type>"
. As retrieved from the service, this will always be specified. You can and should omit it when constructing an instance for the purpose of creating a new metric descriptor.
-
create
()[source]# Create a new metric descriptor based on this object.
Example:
>>> descriptor = client.metric_descriptor( ... 'custom.googleapis.com/my_metric', ... metric_kind=MetricKind.GAUGE, ... value_type=ValueType.DOUBLE, ... description='This is a simple example of a custom metric.') >>> descriptor.create()
The metric kind must not be
MetricKind.METRIC_KIND_UNSPECIFIED
, and the value type must not beValueType.VALUE_TYPE_UNSPECIFIED
.The
name
attribute is ignored in preparing the creation request. All attributes are overwritten by the values received in the response (normally affecting onlyname
).
- client (
-
class
google.cloud.monitoring.metric.
MetricKind
[source]# Bases:
object
Choices for the kind of measurement.
-
METRIC_KIND_UNSPECIFIED
= 'METRIC_KIND_UNSPECIFIED'# Note
An unspecified kind is not allowed in metric descriptors.
-
-
class
google.cloud.monitoring.metric.
ValueType
[source]# Bases:
object
Choices for the metric value type.
-
VALUE_TYPE_UNSPECIFIED
= 'VALUE_TYPE_UNSPECIFIED'# Note
An unspecified type is not allowed in metric descriptors.
-