use of com.google.cloud.monitoring.v3.MetricServiceClient.ListMonitoredResourceDescriptorsPagedResponse in project java-docs-samples by GoogleCloudPlatform.
the class Snippets method listMonitoredResources.
/**
* Gets all monitored resource descriptors.
*/
void listMonitoredResources() throws IOException {
// [START monitoring_list_resources]
// Your Google Cloud Platform project ID
String projectId = System.getProperty("projectId");
final MetricServiceClient client = MetricServiceClient.create();
ProjectName name = ProjectName.of(projectId);
ListMonitoredResourceDescriptorsRequest request = ListMonitoredResourceDescriptorsRequest.newBuilder().setName(name.toString()).build();
System.out.println("Listing monitored resource descriptors: ");
ListMonitoredResourceDescriptorsPagedResponse response = client.listMonitoredResourceDescriptors(request);
for (MonitoredResourceDescriptor d : response.iterateAll()) {
System.out.println(d.getType());
}
// [END monitoring_list_resources]
}
Aggregations