xref: /aosp_15_r20/external/googleapis/google/monitoring/v3/metric_service.proto (revision d5c09012810ac0c9f33fe448fb6da8260d444cc9)
1// Copyright 2023 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15syntax = "proto3";
16
17package google.monitoring.v3;
18
19import "google/api/annotations.proto";
20import "google/api/client.proto";
21import "google/api/field_behavior.proto";
22import "google/api/metric.proto";
23import "google/api/monitored_resource.proto";
24import "google/api/resource.proto";
25import "google/monitoring/v3/common.proto";
26import "google/monitoring/v3/metric.proto";
27import "google/protobuf/empty.proto";
28import "google/rpc/status.proto";
29
30option csharp_namespace = "Google.Cloud.Monitoring.V3";
31option go_package = "cloud.google.com/go/monitoring/apiv3/v2/monitoringpb;monitoringpb";
32option java_multiple_files = true;
33option java_outer_classname = "MetricServiceProto";
34option java_package = "com.google.monitoring.v3";
35option php_namespace = "Google\\Cloud\\Monitoring\\V3";
36option ruby_package = "Google::Cloud::Monitoring::V3";
37option (google.api.resource_definition) = {
38  type: "monitoring.googleapis.com/MetricDescriptor"
39  pattern: "projects/{project}/metricDescriptors/{metric_descriptor=**}"
40  pattern: "organizations/{organization}/metricDescriptors/{metric_descriptor=**}"
41  pattern: "folders/{folder}/metricDescriptors/{metric_descriptor=**}"
42  pattern: "*"
43  history: ORIGINALLY_SINGLE_PATTERN
44};
45option (google.api.resource_definition) = {
46  type: "monitoring.googleapis.com/MonitoredResourceDescriptor"
47  pattern: "projects/{project}/monitoredResourceDescriptors/{monitored_resource_descriptor}"
48  pattern: "organizations/{organization}/monitoredResourceDescriptors/{monitored_resource_descriptor}"
49  pattern: "folders/{folder}/monitoredResourceDescriptors/{monitored_resource_descriptor}"
50  pattern: "*"
51  history: ORIGINALLY_SINGLE_PATTERN
52};
53option (google.api.resource_definition) = {
54  type: "monitoring.googleapis.com/Workspace"
55  pattern: "projects/{project}"
56  pattern: "workspaces/{workspace}"
57};
58option (google.api.resource_definition) = {
59  type: "monitoring.googleapis.com/TimeSeries"
60  pattern: "projects/{project}/timeSeries/{time_series}"
61  pattern: "organizations/{organization}/timeSeries/{time_series}"
62  pattern: "folders/{folder}/timeSeries/{time_series}"
63};
64
65// Manages metric descriptors, monitored resource descriptors, and
66// time series data.
67service MetricService {
68  option (google.api.default_host) = "monitoring.googleapis.com";
69  option (google.api.oauth_scopes) =
70      "https://www.googleapis.com/auth/cloud-platform,"
71      "https://www.googleapis.com/auth/monitoring,"
72      "https://www.googleapis.com/auth/monitoring.read,"
73      "https://www.googleapis.com/auth/monitoring.write";
74
75  // Lists monitored resource descriptors that match a filter.
76  rpc ListMonitoredResourceDescriptors(ListMonitoredResourceDescriptorsRequest)
77      returns (ListMonitoredResourceDescriptorsResponse) {
78    option (google.api.http) = {
79      get: "/v3/{name=projects/*}/monitoredResourceDescriptors"
80    };
81    option (google.api.method_signature) = "name";
82  }
83
84  // Gets a single monitored resource descriptor.
85  rpc GetMonitoredResourceDescriptor(GetMonitoredResourceDescriptorRequest)
86      returns (google.api.MonitoredResourceDescriptor) {
87    option (google.api.http) = {
88      get: "/v3/{name=projects/*/monitoredResourceDescriptors/**}"
89    };
90    option (google.api.method_signature) = "name";
91  }
92
93  // Lists metric descriptors that match a filter.
94  rpc ListMetricDescriptors(ListMetricDescriptorsRequest)
95      returns (ListMetricDescriptorsResponse) {
96    option (google.api.http) = {
97      get: "/v3/{name=projects/*}/metricDescriptors"
98    };
99    option (google.api.method_signature) = "name";
100  }
101
102  // Gets a single metric descriptor.
103  rpc GetMetricDescriptor(GetMetricDescriptorRequest)
104      returns (google.api.MetricDescriptor) {
105    option (google.api.http) = {
106      get: "/v3/{name=projects/*/metricDescriptors/**}"
107    };
108    option (google.api.method_signature) = "name";
109  }
110
111  // Creates a new metric descriptor.
112  // The creation is executed asynchronously.
113  // User-created metric descriptors define
114  // [custom metrics](https://cloud.google.com/monitoring/custom-metrics).
115  // The metric descriptor is updated if it already exists,
116  // except that metric labels are never removed.
117  rpc CreateMetricDescriptor(CreateMetricDescriptorRequest)
118      returns (google.api.MetricDescriptor) {
119    option (google.api.http) = {
120      post: "/v3/{name=projects/*}/metricDescriptors"
121      body: "metric_descriptor"
122    };
123    option (google.api.method_signature) = "name,metric_descriptor";
124  }
125
126  // Deletes a metric descriptor. Only user-created
127  // [custom metrics](https://cloud.google.com/monitoring/custom-metrics) can be
128  // deleted.
129  rpc DeleteMetricDescriptor(DeleteMetricDescriptorRequest)
130      returns (google.protobuf.Empty) {
131    option (google.api.http) = {
132      delete: "/v3/{name=projects/*/metricDescriptors/**}"
133    };
134    option (google.api.method_signature) = "name";
135  }
136
137  // Lists time series that match a filter.
138  rpc ListTimeSeries(ListTimeSeriesRequest) returns (ListTimeSeriesResponse) {
139    option (google.api.http) = {
140      get: "/v3/{name=projects/*}/timeSeries"
141      additional_bindings { get: "/v3/{name=organizations/*}/timeSeries" }
142      additional_bindings { get: "/v3/{name=folders/*}/timeSeries" }
143    };
144    option (google.api.method_signature) = "name,filter,interval,view";
145  }
146
147  // Creates or adds data to one or more time series.
148  // The response is empty if all time series in the request were written.
149  // If any time series could not be written, a corresponding failure message is
150  // included in the error response.
151  // This method does not support
152  // [resource locations constraint of an organization
153  // policy](https://cloud.google.com/resource-manager/docs/organization-policy/defining-locations#setting_the_organization_policy).
154  rpc CreateTimeSeries(CreateTimeSeriesRequest)
155      returns (google.protobuf.Empty) {
156    option (google.api.http) = {
157      post: "/v3/{name=projects/*}/timeSeries"
158      body: "*"
159    };
160    option (google.api.method_signature) = "name,time_series";
161  }
162
163  // Creates or adds data to one or more service time series. A service time
164  // series is a time series for a metric from a Google Cloud service. The
165  // response is empty if all time series in the request were written. If any
166  // time series could not be written, a corresponding failure message is
167  // included in the error response. This endpoint rejects writes to
168  // user-defined metrics.
169  // This method is only for use by Google Cloud services. Use
170  // [projects.timeSeries.create][google.monitoring.v3.MetricService.CreateTimeSeries]
171  // instead.
172  rpc CreateServiceTimeSeries(CreateTimeSeriesRequest)
173      returns (google.protobuf.Empty) {
174    option (google.api.http) = {
175      post: "/v3/{name=projects/*}/timeSeries:createService"
176      body: "*"
177    };
178    option (google.api.method_signature) = "name,time_series";
179  }
180}
181
182// The `ListMonitoredResourceDescriptors` request.
183message ListMonitoredResourceDescriptorsRequest {
184  // Required. The
185  // [project](https://cloud.google.com/monitoring/api/v3#project_name) on which
186  // to execute the request. The format is:
187  //
188  //     projects/[PROJECT_ID_OR_NUMBER]
189  string name = 5 [
190    (google.api.field_behavior) = REQUIRED,
191    (google.api.resource_reference) = {
192      child_type: "monitoring.googleapis.com/MonitoredResourceDescriptor"
193    }
194  ];
195
196  // An optional [filter](https://cloud.google.com/monitoring/api/v3/filters)
197  // describing the descriptors to be returned.  The filter can reference the
198  // descriptor's type and labels. For example, the following filter returns
199  // only Google Compute Engine descriptors that have an `id` label:
200  //
201  //     resource.type = starts_with("gce_") AND resource.label:id
202  string filter = 2;
203
204  // A positive number that is the maximum number of results to return.
205  int32 page_size = 3;
206
207  // If this field is not empty then it must contain the `nextPageToken` value
208  // returned by a previous call to this method.  Using this field causes the
209  // method to return additional results from the previous method call.
210  string page_token = 4;
211}
212
213// The `ListMonitoredResourceDescriptors` response.
214message ListMonitoredResourceDescriptorsResponse {
215  // The monitored resource descriptors that are available to this project
216  // and that match `filter`, if present.
217  repeated google.api.MonitoredResourceDescriptor resource_descriptors = 1;
218
219  // If there are more results than have been returned, then this field is set
220  // to a non-empty value.  To see the additional results,
221  // use that value as `page_token` in the next call to this method.
222  string next_page_token = 2;
223}
224
225// The `GetMonitoredResourceDescriptor` request.
226message GetMonitoredResourceDescriptorRequest {
227  // Required. The monitored resource descriptor to get.  The format is:
228  //
229  //     projects/[PROJECT_ID_OR_NUMBER]/monitoredResourceDescriptors/[RESOURCE_TYPE]
230  //
231  // The `[RESOURCE_TYPE]` is a predefined type, such as
232  // `cloudsql_database`.
233  string name = 3 [
234    (google.api.field_behavior) = REQUIRED,
235    (google.api.resource_reference) = {
236      type: "monitoring.googleapis.com/MonitoredResourceDescriptor"
237    }
238  ];
239}
240
241// The `ListMetricDescriptors` request.
242message ListMetricDescriptorsRequest {
243  // Required. The
244  // [project](https://cloud.google.com/monitoring/api/v3#project_name) on which
245  // to execute the request. The format is:
246  //
247  //     projects/[PROJECT_ID_OR_NUMBER]
248  string name = 5 [
249    (google.api.field_behavior) = REQUIRED,
250    (google.api.resource_reference) = {
251      child_type: "monitoring.googleapis.com/MetricDescriptor"
252    }
253  ];
254
255  // If this field is empty, all custom and
256  // system-defined metric descriptors are returned.
257  // Otherwise, the [filter](https://cloud.google.com/monitoring/api/v3/filters)
258  // specifies which metric descriptors are to be
259  // returned. For example, the following filter matches all
260  // [custom metrics](https://cloud.google.com/monitoring/custom-metrics):
261  //
262  //     metric.type = starts_with("custom.googleapis.com/")
263  string filter = 2;
264
265  // A positive number that is the maximum number of results to return. The
266  // default and maximum value is 10,000. If a page_size <= 0 or > 10,000 is
267  // submitted, will instead return a maximum of 10,000 results.
268  int32 page_size = 3;
269
270  // If this field is not empty then it must contain the `nextPageToken` value
271  // returned by a previous call to this method.  Using this field causes the
272  // method to return additional results from the previous method call.
273  string page_token = 4;
274}
275
276// The `ListMetricDescriptors` response.
277message ListMetricDescriptorsResponse {
278  // The metric descriptors that are available to the project
279  // and that match the value of `filter`, if present.
280  repeated google.api.MetricDescriptor metric_descriptors = 1;
281
282  // If there are more results than have been returned, then this field is set
283  // to a non-empty value.  To see the additional results,
284  // use that value as `page_token` in the next call to this method.
285  string next_page_token = 2;
286}
287
288// The `GetMetricDescriptor` request.
289message GetMetricDescriptorRequest {
290  // Required. The metric descriptor on which to execute the request. The format
291  // is:
292  //
293  //     projects/[PROJECT_ID_OR_NUMBER]/metricDescriptors/[METRIC_ID]
294  //
295  // An example value of `[METRIC_ID]` is
296  // `"compute.googleapis.com/instance/disk/read_bytes_count"`.
297  string name = 3 [
298    (google.api.field_behavior) = REQUIRED,
299    (google.api.resource_reference) = {
300      type: "monitoring.googleapis.com/MetricDescriptor"
301    }
302  ];
303}
304
305// The `CreateMetricDescriptor` request.
306message CreateMetricDescriptorRequest {
307  // Required. The
308  // [project](https://cloud.google.com/monitoring/api/v3#project_name) on which
309  // to execute the request. The format is:
310  // 4
311  //     projects/[PROJECT_ID_OR_NUMBER]
312  string name = 3 [
313    (google.api.field_behavior) = REQUIRED,
314    (google.api.resource_reference) = {
315      child_type: "monitoring.googleapis.com/MetricDescriptor"
316    }
317  ];
318
319  // Required. The new [custom
320  // metric](https://cloud.google.com/monitoring/custom-metrics) descriptor.
321  google.api.MetricDescriptor metric_descriptor = 2
322      [(google.api.field_behavior) = REQUIRED];
323}
324
325// The `DeleteMetricDescriptor` request.
326message DeleteMetricDescriptorRequest {
327  // Required. The metric descriptor on which to execute the request. The format
328  // is:
329  //
330  //     projects/[PROJECT_ID_OR_NUMBER]/metricDescriptors/[METRIC_ID]
331  //
332  // An example of `[METRIC_ID]` is:
333  // `"custom.googleapis.com/my_test_metric"`.
334  string name = 3 [
335    (google.api.field_behavior) = REQUIRED,
336    (google.api.resource_reference) = {
337      type: "monitoring.googleapis.com/MetricDescriptor"
338    }
339  ];
340}
341
342// The `ListTimeSeries` request.
343message ListTimeSeriesRequest {
344  // Controls which fields are returned by `ListTimeSeries*`.
345  enum TimeSeriesView {
346    // Returns the identity of the metric(s), the time series,
347    // and the time series data.
348    FULL = 0;
349
350    // Returns the identity of the metric and the time series resource,
351    // but not the time series data.
352    HEADERS = 1;
353  }
354
355  // Required. The
356  // [project](https://cloud.google.com/monitoring/api/v3#project_name),
357  // organization or folder on which to execute the request. The format is:
358  //
359  //     projects/[PROJECT_ID_OR_NUMBER]
360  //     organizations/[ORGANIZATION_ID]
361  //     folders/[FOLDER_ID]
362  string name = 10 [
363    (google.api.field_behavior) = REQUIRED,
364    (google.api.resource_reference) = {
365      child_type: "monitoring.googleapis.com/TimeSeries"
366    }
367  ];
368
369  // Required. A [monitoring
370  // filter](https://cloud.google.com/monitoring/api/v3/filters) that specifies
371  // which time series should be returned.  The filter must specify a single
372  // metric type, and can additionally specify metric labels and other
373  // information. For example:
374  //
375  //     metric.type = "compute.googleapis.com/instance/cpu/usage_time" AND
376  //         metric.labels.instance_name = "my-instance-name"
377  string filter = 2 [(google.api.field_behavior) = REQUIRED];
378
379  // Required. The time interval for which results should be returned. Only time
380  // series that contain data points in the specified interval are included in
381  // the response.
382  TimeInterval interval = 4 [(google.api.field_behavior) = REQUIRED];
383
384  // Specifies the alignment of data points in individual time series as
385  // well as how to combine the retrieved time series across specified labels.
386  //
387  // By default (if no `aggregation` is explicitly specified), the raw time
388  // series data is returned.
389  Aggregation aggregation = 5;
390
391  // Apply a second aggregation after `aggregation` is applied. May only be
392  // specified if `aggregation` is specified.
393  Aggregation secondary_aggregation = 11;
394
395  // Unsupported: must be left blank. The points in each time series are
396  // currently returned in reverse time order (most recent to oldest).
397  string order_by = 6;
398
399  // Required. Specifies which information is returned about the time series.
400  TimeSeriesView view = 7 [(google.api.field_behavior) = REQUIRED];
401
402  // A positive number that is the maximum number of results to return. If
403  // `page_size` is empty or more than 100,000 results, the effective
404  // `page_size` is 100,000 results. If `view` is set to `FULL`, this is the
405  // maximum number of `Points` returned. If `view` is set to `HEADERS`, this is
406  // the maximum number of `TimeSeries` returned.
407  int32 page_size = 8;
408
409  // If this field is not empty then it must contain the `nextPageToken` value
410  // returned by a previous call to this method.  Using this field causes the
411  // method to return additional results from the previous method call.
412  string page_token = 9;
413}
414
415// The `ListTimeSeries` response.
416message ListTimeSeriesResponse {
417  // One or more time series that match the filter included in the request.
418  repeated TimeSeries time_series = 1;
419
420  // If there are more results than have been returned, then this field is set
421  // to a non-empty value.  To see the additional results,
422  // use that value as `page_token` in the next call to this method.
423  string next_page_token = 2;
424
425  // Query execution errors that may have caused the time series data returned
426  // to be incomplete.
427  repeated google.rpc.Status execution_errors = 3;
428
429  // The unit in which all `time_series` point values are reported. `unit`
430  // follows the UCUM format for units as seen in
431  // https://unitsofmeasure.org/ucum.html.
432  // If different `time_series` have different units (for example, because they
433  // come from different metric types, or a unit is absent), then `unit` will be
434  // "{not_a_unit}".
435  string unit = 5;
436}
437
438// The `CreateTimeSeries` request.
439message CreateTimeSeriesRequest {
440  // Required. The
441  // [project](https://cloud.google.com/monitoring/api/v3#project_name) on which
442  // to execute the request. The format is:
443  //
444  //     projects/[PROJECT_ID_OR_NUMBER]
445  string name = 3 [
446    (google.api.field_behavior) = REQUIRED,
447    (google.api.resource_reference) = {
448      type: "cloudresourcemanager.googleapis.com/Project"
449    }
450  ];
451
452  // Required. The new data to be added to a list of time series.
453  // Adds at most one data point to each of several time series.  The new data
454  // point must be more recent than any other point in its time series.  Each
455  // `TimeSeries` value must fully specify a unique time series by supplying
456  // all label values for the metric and the monitored resource.
457  //
458  // The maximum number of `TimeSeries` objects per `Create` request is 200.
459  repeated TimeSeries time_series = 2 [(google.api.field_behavior) = REQUIRED];
460}
461
462// DEPRECATED. Used to hold per-time-series error status.
463message CreateTimeSeriesError {
464  // DEPRECATED. Time series ID that resulted in the `status` error.
465  TimeSeries time_series = 1 [deprecated = true];
466
467  // DEPRECATED. The status of the requested write operation for `time_series`.
468  google.rpc.Status status = 2 [deprecated = true];
469}
470
471// Summary of the result of a failed request to write data to a time series.
472message CreateTimeSeriesSummary {
473  // Detailed information about an error category.
474  message Error {
475    // The status of the requested write operation.
476    google.rpc.Status status = 1;
477
478    // The number of points that couldn't be written because of `status`.
479    int32 point_count = 2;
480  }
481
482  // The number of points in the request.
483  int32 total_point_count = 1;
484
485  // The number of points that were successfully written.
486  int32 success_point_count = 2;
487
488  // The number of points that failed to be written. Order is not guaranteed.
489  repeated Error errors = 3;
490}
491
492// The `QueryTimeSeries` request.
493message QueryTimeSeriesRequest {
494  // Required. The
495  // [project](https://cloud.google.com/monitoring/api/v3#project_name) on which
496  // to execute the request. The format is:
497  //
498  //     projects/[PROJECT_ID_OR_NUMBER]
499  string name = 1 [(google.api.field_behavior) = REQUIRED];
500
501  // Required. The query in the [Monitoring Query
502  // Language](https://cloud.google.com/monitoring/mql/reference) format.
503  // The default time zone is in UTC.
504  string query = 7 [(google.api.field_behavior) = REQUIRED];
505
506  // A positive number that is the maximum number of time_series_data to return.
507  int32 page_size = 9;
508
509  // If this field is not empty then it must contain the `nextPageToken` value
510  // returned by a previous call to this method.  Using this field causes the
511  // method to return additional results from the previous method call.
512  string page_token = 10;
513}
514
515// The `QueryTimeSeries` response.
516message QueryTimeSeriesResponse {
517  // The descriptor for the time series data.
518  TimeSeriesDescriptor time_series_descriptor = 8;
519
520  // The time series data.
521  repeated TimeSeriesData time_series_data = 9;
522
523  // If there are more results than have been returned, then this field is set
524  // to a non-empty value.  To see the additional results, use that value as
525  // `page_token` in the next call to this method.
526  string next_page_token = 10;
527
528  // Query execution errors that may have caused the time series data returned
529  // to be incomplete. The available data will be available in the
530  // response.
531  repeated google.rpc.Status partial_errors = 11;
532}
533
534// This is an error detail intended to be used with INVALID_ARGUMENT errors.
535message QueryErrorList {
536  // Errors in parsing the time series query language text. The number of errors
537  // in the response may be limited.
538  repeated QueryError errors = 1;
539
540  // A summary of all the errors.
541  string error_summary = 2;
542}
543