google-cloud-monitoring overview

A client to Cloud Monitoring API

The interfaces provided are listed below, along with usage samples.


Service Description: The AlertPolicyService API is used to manage (list, create, delete, edit) alert policies in Stackdriver Monitoring. An alerting policy is a description of the conditions under which some aspect of your system is considered to be "unhealthy" and the ways to notify people or services about this state. In addition to using this API, alert policies can also be managed through Stackdriver Monitoring, which can be reached by clicking the "Monitoring" tab in Cloud Console.

Sample for AlertPolicyServiceClient:

 try (AlertPolicyServiceClient alertPolicyServiceClient = AlertPolicyServiceClient.create()) {
   AlertPolicyName name =
       AlertPolicyName.ofProjectAlertPolicyName("[PROJECT]", "[ALERT_POLICY]");
   AlertPolicy response = alertPolicyServiceClient.getAlertPolicy(name);


Service Description: The Group API lets you inspect and manage your groups.

A group is a named filter that is used to identify a collection of monitored resources. Groups are typically used to mirror the physical and/or logical topology of the environment. Because group membership is computed dynamically, monitored resources that are started in the future are automatically placed in matching groups. By using a group to name monitored resources in, for example, an alert policy, the target of that alert policy is updated automatically as monitored resources are added and removed from the infrastructure.

Sample for GroupServiceClient:

 try (GroupServiceClient groupServiceClient = GroupServiceClient.create()) {
   GroupName name = GroupName.ofProjectGroupName("[PROJECT]", "[GROUP]");
   Group response = groupServiceClient.getGroup(name);


Service Description: Manages metric descriptors, monitored resource descriptors, and time series data.

Sample for MetricServiceClient:

 try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
   MonitoredResourceDescriptorName name =
   MonitoredResourceDescriptor response =


Service Description: The Notification Channel API provides access to configuration that controls how messages related to incidents are sent.

Sample for NotificationChannelServiceClient:

 try (NotificationChannelServiceClient notificationChannelServiceClient =
     NotificationChannelServiceClient.create()) {
   NotificationChannelDescriptorName name =
           "[PROJECT]", "[CHANNEL_DESCRIPTOR]");
   NotificationChannelDescriptor response =


Service Description: The QueryService API is used to manage time series data in Stackdriver Monitoring. Time series data is a collection of data points that describes the time-varying values of a metric.

Sample for QueryServiceClient:

 try (QueryServiceClient queryServiceClient = QueryServiceClient.create()) {
   QueryTimeSeriesRequest request =
   for (TimeSeriesData element : queryServiceClient.queryTimeSeries(request).iterateAll()) {
     // doThingsWith(element);


Service Description: The Cloud Monitoring Service-Oriented Monitoring API has endpoints for managing and querying aspects of a workspace's services. These include the Service's monitored resources, its Service-Level Objectives, and a taxonomy of categorized Health Metrics.

Sample for ServiceMonitoringServiceClient:

 try (ServiceMonitoringServiceClient serviceMonitoringServiceClient =
     ServiceMonitoringServiceClient.create()) {
   FolderName parent = FolderName.of("[FOLDER]");
   Service service = Service.newBuilder().build();
   Service response = serviceMonitoringServiceClient.createService(parent, service);


Service Description: The UptimeCheckService API is used to manage (list, create, delete, edit) Uptime check configurations in the Stackdriver Monitoring product. An Uptime check is a piece of configuration that determines which resources and services to monitor for availability. These configurations can also be configured interactively by navigating to the Cloud Console, selecting the appropriate project, clicking on "Monitoring" on the left-hand side to navigate to Stackdriver, and then clicking on "Uptime".

Sample for UptimeCheckServiceClient:

 try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
   UptimeCheckConfigName name =
           "[PROJECT]", "[UPTIME_CHECK_CONFIG]");
   UptimeCheckConfig response = uptimeCheckServiceClient.getUptimeCheckConfig(name);