Reporting Monitoring Metrics

This page describes how to use Service Infrastructure to enable managed services to generate monitoring data to send to service producer and service consumer projects. Monitoring provides visibility into the performance, uptime, and overall health of individual managed services.

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

Whereas Monitoring alone allows a managed service to generate monitoring data for use by you as a developer of the managed service, the Service Control API also lets you generate monitoring data which is intended for your users. This makes it possible for your users to understand and diagnose use of your managed service.

Configuring monitoring

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

  • 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.

  • Metrics: 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.

  • Monitoring configuration: Lets you specify the metrics associated with individual monitored resources and the service producer or service consumer project where each log should be sent.

The following example of service configuration state defines a monitored resource and a metric. A client can invoke the method to report values on the metric. See monitoring.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 monitoring in the service configuration and pushed the configuration to the Service Management API, you can call the Service Control API to report metrics. The following example uses the gcurl command to demonstrate the call. For information on how to set this up, see Getting Started with the Service Control API.

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' } ]
    } ]
  } ]