Timeseries: write

Requires authorization

Write data points to one or more time series for one or more metrics.

See custom metrics for details of the use of this API.

Try it now.

If a time series (a metric with a set of label values) does not exist, a new time series will be created.

Data points must be written sequentially in the order of their end time. Attempting to write a time series point earlier than a previously-written point will result in an error.

The timeseries within a single write must be unique.

Request

HTTP request

POST https://www.googleapis.com/cloudmonitoring/v2beta2/projects/project/timeseries:write

Parameters

Parameter name Value Description
Path parameters
project string The project ID. The value can be the numeric project ID or string-based project name.

Authorization

This request requires authorization with at least one of the following scopes (read more about authentication and authorization).

Scope
https://www.googleapis.com/auth/monitoring
https://www.googleapis.com/auth/cloud-platform

Request body

In the request body, supply data with the following structure:

{
  "commonLabels": {
    (key): string
  },
  "timeseries": [
    {
      "timeseriesDesc": timeseriesDescriptors Resource,
      "point": {
        "start": datetime,
        "end": datetime,
        "boolValue": boolean,
        "int64Value": long,
        "doubleValue": double,
        "stringValue": string,
        "distributionValue": {
          "underflowBucket": {
            "upperBound": double,
            "count": long
          },
          "buckets": [
            {
              "lowerBound": double,
              "upperBound": double,
              "count": long
            }
          ],
          "overflowBucket": {
            "lowerBound": double,
            "count": long
          }
        }
      }
    }
  ]
}
Property name Value Description Notes
commonLabels object The label's name.
commonLabels.(key) string The label's name.
timeseries[] list Provide time series specific labels and the data points for each time series. The labels in timeseries and the common_labels should form a complete list of labels that required by the metric.
timeseries[].timeseriesDesc nested object The descriptor of this time series.
timeseries[].point nested object The data point in this time series snapshot.
timeseries[].point.start datetime The interval [start, end] is the time period to which the point's value applies. For gauge metrics, whose values are instantaneous measurements, this interval should be empty (start should equal end). For cumulative metrics (of which deltas and rates are special cases), the interval should be non-empty. Both start and end are RFC 3339 strings.
timeseries[].point.end datetime The interval [start, end] is the time period to which the point's value applies. For gauge metrics, whose values are instantaneous measurements, this interval should be empty (start should equal end). For cumulative metrics (of which deltas and rates are special cases), the interval should be non-empty. Both start and end are RFC 3339 strings.
timeseries[].point.boolValue boolean The value of this data point. Either "true" or "false".
timeseries[].point.int64Value long The value of this data point as a 64-bit integer.
timeseries[].point.doubleValue double The value of this data point as a double-precision floating-point number.
timeseries[].point.stringValue string The value of this data point in string format.
timeseries[].point.distributionValue nested object The value of this data point as a distribution. A distribution value can contain a list of buckets and/or an underflowBucket and an overflowBucket. The values of these points can be used to create a histogram.
timeseries[].point.distributionValue.underflowBucket nested object The underflow bucket.
timeseries[].point.distributionValue.underflowBucket.upperBound double The upper bound of the value interval of this bucket (exclusive).
timeseries[].point.distributionValue.underflowBucket.count long The number of events whose values are in the interval defined by this bucket.
timeseries[].point.distributionValue.buckets[] list The finite buckets.
timeseries[].point.distributionValue.buckets[].lowerBound double The lower bound of the value interval of this bucket (inclusive).
timeseries[].point.distributionValue.buckets[].upperBound double The upper bound of the value interval of this bucket (exclusive).
timeseries[].point.distributionValue.buckets[].count long The number of events whose values are in the interval defined by this bucket.
timeseries[].point.distributionValue.overflowBucket nested object The overflow bucket.
timeseries[].point.distributionValue.overflowBucket.lowerBound double The lower bound of the value interval of this bucket (inclusive).
timeseries[].point.distributionValue.overflowBucket.count long The number of events whose values are in the interval defined by this bucket.

Response

If successful, this method returns a response body with the following structure:

{
  "kind": "cloudmonitoring#writeTimeseriesResponse"
}
Property name Value Description Notes
kind string Identifies what kind of resource this is. Value: the fixed string "cloudmonitoring#writeTimeseriesResponse".

Try it!

Use the APIs Explorer below to call this method on live data and see the response. Alternatively, try the standalone Explorer.

Monitor your resources on the go

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

Send feedback about...

Stackdriver Monitoring