Policy and Telemetry Rules



A Rule is a selector and a set of intentions to be executed when the selector evaluates to true.

Field Type Description
match string

Required. Match is an attribute based predicate. When Mixer receives a request it evaluates the match expression and executes all the associated actions if the match evaluates to true.

A few example match:

  • an empty match evaluates to true
  • true, a boolean literal; a rule with this match will always be executed
  • destination.service == ratings* selects any request targeting a service whose name starts with "ratings"
  • attr1 == "20" && attr2 == "30" logical AND, OR, and NOT are also available
actions[] repeated Action Optional. The actions that will be executed when match evaluates to true.

The following example instructs Mixer to invoke ‘handler.prometheus’ handler for all services and pass it the instance constructed using the RequestCount metric instance.

apiVersion: "config.istio.io/v1alpha2"
kind: rule
  name: promcount
  namespace: istio-system
- match: destination.service == "*"
  - handler: handler.prometheus
    - RequestCount.metric

Custom Resource Definition

kind: CustomResourceDefinition
apiVersion: apiextensions.k8s.io/v1beta1
  name: rules.config.istio.io
    package: istio.io.mixer
    istio: core
  group: config.istio.io
    kind: rule
    plural: rules
    singular: rule
  scope: Namespaced
  version: v1alpha2


Action describes which Handler to invoke and what data to pass to it for processing.

Field Type Description
handler string Required. Fully qualified name of the handler to invoke. Must match the name of a Handler.
instances[] repeated string Required. Each value must match the fully qualified name of the Instances. Referenced instances are evaluated by resolving the attributes/literals for all the fields. The constructed objects are then passed to the handler referenced within this action.

The following example instructs Mixer to invoke the handler.prometheus handler and pass it the instance constructed using the RequestCount metric instance.

  handler: handler.prometheus
  - RequestCount.metric


Handler allows the operator to configure a specific adapter implementation.

In the following example we define a prometheus handler using the Mixer’s prepackaged prometheus adapter. Here, we define how the handler should generate prometheus metrics from the metric instances provided by Mixer.

apiVersion: "config.istio.io/v1alpha2"
kind: prometheus
  name: handler
  namespace: istio-system
  - name: request_count
    instance_name: RequestCount.metric.istio-system
    kind: COUNTER
    - source_service
    - source_version
    - destination_service
    - destination_version
    - response_code


A Instance tells Mixer how to create values for particular template.

Instance is defined by the operator. Instance is defined relative to a known template. Their purpose is to tell Mixer how to use attributes or literals to produce values for the specified template at runtime.

The following example instructs Mixer to construct an instance associated with metric template. It provides a mapping from the template’s fields to expressions. Instances produced with this instance configuration can be referenced by Actions using name RequestCount.

apiVersion: "config.istio.io/v1alpha2"
kind: metric
  name: RequestCount
  namespace: istio-system
  value: "1"
    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"'