Class MetricServiceClient (2.23.0-rc)

Manages metric descriptors, monitored resource descriptors, and time series data.

Equality

Instances of this class created via copy-construction or copy-assignment always compare equal. Instances created with equal std::shared_ptr<*Connection> objects compare equal. Objects that compare equal share the same underlying resources.

Performance

Creating a new instance of this class is a relatively expensive operation, new objects establish new connections to the service. In contrast, copy-construction, move-construction, and the corresponding assignment operations are relatively efficient as the copies share all underlying resources.

Thread Safety

Concurrent access to different instances of this class, even if they compare equal, is guaranteed to work. Two or more threads operating on the same instance of this class is not guaranteed to work. Since copy-construction and move-construction is a relatively efficient operation, consider using such a copy when using this class from multiple threads.

Constructors

MetricServiceClient(MetricServiceClient const &)

Copy and move support

Parameter
NameDescription
MetricServiceClient const &

MetricServiceClient(MetricServiceClient &&)

Copy and move support

Parameter
NameDescription
MetricServiceClient &&

MetricServiceClient(std::shared_ptr< MetricServiceConnection >, Options)

Parameters
NameDescription
connection std::shared_ptr< MetricServiceConnection >
opts Options

Operators

operator=(MetricServiceClient const &)

Copy and move support

Parameter
NameDescription
MetricServiceClient const &
Returns
TypeDescription
MetricServiceClient &

operator=(MetricServiceClient &&)

Copy and move support

Parameter
NameDescription
MetricServiceClient &&
Returns
TypeDescription
MetricServiceClient &

Functions

ListMonitoredResourceDescriptors(std::string const &, Options)

Lists monitored resource descriptors that match a filter.

This method does not require a Workspace.

Parameters
NameDescription
name std::string const &

Required. The project on which to execute the request. The format is:
projects/[PROJECT_ID_OR_NUMBER]

opts Options

Optional. Override the class-level options, such as retry and backoff policies.

Returns
TypeDescription
StreamRange< google::api::MonitoredResourceDescriptor >

a StreamRange to iterate of the results. See the documentation of this type for details. In brief, this class has begin() and end() member functions returning a iterator class meeting the input iterator requirements. The value type for this iterator is a StatusOr as the iteration may fail even after some values are retrieved successfully, for example, if there is a network disconnect. An empty set of results does not indicate an error, it indicates that there are no resources meeting the request criteria. On a successful iteration the StatusOr<T> contains elements of type google.api.MonitoredResourceDescriptor, or rather, the C++ class generated by Protobuf from that type. Please consult the Protobuf documentation for details on the Protobuf mapping rules.

ListMonitoredResourceDescriptors(google::monitoring::v3::ListMonitoredResourceDescriptorsRequest, Options)

Lists monitored resource descriptors that match a filter.

This method does not require a Workspace.

Parameters
NameDescription
request google::monitoring::v3::ListMonitoredResourceDescriptorsRequest

Unary RPCs, such as the one wrapped by this function, receive a single request proto message which includes all the inputs for the RPC. In this case, the proto message is a google.monitoring.v3.ListMonitoredResourceDescriptorsRequest. Proto messages are converted to C++ classes by Protobuf, using the Protobuf mapping rules.

opts Options

Optional. Override the class-level options, such as retry and backoff policies.

Returns
TypeDescription
StreamRange< google::api::MonitoredResourceDescriptor >

a StreamRange to iterate of the results. See the documentation of this type for details. In brief, this class has begin() and end() member functions returning a iterator class meeting the input iterator requirements. The value type for this iterator is a StatusOr as the iteration may fail even after some values are retrieved successfully, for example, if there is a network disconnect. An empty set of results does not indicate an error, it indicates that there are no resources meeting the request criteria. On a successful iteration the StatusOr<T> contains elements of type google.api.MonitoredResourceDescriptor, or rather, the C++ class generated by Protobuf from that type. Please consult the Protobuf documentation for details on the Protobuf mapping rules.

GetMonitoredResourceDescriptor(std::string const &, Options)

Gets a single monitored resource descriptor.

This method does not require a Workspace.

Parameters
NameDescription
name std::string const &

Required. The monitored resource descriptor to get. The format is:
projects/[PROJECT_ID_OR_NUMBER]/monitoredResourceDescriptors/[RESOURCE_TYPE]
The [RESOURCE_TYPE] is a predefined type, such as cloudsql_database.

opts Options

Optional. Override the class-level options, such as retry and backoff policies.

Returns
TypeDescription
StatusOr< google::api::MonitoredResourceDescriptor >

the result of the RPC. The response message type (google.api.MonitoredResourceDescriptor) is mapped to a C++ class using the Protobuf mapping rules. If the request fails, the StatusOr contains the error details.

GetMonitoredResourceDescriptor(google::monitoring::v3::GetMonitoredResourceDescriptorRequest const &, Options)

Gets a single monitored resource descriptor.

This method does not require a Workspace.

Parameters
NameDescription
request google::monitoring::v3::GetMonitoredResourceDescriptorRequest const &

Unary RPCs, such as the one wrapped by this function, receive a single request proto message which includes all the inputs for the RPC. In this case, the proto message is a google.monitoring.v3.GetMonitoredResourceDescriptorRequest. Proto messages are converted to C++ classes by Protobuf, using the Protobuf mapping rules.

opts Options

Optional. Override the class-level options, such as retry and backoff policies.

Returns
TypeDescription
StatusOr< google::api::MonitoredResourceDescriptor >

the result of the RPC. The response message type (google.api.MonitoredResourceDescriptor) is mapped to a C++ class using the Protobuf mapping rules. If the request fails, the StatusOr contains the error details.

ListMetricDescriptors(std::string const &, Options)

Lists metric descriptors that match a filter.

This method does not require a Workspace.

Parameters
NameDescription
name std::string const &

Required. The project on which to execute the request. The format is:
projects/[PROJECT_ID_OR_NUMBER]

opts Options

Optional. Override the class-level options, such as retry and backoff policies.

Returns
TypeDescription
StreamRange< google::api::MetricDescriptor >

a StreamRange to iterate of the results. See the documentation of this type for details. In brief, this class has begin() and end() member functions returning a iterator class meeting the input iterator requirements. The value type for this iterator is a StatusOr as the iteration may fail even after some values are retrieved successfully, for example, if there is a network disconnect. An empty set of results does not indicate an error, it indicates that there are no resources meeting the request criteria. On a successful iteration the StatusOr<T> contains elements of type google.api.MetricDescriptor, or rather, the C++ class generated by Protobuf from that type. Please consult the Protobuf documentation for details on the Protobuf mapping rules.

ListMetricDescriptors(google::monitoring::v3::ListMetricDescriptorsRequest, Options)

Lists metric descriptors that match a filter.

This method does not require a Workspace.

Parameters
NameDescription
request google::monitoring::v3::ListMetricDescriptorsRequest

Unary RPCs, such as the one wrapped by this function, receive a single request proto message which includes all the inputs for the RPC. In this case, the proto message is a google.monitoring.v3.ListMetricDescriptorsRequest. Proto messages are converted to C++ classes by Protobuf, using the Protobuf mapping rules.

opts Options

Optional. Override the class-level options, such as retry and backoff policies.

Returns
TypeDescription
StreamRange< google::api::MetricDescriptor >

a StreamRange to iterate of the results. See the documentation of this type for details. In brief, this class has begin() and end() member functions returning a iterator class meeting the input iterator requirements. The value type for this iterator is a StatusOr as the iteration may fail even after some values are retrieved successfully, for example, if there is a network disconnect. An empty set of results does not indicate an error, it indicates that there are no resources meeting the request criteria. On a successful iteration the StatusOr<T> contains elements of type google.api.MetricDescriptor, or rather, the C++ class generated by Protobuf from that type. Please consult the Protobuf documentation for details on the Protobuf mapping rules.

GetMetricDescriptor(std::string const &, Options)

Gets a single metric descriptor.

This method does not require a Workspace.

Parameters
NameDescription
name std::string const &

Required. The metric descriptor on which to execute the request. The format is:
projects/[PROJECT_ID_OR_NUMBER]/metricDescriptors/[METRIC_ID]
An example value of [METRIC_ID] is "compute.googleapis.com/instance/disk/read_bytes_count".

opts Options

Optional. Override the class-level options, such as retry and backoff policies.

Returns
TypeDescription
StatusOr< google::api::MetricDescriptor >

the result of the RPC. The response message type (google.api.MetricDescriptor) is mapped to a C++ class using the Protobuf mapping rules. If the request fails, the StatusOr contains the error details.

GetMetricDescriptor(google::monitoring::v3::GetMetricDescriptorRequest const &, Options)

Gets a single metric descriptor.

This method does not require a Workspace.

Parameters
NameDescription
request google::monitoring::v3::GetMetricDescriptorRequest const &

Unary RPCs, such as the one wrapped by this function, receive a single request proto message which includes all the inputs for the RPC. In this case, the proto message is a google.monitoring.v3.GetMetricDescriptorRequest. Proto messages are converted to C++ classes by Protobuf, using the Protobuf mapping rules.

opts Options

Optional. Override the class-level options, such as retry and backoff policies.

Returns
TypeDescription
StatusOr< google::api::MetricDescriptor >

the result of the RPC. The response message type (google.api.MetricDescriptor) is mapped to a C++ class using the Protobuf mapping rules. If the request fails, the StatusOr contains the error details.

CreateMetricDescriptor(std::string const &, google::api::MetricDescriptor const &, Options)

Creates a new metric descriptor.

The creation is executed asynchronously and callers may check the returned operation to track its progress. User-created metric descriptors define custom metrics.

Parameters
NameDescription
name std::string const &

Required. The project on which to execute the request. The format is: 4 projects/[PROJECT_ID_OR_NUMBER]

metric_descriptor google::api::MetricDescriptor const &

Required. The new custom metric descriptor.

opts Options

Optional. Override the class-level options, such as retry and backoff policies.

Returns
TypeDescription
StatusOr< google::api::MetricDescriptor >

the result of the RPC. The response message type (google.api.MetricDescriptor) is mapped to a C++ class using the Protobuf mapping rules. If the request fails, the StatusOr contains the error details.

CreateMetricDescriptor(google::monitoring::v3::CreateMetricDescriptorRequest const &, Options)

Creates a new metric descriptor.

The creation is executed asynchronously and callers may check the returned operation to track its progress. User-created metric descriptors define custom metrics.

Parameters
NameDescription
request google::monitoring::v3::CreateMetricDescriptorRequest const &

Unary RPCs, such as the one wrapped by this function, receive a single request proto message which includes all the inputs for the RPC. In this case, the proto message is a google.monitoring.v3.CreateMetricDescriptorRequest. Proto messages are converted to C++ classes by Protobuf, using the Protobuf mapping rules.

opts Options

Optional. Override the class-level options, such as retry and backoff policies.

Returns
TypeDescription
StatusOr< google::api::MetricDescriptor >

the result of the RPC. The response message type (google.api.MetricDescriptor) is mapped to a C++ class using the Protobuf mapping rules. If the request fails, the StatusOr contains the error details.

DeleteMetricDescriptor(std::string const &, Options)

Deletes a metric descriptor.

Only user-created custom metrics can be deleted.

Parameters
NameDescription
name std::string const &

Required. The metric descriptor on which to execute the request. The format is:
projects/[PROJECT_ID_OR_NUMBER]/metricDescriptors/[METRIC_ID]
An example of [METRIC_ID] is: "custom.googleapis.com/my_test_metric".

opts Options

Optional. Override the class-level options, such as retry and backoff policies.

Returns
TypeDescription
Status

a Status object. If the request failed, the status contains the details of the failure.

DeleteMetricDescriptor(google::monitoring::v3::DeleteMetricDescriptorRequest const &, Options)

Deletes a metric descriptor.

Only user-created custom metrics can be deleted.

Parameters
NameDescription
request google::monitoring::v3::DeleteMetricDescriptorRequest const &

Unary RPCs, such as the one wrapped by this function, receive a single request proto message which includes all the inputs for the RPC. In this case, the proto message is a google.monitoring.v3.DeleteMetricDescriptorRequest. Proto messages are converted to C++ classes by Protobuf, using the Protobuf mapping rules.

opts Options

Optional. Override the class-level options, such as retry and backoff policies.

Returns
TypeDescription
Status

a Status object. If the request failed, the status contains the details of the failure.

ListTimeSeries(std::string const &, std::string const &, google::monitoring::v3::TimeInterval const &, google::monitoring::v3::ListTimeSeriesRequest::TimeSeriesView, Options)

Lists time series that match a filter.

This method does not require a Workspace.

Parameters
NameDescription
name std::string const &

Required. The project, organization or folder on which to execute the request. The format is:
projects/[PROJECT_ID_OR_NUMBER] organizations/[ORGANIZATION_ID] folders/[FOLDER_ID]

filter std::string const &

Required. A monitoring filter that specifies which time series should be returned. The filter must specify a single metric type, and can additionally specify metric labels and other information. For example:
metric.type = "compute.googleapis.com/instance/cpu/usage_time" AND metric.labels.instance_name = "my-instance-name"

interval google::monitoring::v3::TimeInterval const &

Required. The time interval for which results should be returned. Only time series that contain data points in the specified interval are included in the response.

view google::monitoring::v3::ListTimeSeriesRequest::TimeSeriesView

Required. Specifies which information is returned about the time series.

opts Options

Optional. Override the class-level options, such as retry and backoff policies.

Returns
TypeDescription
StreamRange< google::monitoring::v3::TimeSeries >

a StreamRange to iterate of the results. See the documentation of this type for details. In brief, this class has begin() and end() member functions returning a iterator class meeting the input iterator requirements. The value type for this iterator is a StatusOr as the iteration may fail even after some values are retrieved successfully, for example, if there is a network disconnect. An empty set of results does not indicate an error, it indicates that there are no resources meeting the request criteria. On a successful iteration the StatusOr<T> contains elements of type google.monitoring.v3.TimeSeries, or rather, the C++ class generated by Protobuf from that type. Please consult the Protobuf documentation for details on the Protobuf mapping rules.

ListTimeSeries(google::monitoring::v3::ListTimeSeriesRequest, Options)

Lists time series that match a filter.

This method does not require a Workspace.

Parameters
NameDescription
request google::monitoring::v3::ListTimeSeriesRequest

Unary RPCs, such as the one wrapped by this function, receive a single request proto message which includes all the inputs for the RPC. In this case, the proto message is a google.monitoring.v3.ListTimeSeriesRequest. Proto messages are converted to C++ classes by Protobuf, using the Protobuf mapping rules.

opts Options

Optional. Override the class-level options, such as retry and backoff policies.

Returns
TypeDescription
StreamRange< google::monitoring::v3::TimeSeries >

a StreamRange to iterate of the results. See the documentation of this type for details. In brief, this class has begin() and end() member functions returning a iterator class meeting the input iterator requirements. The value type for this iterator is a StatusOr as the iteration may fail even after some values are retrieved successfully, for example, if there is a network disconnect. An empty set of results does not indicate an error, it indicates that there are no resources meeting the request criteria. On a successful iteration the StatusOr<T> contains elements of type google.monitoring.v3.TimeSeries, or rather, the C++ class generated by Protobuf from that type. Please consult the Protobuf documentation for details on the Protobuf mapping rules.

CreateTimeSeries(std::string const &, std::vector< google::monitoring::v3::TimeSeries > const &, Options)

Creates or adds data to one or more time series.

The response is empty if all time series in the request were written. If any time series could not be written, a corresponding failure message is included in the error response.

Parameters
NameDescription
name std::string const &

Required. The project on which to execute the request. The format is:
projects/[PROJECT_ID_OR_NUMBER]

time_series std::vector< google::monitoring::v3::TimeSeries > const &

Required. The new data to be added to a list of time series. Adds at most one data point to each of several time series. The new data point must be more recent than any other point in its time series. Each TimeSeries value must fully specify a unique time series by supplying all label values for the metric and the monitored resource.
The maximum number of TimeSeries objects per Create request is 200.

opts Options

Optional. Override the class-level options, such as retry and backoff policies.

Returns
TypeDescription
Status

a Status object. If the request failed, the status contains the details of the failure.

CreateTimeSeries(google::monitoring::v3::CreateTimeSeriesRequest const &, Options)

Creates or adds data to one or more time series.

The response is empty if all time series in the request were written. If any time series could not be written, a corresponding failure message is included in the error response.

Parameters
NameDescription
request google::monitoring::v3::CreateTimeSeriesRequest const &

Unary RPCs, such as the one wrapped by this function, receive a single request proto message which includes all the inputs for the RPC. In this case, the proto message is a google.monitoring.v3.CreateTimeSeriesRequest. Proto messages are converted to C++ classes by Protobuf, using the Protobuf mapping rules.

opts Options

Optional. Override the class-level options, such as retry and backoff policies.

Returns
TypeDescription
Status

a Status object. If the request failed, the status contains the details of the failure.

CreateServiceTimeSeries(std::string const &, std::vector< google::monitoring::v3::TimeSeries > const &, Options)

Creates or adds data to one or more service time series.

A service time series is a time series for a metric from a Google Cloud service. The response is empty if all time series in the request were written. If any time series could not be written, a corresponding failure message is included in the error response. This endpoint rejects writes to user-defined metrics. This method is only for use by Google Cloud services. Use projects.timeSeries.create instead.

Parameters
NameDescription
name std::string const &

Required. The project on which to execute the request. The format is:
projects/[PROJECT_ID_OR_NUMBER]

time_series std::vector< google::monitoring::v3::TimeSeries > const &

Required. The new data to be added to a list of time series. Adds at most one data point to each of several time series. The new data point must be more recent than any other point in its time series. Each TimeSeries value must fully specify a unique time series by supplying all label values for the metric and the monitored resource.
The maximum number of TimeSeries objects per Create request is 200.

opts Options

Optional. Override the class-level options, such as retry and backoff policies.

Returns
TypeDescription
Status

a Status object. If the request failed, the status contains the details of the failure.

CreateServiceTimeSeries(google::monitoring::v3::CreateTimeSeriesRequest const &, Options)

Creates or adds data to one or more service time series.

A service time series is a time series for a metric from a Google Cloud service. The response is empty if all time series in the request were written. If any time series could not be written, a corresponding failure message is included in the error response. This endpoint rejects writes to user-defined metrics. This method is only for use by Google Cloud services. Use projects.timeSeries.create instead.

Parameters
NameDescription
request google::monitoring::v3::CreateTimeSeriesRequest const &

Unary RPCs, such as the one wrapped by this function, receive a single request proto message which includes all the inputs for the RPC. In this case, the proto message is a google.monitoring.v3.CreateTimeSeriesRequest. Proto messages are converted to C++ classes by Protobuf, using the Protobuf mapping rules.

opts Options

Optional. Override the class-level options, such as retry and backoff policies.

Returns
TypeDescription
Status

a Status object. If the request failed, the status contains the details of the failure.

AsyncCreateTimeSeries(std::string const &, std::vector< google::monitoring::v3::TimeSeries > const &, Options)

Creates or adds data to one or more time series.

The response is empty if all time series in the request were written. If any time series could not be written, a corresponding failure message is included in the error response.

Parameters
NameDescription
name std::string const &

Required. The project on which to execute the request. The format is:
projects/[PROJECT_ID_OR_NUMBER]

time_series std::vector< google::monitoring::v3::TimeSeries > const &

Required. The new data to be added to a list of time series. Adds at most one data point to each of several time series. The new data point must be more recent than any other point in its time series. Each TimeSeries value must fully specify a unique time series by supplying all label values for the metric and the monitored resource.
The maximum number of TimeSeries objects per Create request is 200.

opts Options

Optional. Override the class-level options, such as retry and backoff policies.

Returns
TypeDescription
future< Status >

a Status object. If the request failed, the status contains the details of the failure.

AsyncCreateTimeSeries(google::monitoring::v3::CreateTimeSeriesRequest const &, Options)

Creates or adds data to one or more time series.

The response is empty if all time series in the request were written. If any time series could not be written, a corresponding failure message is included in the error response.

Parameters
NameDescription
request google::monitoring::v3::CreateTimeSeriesRequest const &

Unary RPCs, such as the one wrapped by this function, receive a single request proto message which includes all the inputs for the RPC. In this case, the proto message is a google.monitoring.v3.CreateTimeSeriesRequest. Proto messages are converted to C++ classes by Protobuf, using the Protobuf mapping rules.

opts Options

Optional. Override the class-level options, such as retry and backoff policies.

Returns
TypeDescription
future< Status >

a Status object. If the request failed, the status contains the details of the failure.