--- title: Metric overview: A template that represents a single runtime metric. location: https://istio.io/docs/reference/config/template/metric.html layout: protoc-gen-docs number_of_entries: 2 ---

The metric template is designed to let you describe runtime metric to dispatch to monitoring backends.

Template

The metric template represents a single piece of data to report.

When writing the configuration, the value for the fields associated with this template can either be a literal or an expression. Please note that if the datatype of a field is not istio.mixer.adapter.model.v1beta1.Value, then the expression’s inferred type must match the datatype of the field.

Example config:

apiVersion: "config.istio.io/v1alpha2"
kind: metric
metadata:
  name: requestsize
  namespace: istio-system
spec:
  value: request.size | 0
  dimensions:
    source_service: source.service | "unknown"
    source_version: source.labels["version"] | "unknown"
    destination_service: destination.service | "unknown"
    destination_version: destination.labels["version"] | "unknown"
    response_code: response.code | 200
  monitored_resource_type: '"UNSPECIFIED"'
Field Type Description
value istio.mixer.adapter.model.v1beta1.Value

The value being reported.

dimensions map<string, istio.mixer.adapter.model.v1beta1.Value>

The unique identity of the particular metric to report.

monitoredResourceType string

Optional. An expression to compute the type of the monitored resource this metric is being reported on. If the metric backend supports monitored resources, these fields are used to populate that resource. Otherwise these fields will be ignored by the adapter.

monitoredResourceDimensions map<string, istio.mixer.adapter.model.v1beta1.Value>

Optional. A set of expressions that will form the dimensions of the monitored resource this metric is being reported on. If the metric backend supports monitored resources, these fields are used to populate that resource. Otherwise these fields will be ignored by the adapter.

istio.mixer.adapter.model.v1beta1.Value

Value is used inside templates for fields that have dynamic types. The actual datatype of the field depends on the datatype of the expression used in the operator configuration.

Field Type Description
stringValue string (oneof)

Used for values of type STRING

int64Value int64 (oneof)

Used for values of type INT64

doubleValue double (oneof)

Used for values of type DOUBLE

boolValue bool (oneof)

Used for values of type BOOL

ipAddressValue istio.mixer.adapter.model.v1beta1.IPAddress (oneof)

Used for values of type IPAddress

timestampValue istio.mixer.adapter.model.v1beta1.TimeStamp (oneof)

Used for values of type TIMESTAMP

durationValue istio.mixer.adapter.model.v1beta1.Duration (oneof)

Used for values of type DURATION

emailAddressValue istio.mixer.adapter.model.v1beta1.EmailAddress (oneof)

Used for values of type EmailAddress

dnsNameValue istio.mixer.adapter.model.v1beta1.DNSName (oneof)

Used for values of type DNSName

uriValue istio.mixer.adapter.model.v1beta1.Uri (oneof)

Used for values of type Uri