Guide to creating and using Argo Rollouts AnalysisTemplate for runtime analysis during progressive delivery, defining metrics, providers, arguments, conditions, and example manifests.
This lesson shows how to create an Argo Rollouts AnalysisTemplate — the reusable resource that defines how to perform runtime analysis during progressive delivery. AnalysisTemplates specify which metrics to collect, how often to collect them, how many samples to take, and what constitutes success or failure. They can accept runtime arguments (including secrets) so Rollouts can pass contextual values into the template.Below is a minimal AnalysisTemplate manifest showing the resource kind and metadata:
AnalysisTemplates can be namespaced (as shown above) or cluster-scoped. Cluster-level templates use the same API but are available to Rollouts across the cluster.
AnalysisTemplates accept args (input parameters) that Rollouts supply at runtime. An arg can be required (no default) or optional (with a default value). Args can also be populated from Kubernetes Secrets using valueFrom.secretKeyRef.Example of args and metrics declared in an AnalysisTemplate:
Copy
apiVersion: argoproj.io/v1alpha1kind: AnalysisTemplatemetadata: name: args-examplespec: args: # required in Rollout due to no default value - name: service-name - name: stable-hash - name: latest-hash # optional in Rollout given the default value - name: api-url value: http://example/measure # from secret - name: api-token valueFrom: secretKeyRef: name: token-secret key: apiToken metrics: - name: webmetric successCondition: result == 'true' provider: # provider config here
To reference an argument inside the template use the args namespace, for example {{ args.service-name }}.
Arguments are substituted at runtime using the template expression {{ args.<name> }}. Ensure the argument names in your Rollout match exactly those declared in the AnalysisTemplate.
The core of an AnalysisTemplate is the metrics list. Each metric declares:
A name
A sampling cadence (interval)
How many samples (count) or an allowed number of failures (failureLimit)
A successCondition and optional failureCondition to evaluate the provider result
A provider (Prometheus, Datadog, New Relic, Job, Web/HTTP, CloudWatch, etc.)
The provider block defines how the metric is measured (query, HTTP call, job execution, etc.). The successCondition and failureCondition receive a result object whose structure depends on the provider (for web, result.code is HTTP status; for Prometheus, result is typically a vector/array).Common providers at a glance:
Provider
Use Case
Key result field
Prometheus
Query metrics and SLI-style checks
result (array/vector, often indexed like result[0])
The web provider performs HTTP requests to gather a measurement. You can configure the URL, HTTP method, headers, timeout, and optional JSON path to extract values from the response body.
This complete AnalysisTemplate uses the web provider to call a service /health endpoint. It runs 3 probes at 5-second intervals and treats any 2xx HTTP status as success.
count: 3 — the probe will be executed three times.
interval: 5s — delay between successive probes.
successCondition — for the web provider, result.code contains the HTTP response status code.
Use count and interval to control sample size and cadence. Collecting multiple samples helps smooth out transient failures and reduces flakiness in progressive rollouts.
Now the AnalysisTemplate exists and is ready to be referenced by a Rollout in this namespace. Wire the template into a Rollout’s analysis section to execute these checks as part of a progressive delivery strategy.