istio.io/_docs/reference/api/mixer/mixer-service.md

14 KiB
Raw Blame History

title overview order layout type
Mixer Service Mixer's API Surface 1200 docs markdown

Mixer

Mixer provides three core features:

  • Precondition Checking. Enables callers to verify a number of preconditions before responding to an incoming request from a service consumer. Preconditions can include whether the service consumer is properly authenticated, is on the services whitelist, passes ACL checks, and more.

  • Telemetry Reporting. Enables services to report logging and monitoring. In the future, it will also enable tracing and billing streams intended for both the service operator as well as for service consumers.

  • Quota Management. Enables services to allocate and free quota on a number of dimensions, Quotas are used as a relatively simple resource management tool to provide some fairness between service consumers when contending for limited resources. Rate limits are examples of quotas.

Check

rpc Check([CheckRequest](#istio.mixer.v1.CheckRequest)) returns ([CheckResponse](#istio.mixer.v1.CheckResponse)) Checks preconditions before performing an operation. The preconditions enforced depend on the set of supplied attributes and the active configuration.

Quota

rpc Quota([QuotaRequest](#istio.mixer.v1.QuotaRequest)) returns ([QuotaResponse](#istio.mixer.v1.QuotaResponse)) Quota allocates and releases quota.

Report

rpc Report([ReportRequest](#istio.mixer.v1.ReportRequest)) returns ([ReportResponse](#istio.mixer.v1.ReportResponse)) Reports telemetry, such as logs and metrics. The reported information depends on the set of supplied attributes and the active configuration.

Attributes

An instance of this message is delivered to the mixer with every API call.

The general idea is to leverage the stateful gRPC streams from the proxy to the mixer to keep to a minimum the 'attribute chatter'. Only delta attributes are sent over, multiple concurrent attribute contexts can be used to avoid thrashing, and attribute indices are used to keep the wire protocol maximally efficient.

Producing this message is the responsibility of the mixer's client library which is linked into different proxy implementations.

The processing order for this state in the mixer is:

  • Any new dictionary is applied

  • The requested attribute context is looked up. If no such context has been defined, a new context is automatically created and initialized to the empty state. When a gRPC stream is first created, there are no attribute contexts for the stream.

  • If resetContext is true, then the attribute context is reset to the empty state.

  • All attributes to deleted are removed from the attribute context.

  • All attribute changes are applied to the attribute context.

Field Type Description
dictionary repeated map<int32, string>

A dictionary that provides a mapping of shorthand index values to attribute names.

This is intended to leverage the stateful gRPC stream from the proxy to the mixer. This dictionary is sent over only when a stream to the mixer is first established and when the proxy's configuration changes and different attributes may be produced.

Once a dictionary has been sent over, it stays in effect until a new dictionary is sent to replace it. The first request sent on a stream must include a dictionary, otherwise the mixer can't process any attribute updates.

Dictionaries are independent of the attribute context and are thus global to each gRPC stream.

attributeContext int32

The attribute context against which to operate.

The mixer keeps different contexts live for any proxy gRPC stream. This allows the proxy to maintain multiple concurrent 'bags of attributes' within the mixer.

If the proxy doesn't want to leverage multiple contexts, it just passes 0 here for every request.

The proxy is configured to use a maximum number of attribute contexts in order to prevent an explosion of contexts in the mixer's memory space.

resetContext bool

When true, resets the current attribute context to the empty state before applying any incoming attributes.

Resetting contexts is useful to constrain the amount of resources used by the mixer. The proxy needs to intelligently manage a pool of contexts. It may be useful to reset a context when certain big events happen, such as when an HTTP2 connection into the proxy terminates.

stringAttributes repeated map<int32, string> Attributes being updated within the specified attribute context. These maps add and/or overwrite the context's current set of attributes.
int64Attributes repeated map<int32, int64>
doubleAttributes repeated map<int32, double>
boolAttributes repeated map<int32, bool>
timestampAttributes repeated map<int32, Timestamp>
durationAttributes repeated map<int32, Duration>
bytesAttributes repeated map<int32, bytes>
stringMapAttributes repeated map<int32, StringMap>
deletedAttributes[] repeated int32 Attributes that should be removed from the specified attribute context. Deleting attributes which aren't currently in the attribute context is not considered an error.
timestampAttributesHACK repeated map<int32, Timestamp>
durationAttributesHACK repeated map<int32, Duration>

CheckRequest

Used to verify preconditions before performing an action.

Field Type Description
requestIndex int64 Index within the stream for this request, used to match to responses
attributeUpdate Attributes The attributes to use for this request

CheckResponse

Field Type Description
requestIndex int64 Index of the request this response is associated with
attributeUpdate Attributes The attributes to use for this response
result Status Indicates whether or not the preconditions succeeded
expiration Duration The amount of time for which this result can be considered valid, given the same inputs

QuotaRequest

Field Type Description
requestIndex int64 Index within the stream for this request, used to match to responses
attributeUpdate Attributes The attributes to use for this request
deduplicationId string Used for deduplicating quota allocation/free calls in the case of failed RPCs and retries. This should be a UUID per call, where the same UUID is used for retries of the same quota allocation call.
quota string The quota to allocate from.
amount int64 The amount of quota to allocate.
bestEffort bool If true, allows a response to return less quota than requested. When false, the exact requested amount is returned or 0 if not enough quota was available.

QuotaResponse

Field Type Description
requestIndex int64 Index of the request this response is associated with.
attributeUpdate Attributes The attributes to use for this response
result Status Indicates whether the quota request was successfully processed.
expiration Duration The amount of time the returned quota can be considered valid, this is 0 for non-expiring quotas.
amount int64 The total amount of quota returned, may be less than requested.

ReportRequest

Used to report telemetry after performing an action.

Field Type Description
requestIndex int64 Index within the stream for this request, used to match to responses
attributeUpdate Attributes The attributes to use for this request

ReportResponse

Field Type Description
requestIndex int64 Index of the request this response is associated with
attributeUpdate Attributes The attributes to use for this response
result Status Indicates whether the report was processed or not

StringMap

A map of string to string. The keys in these maps are from the current dictionary.

Field Type Description
map repeated map<int32, string>