Reporting Metrics

This page describes how to use Google Service Control to enable services to produce monitoring data to send to service producers and service consumers. Monitoring provides visibility into the performance, uptime, and overall health of individual services.

Service Control accepts metrics, which it batches and aggregates and forwards to Stackdriver Monitoring. Stackdriver Monitoring ingests these metrics and generates insights via dashboards, charts, and alerts.

Whereas Stackdriver Monitoring alone allows a service to produce monitoring data for the sake of the service's producer, Service Control makes it possible to also produce monitoring data which is intended for the service's consumers. This makes it possible for service consumers to understand and diagnose use of the service.

Configuring metrics

Before you send monitoring data to Service Control, you need to specify three different bits of information in your service configuration:

  • Metric names: You can report one or more metrics. Each metric represents a single piece of state whose value is tracked over time. Stackdriver Monitoring provides a well-known set of metrics you can chose from.

  • Monitored resources: A Monitored resource represents a cloud entity that originates some monitoring data or is the subject of it. Stackdriver Monitoring provides a well-known set of monitored resource types that you can chose from.

  • Monitoring configuration: Lets you specify the metrics associated with individual monitored resources and the destination (producer or consumer) where the monitoring data should be sent.

In the following example of service configuration state, we defined a monitored resource and a metric. A client can invoke the method to report values on the metric. See service.proto for details on service configuration.

# The monitored resource to be used.
- type: api
  - key:
  - key:
  - key:
  - key:
  - key:
  - key:

# The metrics to be used.
- name:
  metric_kind: DELTA
  value_type: INT64

# The monitoring configuration.
  - monitored_resource: api
  - monitored_resource: api

Reporting metrics

Once you have configured metrics in the service configuration and pushed the configuration to Google Service Management, you can call the Service Control API to report metrics. The following example uses the gcurl command to demonstrate the call; see Getting Started for how to set this up.

gcurl -d "{
  'operations': [ {
    'operationId': '8356d3c5-f9b5-4274-b4f9-079a3731e6e5',
    'operationName': 'google.example.hello.v1.HelloService.GetHello',
    'consumerId': 'project:endpointsapis-consumer',
    'startTime': '`date +%FT%T%:z`',
    'endTime': '`date +%FT%T%:z`',
    'labels': {
      '': 'global',
      '': 'v1',
      '': 'google.example.hello.v1.HelloService.GetHello',
      '': 'proven-catcher-789',
      '': '',
      '': '92830528305210394'
    'metricValueSets': [ {
      'metricName': '',
      'metricValues': [ { 'int64Value': '23' } ]
    } ]
  } ]

Monitor your resources on the go

Get the Google Cloud Console app to help you manage your projects.