--- title: Stackdriver description: Adapter to deliver logs, metrics, and traces to Stackdriver location: https://istio.io/docs/reference/config/policy-and-telemetry/adapters/stackdriver.html layout: protoc-gen-docs generator: protoc-gen-docs aliases: - /docs/reference/config/adapters/stackdriver.html number_of_entries: 12 ---

The `stackdriver` adapter enables Istio to deliver log, metric and traces to the Stackdriver backend.

This adapter supports the metric template, the logentry template, and the tracespan template.

## Params

Configuration format for the `stackdriver` adapter.

Field | Type | Description
--- | --- | ---
`endpoint` | `string` | Endpoint URL to send stackdriver data - leave empty to use the StackDriver SDK’s default value (monitoring.googleapis.com).
`projectId` | `string` | GCP Project to attach metrics to.
`pushInterval` | `google.protobuf.Duration` | This adapter batches the data it sends to Stackdriver; we will push to stackdriver every push_interval. If no value is provided we default to once per minute.
`appCredentials` | `bool (oneof)` | Use Google’s Application Default Credentials to authorize calls made by the StackDriver SDK. See Google’s documentation.
`apiKey` | `string (oneof)` | The API Key to be used for auth.
`serviceAccountPath` | `string (oneof)` | The path to a Google service account credential file, relative to the Mixer. E.g. `/etc/opt/mixer/gcp-serviceaccount-creds.json` or `./testdata/my-test-account-creds.json`.
`metricInfo` | `map<string, Params.MetricInfo>` | A map of Istio metric name to Stackdriver metric info.
`logInfo` | `map<string, Params.LogInfo>` | A map of Istio LogEntry name to Stackdriver log info.
`trace` | `Params.Trace` | Stackdriver Trace configuration.

## Params.LogInfo

Describes how to represent an Istio Log in Stackdriver.

Field | Type | Description
--- | --- | ---
`labelNames` | `string[]` | The logging template provides a set of variables; these list the subset of variables that should be used to form Stackdriver labels for the log entry.
`payloadTemplate` | `string` | A golang text/template template that will be executed to construct the payload for this log entry. It will be given the full set of variables for the log to use to construct its result.
`httpMapping` | `Params.LogInfo.HttpRequestMapping` | If an HttpRequestMapping is provided, a HttpRequest object will be filled out for this log entry using the variables named in the mapping to populate the fields of the request struct from the instance’s variables.
`sinkInfo` | `Params.LogInfo.SinkInfo` | If SinkInfo is provided, Stackriver logs would be exported to that sink.

## Params.LogInfo.HttpRequestMapping

Maps from template variable names to the various fields of Stackdriver’s HTTP request struct. See https://godoc.org/cloud.google.com/go/logging#HTTPRequest

Field | Type | Description
--- | --- | ---
`status` | `string` | template variable name to map into HTTPRequest.Status
`requestSize` | `string` | template variable name to map into HTTPRequest.RequestSize
`responseSize` | `string` | template variable name to map into HTTPRequest.ResponseSize
`latency` | `string` | template variable name to map into HTTPRequest.Latency
`localIp` | `string` | template variable name to map into HTTPRequest.LocalIP
`remoteIp` | `string` | template variable name to map into HTTPRequest.RemoteIP
`url` | `string` | template variable name to map into HTTPRequest.Request.Url
`method` | `string` | template variable name to map into HTTPRequest.RequestMethod
`userAgent` | `string` | template variable name to map into HTTPRequest.UserAgent
`referer` | `string` | template variable name to map into HTTPRequest.Referer

## Params.LogInfo.SinkInfo

Contains information about sink to export Stackdriver logs to. See https://godoc.org/cloud.google.com/go/logging/logadmin#Sink. Ex: If you want to export it to a GCS bucket, id would be a unique idetifier you want for the sink, destination would be the storage be name of GCS Storage bucket and filter would be user defined condition for filtering logs. See below for a sample config: id: ‘info-errors-to-gcs’ destination: ‘storage.googleapis.com/’ filter: ‘severity >= Default’

Field | Type | Description
--- | --- | ---
`id` | `string` | Client assigned sink identifier.
`destination` | `string` | Export Destination.
`filter` | `string` | Filter that specifies any filtering to be done on logs.
`UniqueWriterIdentity` | `bool` | Determines the kind of IAM identity returned as WriterIdentity in the new sink. If this value is omitted or set to false, and if the sink’s parent is a project, then the value returned as WriterIdentity is the same group or service account used by Stackdriver Logging before the addition of writer identities to the API. The sink’s destination must be in the same project as the sink itself. If this field is set to true, or if the sink is owned by a non-project resource such as an organization, then the value of WriterIdentity will be a unique service account used only for exports from the new sink.
`UpdateDestination` | `bool` | These fields apply only to UpdateSinkOpt calls. The corresponding sink field is updated if and only if the Update field is true. Upate sink destination.
`UpdateFilter` | `bool` | Update sink filter.
`UpdateIncludeChildren` | `bool` | Update inlcudes children.

## Params.MetricInfo

Describes how to represent an Istio metric in Stackdriver. See https://github.com/googleapis/googleapis/blob/master/google/api/metric.proto

Field | Type | Description
--- | --- | ---
`kind` | `google.api.MetricDescriptor.MetricKind` | The kind of measurement for a metric, which describes how the data is reported. Ex: Gauge.
`value` | `google.api.MetricDescriptor.ValueType` | The type of the metric’s value. Ex: Distribution.
`buckets` | `Params.MetricInfo.BucketsDefinition` | For metrics with a metric value of DISTRIBUTION, this provides a mechanism for configuring the buckets that will be used to store the aggregated values. This field must be provided for metrics declared to be of type DISTRIBUTION. This field will be ignored for non-distribution metric kinds.
`metricType` | `string` | Stackdriver metric type name, e.g. istio.io/service/server/request_count. If this is not provided, a concantenation of custom metric prefix (custom.googleapis.com/) and Istio metric name will be used.

## Params.MetricInfo.BucketsDefinition

Describes buckets for DISTRIBUTION valued metrics. TODO: look into using google.api.distribution.proto instead - we would pull it in but it has a ton of dependencies it doesn’t actually use.

Field | Type | Description
--- | --- | ---
`linearBuckets` | `Params.MetricInfo.BucketsDefinition.Linear (oneof)` | The linear buckets.
`exponentialBuckets` | `Params.MetricInfo.BucketsDefinition.Exponential (oneof)` | The exponential buckets.
`explicitBuckets` | `Params.MetricInfo.BucketsDefinition.Explicit (oneof)` | The explicit buckets.

## Params.MetricInfo.BucketsDefinition.Explicit

Specifies a set of buckets with arbitrary widths.

There are `size(bounds) + 1` (= `N`) buckets. Bucket `i` has the following boundaries:

- Upper bound (`0 <= i < N-1`): `bounds[i]`
- Lower bound (`1 <= i < N`): `bounds[i - 1]`

The `bounds` field must contain at least one element. If `bounds` has only one element, then there are no finite buckets, and that single element is the common boundary of the overflow and underflow buckets.

Field | Type | Description
--- | --- | ---
`bounds` | `double[]` | The values must be monotonically increasing.

## Params.MetricInfo.BucketsDefinition.Exponential

Specifies an exponential sequence of buckets that have a width that is proportional to the value of the lower bound. Each bucket represents a constant relative uncertainty on a specific value in the bucket.

There are `num_finite_buckets + 2` (= `N`) buckets. The two additional buckets are the underflow and overflow buckets.

Bucket `i` has the following boundaries:

- Upper bound (0 <= i < N-1): `scale * (growth_factor ^ i)`
- Lower bound (1 <= i < N): `scale * (growth_factor ^ (i - 1))`

Field | Type | Description
--- | --- | ---
`numFiniteBuckets` | `int32` | Must be greater than 0.
`growthFactor` | `double` | Must be greater than 1.
`scale` | `double` | Must be greater than 0.

## Params.MetricInfo.BucketsDefinition.Linear

Specifies a linear sequence of buckets that all have the same width (except overflow and underflow). Each bucket represents a constant absolute uncertainty on the specific value in the bucket.

There are `num_finite_buckets + 2` (= `N`) buckets. The two additional buckets are the underflow and overflow buckets.

Bucket `i` has the following boundaries:

- Upper bound (`0 <= i < N-1`): `offset + (width * i)`
- Lower bound (`1 <= i < N`): `offset + (width * (i - 1))`

Field | Type | Description
--- | --- | ---
`numFiniteBuckets` | `int32` | Must be greater than 0.
`width` | `double` | Must be greater than 0.
`offset` | `double` | Lower bound of the first bucket.

## Params.Trace

Details of Stackdriver Trace configuration for tracespan template.

Field | Type | Description
--- | --- | ---
`sampleProbability` | `double` | Proability that a particular trace ID will be sampled.

## google.api.MetricDescriptor.MetricKind

The kind of measurement. It describes how the data is reported.

Name | Description
--- | ---
`METRIC_KIND_UNSPECIFIED` | Do not use this default value.
`GAUGE` | An instantaneous measurement of a value.
`DELTA` | The change in a value during a time interval.
`CUMULATIVE` | A value accumulated over a time interval. Cumulative measurements in a time series should have the same start time and increasing end times, until an event resets the cumulative value to zero and sets a new start time for the following points.

## google.api.MetricDescriptor.ValueType

The value type of a metric.

Name | Description
--- | ---
`VALUE_TYPE_UNSPECIFIED` | Do not use this default value.
`BOOL` | The value is a boolean. This value type can be used only if the metric kind is `GAUGE`.
`INT64` | The value is a signed 64-bit integer.
`DOUBLE` | The value is a double precision floating point number.
`STRING` | The value is a text string. This value type can be used only if the metric kind is `GAUGE`.
`DISTRIBUTION` | The value is a `Distribution`.
`MONEY` | The value is money.