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