Skip to content
This repository was archived by the owner on Oct 2, 2023. It is now read-only.

Commit 8a42810

Browse files
feat: Added support for secondary aggregation when querying metrics (#471)
This PR was generated using Autosynth. 🌈 Synth log will be available here: https://source.cloud.google.com/results/invocations/b9dd8574-10ed-4799-8623-fde41a50803e/targets - [ ] To automatically regenerate this PR, check this box. (May take up to 24 hours.) PiperOrigin-RevId: 364422694 Source-Link: googleapis/googleapis@2124b62 feat: Added support for Monitoring Query Language: https://cloud.google.com/monitoring/mql feat: Added support for units in the MetricService feat: Added total_size to the response of ListAlertPolicies fix: Un-deprecated cluster_istio for service monitoring feat: Added IstioCanonicalService for service monitoring feat: Added creation and mutation records to notification channels feat: Added support for querying metrics for folders and organizations fix: Extended the default deadline for UpdateGroup to 180s
1 parent 0cec022 commit 8a42810

File tree

74 files changed

+10035
-1288
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+10035
-1288
lines changed

google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClient.java

+27-19
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ public AlertPolicyServiceStub getStub() {
171171

172172
// AUTO-GENERATED DOCUMENTATION AND METHOD.
173173
/**
174-
* Lists the existing alerting policies for the project.
174+
* Lists the existing alerting policies for the workspace.
175175
*
176176
* <p>Sample code:
177177
*
@@ -202,7 +202,7 @@ public final ListAlertPoliciesPagedResponse listAlertPolicies(ResourceName name)
202202

203203
// AUTO-GENERATED DOCUMENTATION AND METHOD.
204204
/**
205-
* Lists the existing alerting policies for the project.
205+
* Lists the existing alerting policies for the workspace.
206206
*
207207
* <p>Sample code:
208208
*
@@ -233,7 +233,7 @@ public final ListAlertPoliciesPagedResponse listAlertPolicies(OrganizationName n
233233

234234
// AUTO-GENERATED DOCUMENTATION AND METHOD.
235235
/**
236-
* Lists the existing alerting policies for the project.
236+
* Lists the existing alerting policies for the workspace.
237237
*
238238
* <p>Sample code:
239239
*
@@ -264,7 +264,7 @@ public final ListAlertPoliciesPagedResponse listAlertPolicies(ProjectName name)
264264

265265
// AUTO-GENERATED DOCUMENTATION AND METHOD.
266266
/**
267-
* Lists the existing alerting policies for the project.
267+
* Lists the existing alerting policies for the workspace.
268268
*
269269
* <p>Sample code:
270270
*
@@ -293,7 +293,7 @@ public final ListAlertPoliciesPagedResponse listAlertPolicies(String name) {
293293

294294
// AUTO-GENERATED DOCUMENTATION AND METHOD.
295295
/**
296-
* Lists the existing alerting policies for the project.
296+
* Lists the existing alerting policies for the workspace.
297297
*
298298
* <p>Sample code:
299299
*
@@ -324,7 +324,7 @@ public final ListAlertPoliciesPagedResponse listAlertPolicies(ListAlertPoliciesR
324324

325325
// AUTO-GENERATED DOCUMENTATION AND METHOD.
326326
/**
327-
* Lists the existing alerting policies for the project.
327+
* Lists the existing alerting policies for the workspace.
328328
*
329329
* <p>Sample code:
330330
*
@@ -356,7 +356,7 @@ public final ListAlertPoliciesPagedResponse listAlertPolicies(ListAlertPoliciesR
356356

357357
// AUTO-GENERATED DOCUMENTATION AND METHOD.
358358
/**
359-
* Lists the existing alerting policies for the project.
359+
* Lists the existing alerting policies for the workspace.
360360
*
361361
* <p>Sample code:
362362
*
@@ -507,9 +507,11 @@ public final UnaryCallable<GetAlertPolicyRequest, AlertPolicy> getAlertPolicyCal
507507
* @param name Required. The project in which to create the alerting policy. The format is:
508508
* <p>projects/[PROJECT_ID_OR_NUMBER]
509509
* <p>Note that this field names the parent container in which the alerting policy will be
510-
* written, not the name of the created policy. The alerting policy that is returned will have
511-
* a name that contains a normalized representation of this name as a prefix but adds a suffix
512-
* of the form `/alertPolicies/[ALERT_POLICY_ID]`, identifying the policy in the container.
510+
* written, not the name of the created policy. |name| must be a host project of a workspace,
511+
* otherwise INVALID_ARGUMENT error will return. The alerting policy that is returned will
512+
* have a name that contains a normalized representation of this name as a prefix but adds a
513+
* suffix of the form `/alertPolicies/[ALERT_POLICY_ID]`, identifying the policy in the
514+
* container.
513515
* @param alertPolicy Required. The requested alerting policy. You should omit the `name` field in
514516
* this policy. The name will be returned in the new policy, including a new
515517
* `[ALERT_POLICY_ID]` value.
@@ -541,9 +543,11 @@ public final AlertPolicy createAlertPolicy(ResourceName name, AlertPolicy alertP
541543
* @param name Required. The project in which to create the alerting policy. The format is:
542544
* <p>projects/[PROJECT_ID_OR_NUMBER]
543545
* <p>Note that this field names the parent container in which the alerting policy will be
544-
* written, not the name of the created policy. The alerting policy that is returned will have
545-
* a name that contains a normalized representation of this name as a prefix but adds a suffix
546-
* of the form `/alertPolicies/[ALERT_POLICY_ID]`, identifying the policy in the container.
546+
* written, not the name of the created policy. |name| must be a host project of a workspace,
547+
* otherwise INVALID_ARGUMENT error will return. The alerting policy that is returned will
548+
* have a name that contains a normalized representation of this name as a prefix but adds a
549+
* suffix of the form `/alertPolicies/[ALERT_POLICY_ID]`, identifying the policy in the
550+
* container.
547551
* @param alertPolicy Required. The requested alerting policy. You should omit the `name` field in
548552
* this policy. The name will be returned in the new policy, including a new
549553
* `[ALERT_POLICY_ID]` value.
@@ -575,9 +579,11 @@ public final AlertPolicy createAlertPolicy(OrganizationName name, AlertPolicy al
575579
* @param name Required. The project in which to create the alerting policy. The format is:
576580
* <p>projects/[PROJECT_ID_OR_NUMBER]
577581
* <p>Note that this field names the parent container in which the alerting policy will be
578-
* written, not the name of the created policy. The alerting policy that is returned will have
579-
* a name that contains a normalized representation of this name as a prefix but adds a suffix
580-
* of the form `/alertPolicies/[ALERT_POLICY_ID]`, identifying the policy in the container.
582+
* written, not the name of the created policy. |name| must be a host project of a workspace,
583+
* otherwise INVALID_ARGUMENT error will return. The alerting policy that is returned will
584+
* have a name that contains a normalized representation of this name as a prefix but adds a
585+
* suffix of the form `/alertPolicies/[ALERT_POLICY_ID]`, identifying the policy in the
586+
* container.
581587
* @param alertPolicy Required. The requested alerting policy. You should omit the `name` field in
582588
* this policy. The name will be returned in the new policy, including a new
583589
* `[ALERT_POLICY_ID]` value.
@@ -610,9 +616,11 @@ public final AlertPolicy createAlertPolicy(ProjectName name, AlertPolicy alertPo
610616
* @param name Required. The project in which to create the alerting policy. The format is:
611617
* <p>projects/[PROJECT_ID_OR_NUMBER]
612618
* <p>Note that this field names the parent container in which the alerting policy will be
613-
* written, not the name of the created policy. The alerting policy that is returned will have
614-
* a name that contains a normalized representation of this name as a prefix but adds a suffix
615-
* of the form `/alertPolicies/[ALERT_POLICY_ID]`, identifying the policy in the container.
619+
* written, not the name of the created policy. |name| must be a host project of a workspace,
620+
* otherwise INVALID_ARGUMENT error will return. The alerting policy that is returned will
621+
* have a name that contains a normalized representation of this name as a prefix but adds a
622+
* suffix of the form `/alertPolicies/[ALERT_POLICY_ID]`, identifying the policy in the
623+
* container.
616624
* @param alertPolicy Required. The requested alerting policy. You should omit the `name` field in
617625
* this policy. The name will be returned in the new policy, including a new
618626
* `[ALERT_POLICY_ID]` value.

google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/MetricServiceClient.java

+112-8
Original file line numberDiff line numberDiff line change
@@ -1136,6 +1136,102 @@ public final void deleteMetricDescriptor(DeleteMetricDescriptorRequest request)
11361136
return stub.deleteMetricDescriptorCallable();
11371137
}
11381138

1139+
// AUTO-GENERATED DOCUMENTATION AND METHOD.
1140+
/**
1141+
* Lists time series that match a filter. This method does not require a Workspace.
1142+
*
1143+
* <p>Sample code:
1144+
*
1145+
* <pre>{@code
1146+
* try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
1147+
* ResourceName name = ResourceName.of("[FOLDER]");
1148+
* String filter = "filter-1274492040";
1149+
* TimeInterval interval = TimeInterval.newBuilder().build();
1150+
* ListTimeSeriesRequest.TimeSeriesView view = ListTimeSeriesRequest.TimeSeriesView.forNumber(0);
1151+
* for (TimeSeries element :
1152+
* metricServiceClient.listTimeSeries(name, filter, interval, view).iterateAll()) {
1153+
* // doThingsWith(element);
1154+
* }
1155+
* }
1156+
* }</pre>
1157+
*
1158+
* @param name Required. The project, organization or folder on which to execute the request. The
1159+
* format is:
1160+
* <p>projects/[PROJECT_ID_OR_NUMBER] organizations/[ORGANIZATION_ID] folders/[FOLDER_ID]
1161+
* @param filter Required. A [monitoring
1162+
* filter](https://cloud.google.com/monitoring/api/v3/filters) that specifies which time
1163+
* series should be returned. The filter must specify a single metric type, and can
1164+
* additionally specify metric labels and other information. For example:
1165+
* <p>metric.type = "compute.googleapis.com/instance/cpu/usage_time" AND
1166+
* metric.labels.instance_name = "my-instance-name"
1167+
* @param interval Required. The time interval for which results should be returned. Only time
1168+
* series that contain data points in the specified interval are included in the response.
1169+
* @param view Required. Specifies which information is returned about the time series.
1170+
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
1171+
*/
1172+
public final ListTimeSeriesPagedResponse listTimeSeries(
1173+
ResourceName name,
1174+
String filter,
1175+
TimeInterval interval,
1176+
ListTimeSeriesRequest.TimeSeriesView view) {
1177+
ListTimeSeriesRequest request =
1178+
ListTimeSeriesRequest.newBuilder()
1179+
.setName(name == null ? null : name.toString())
1180+
.setFilter(filter)
1181+
.setInterval(interval)
1182+
.setView(view)
1183+
.build();
1184+
return listTimeSeries(request);
1185+
}
1186+
1187+
// AUTO-GENERATED DOCUMENTATION AND METHOD.
1188+
/**
1189+
* Lists time series that match a filter. This method does not require a Workspace.
1190+
*
1191+
* <p>Sample code:
1192+
*
1193+
* <pre>{@code
1194+
* try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
1195+
* OrganizationName name = OrganizationName.of("[ORGANIZATION]");
1196+
* String filter = "filter-1274492040";
1197+
* TimeInterval interval = TimeInterval.newBuilder().build();
1198+
* ListTimeSeriesRequest.TimeSeriesView view = ListTimeSeriesRequest.TimeSeriesView.forNumber(0);
1199+
* for (TimeSeries element :
1200+
* metricServiceClient.listTimeSeries(name, filter, interval, view).iterateAll()) {
1201+
* // doThingsWith(element);
1202+
* }
1203+
* }
1204+
* }</pre>
1205+
*
1206+
* @param name Required. The project, organization or folder on which to execute the request. The
1207+
* format is:
1208+
* <p>projects/[PROJECT_ID_OR_NUMBER] organizations/[ORGANIZATION_ID] folders/[FOLDER_ID]
1209+
* @param filter Required. A [monitoring
1210+
* filter](https://cloud.google.com/monitoring/api/v3/filters) that specifies which time
1211+
* series should be returned. The filter must specify a single metric type, and can
1212+
* additionally specify metric labels and other information. For example:
1213+
* <p>metric.type = "compute.googleapis.com/instance/cpu/usage_time" AND
1214+
* metric.labels.instance_name = "my-instance-name"
1215+
* @param interval Required. The time interval for which results should be returned. Only time
1216+
* series that contain data points in the specified interval are included in the response.
1217+
* @param view Required. Specifies which information is returned about the time series.
1218+
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
1219+
*/
1220+
public final ListTimeSeriesPagedResponse listTimeSeries(
1221+
OrganizationName name,
1222+
String filter,
1223+
TimeInterval interval,
1224+
ListTimeSeriesRequest.TimeSeriesView view) {
1225+
ListTimeSeriesRequest request =
1226+
ListTimeSeriesRequest.newBuilder()
1227+
.setName(name == null ? null : name.toString())
1228+
.setFilter(filter)
1229+
.setInterval(interval)
1230+
.setView(view)
1231+
.build();
1232+
return listTimeSeries(request);
1233+
}
1234+
11391235
// AUTO-GENERATED DOCUMENTATION AND METHOD.
11401236
/**
11411237
* Lists time series that match a filter. This method does not require a Workspace.
@@ -1155,8 +1251,9 @@ public final void deleteMetricDescriptor(DeleteMetricDescriptorRequest request)
11551251
* }
11561252
* }</pre>
11571253
*
1158-
* @param name Required. The project on which to execute the request. The format is:
1159-
* <p>projects/[PROJECT_ID_OR_NUMBER]
1254+
* @param name Required. The project, organization or folder on which to execute the request. The
1255+
* format is:
1256+
* <p>projects/[PROJECT_ID_OR_NUMBER] organizations/[ORGANIZATION_ID] folders/[FOLDER_ID]
11601257
* @param filter Required. A [monitoring
11611258
* filter](https://cloud.google.com/monitoring/api/v3/filters) that specifies which time
11621259
* series should be returned. The filter must specify a single metric type, and can
@@ -1191,7 +1288,7 @@ public final ListTimeSeriesPagedResponse listTimeSeries(
11911288
*
11921289
* <pre>{@code
11931290
* try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
1194-
* String name = ProjectName.of("[PROJECT]").toString();
1291+
* String name = TimeSeriesName.ofProjectTimeSeriesName("[PROJECT]", "[TIME_SERIES]").toString();
11951292
* String filter = "filter-1274492040";
11961293
* TimeInterval interval = TimeInterval.newBuilder().build();
11971294
* ListTimeSeriesRequest.TimeSeriesView view = ListTimeSeriesRequest.TimeSeriesView.forNumber(0);
@@ -1202,8 +1299,9 @@ public final ListTimeSeriesPagedResponse listTimeSeries(
12021299
* }
12031300
* }</pre>
12041301
*
1205-
* @param name Required. The project on which to execute the request. The format is:
1206-
* <p>projects/[PROJECT_ID_OR_NUMBER]
1302+
* @param name Required. The project, organization or folder on which to execute the request. The
1303+
* format is:
1304+
* <p>projects/[PROJECT_ID_OR_NUMBER] organizations/[ORGANIZATION_ID] folders/[FOLDER_ID]
12071305
* @param filter Required. A [monitoring
12081306
* filter](https://cloud.google.com/monitoring/api/v3/filters) that specifies which time
12091307
* series should be returned. The filter must specify a single metric type, and can
@@ -1240,10 +1338,12 @@ public final ListTimeSeriesPagedResponse listTimeSeries(
12401338
* try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
12411339
* ListTimeSeriesRequest request =
12421340
* ListTimeSeriesRequest.newBuilder()
1243-
* .setName(ProjectName.of("[PROJECT]").toString())
1341+
* .setName(
1342+
* TimeSeriesName.ofProjectTimeSeriesName("[PROJECT]", "[TIME_SERIES]").toString())
12441343
* .setFilter("filter-1274492040")
12451344
* .setInterval(TimeInterval.newBuilder().build())
12461345
* .setAggregation(Aggregation.newBuilder().build())
1346+
* .setSecondaryAggregation(Aggregation.newBuilder().build())
12471347
* .setOrderBy("orderBy-1207110587")
12481348
* .setPageSize(883849137)
12491349
* .setPageToken("pageToken873572522")
@@ -1271,10 +1371,12 @@ public final ListTimeSeriesPagedResponse listTimeSeries(ListTimeSeriesRequest re
12711371
* try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
12721372
* ListTimeSeriesRequest request =
12731373
* ListTimeSeriesRequest.newBuilder()
1274-
* .setName(ProjectName.of("[PROJECT]").toString())
1374+
* .setName(
1375+
* TimeSeriesName.ofProjectTimeSeriesName("[PROJECT]", "[TIME_SERIES]").toString())
12751376
* .setFilter("filter-1274492040")
12761377
* .setInterval(TimeInterval.newBuilder().build())
12771378
* .setAggregation(Aggregation.newBuilder().build())
1379+
* .setSecondaryAggregation(Aggregation.newBuilder().build())
12781380
* .setOrderBy("orderBy-1207110587")
12791381
* .setPageSize(883849137)
12801382
* .setPageToken("pageToken873572522")
@@ -1303,10 +1405,12 @@ public final ListTimeSeriesPagedResponse listTimeSeries(ListTimeSeriesRequest re
13031405
* try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
13041406
* ListTimeSeriesRequest request =
13051407
* ListTimeSeriesRequest.newBuilder()
1306-
* .setName(ProjectName.of("[PROJECT]").toString())
1408+
* .setName(
1409+
* TimeSeriesName.ofProjectTimeSeriesName("[PROJECT]", "[TIME_SERIES]").toString())
13071410
* .setFilter("filter-1274492040")
13081411
* .setInterval(TimeInterval.newBuilder().build())
13091412
* .setAggregation(Aggregation.newBuilder().build())
1413+
* .setSecondaryAggregation(Aggregation.newBuilder().build())
13101414
* .setOrderBy("orderBy-1207110587")
13111415
* .setPageSize(883849137)
13121416
* .setPageToken("pageToken873572522")

0 commit comments

Comments
 (0)