CICD-303 · Metric-based promotion
Encyclopedia · Advanced GitOps and progressive delivery · All snippets
Previous · CICD-302 · Next · CICD-304
1. Where it fits
- Placement Under the Argo Rollouts AnalysisTemplate's
spec. - Prerequisites trusted configuration repository, test cluster and named GitOps controller or rollout controller.
- Platforms kubernetes, local-lab.
2. Copy the snippet
yaml
metrics:
- name: success-rate
interval: 1m
count: 5
successCondition: "len(result) == 1 && result[0] >= 0.99"
failureLimit: 1
provider:
prometheus:
address: http://prometheus.monitoring:9090
query: >-
sum(rate(http_requests_total{deployment="web-canary",status!~"5.."}[5m])) / sum(rate(http_requests_total{deployment="web-canary"}[5m]))3. How it works
The AnalysisTemplate queries Prometheus repeatedly and applies the success condition to each sample. Missing or invalid samples require an explicit operational policy.
Repeated numeric samples determine the success of the analysis run.
flowchart TD
N1["Prometheus"]
N2["Metric samples"]
N1 --> N2
N3["Promotion policy"]
N4{"Analysis passes"}
N3 --> N4
N2 --> N4
N5["Allow promotion"]
N4 -->|Yes| N5
N6["Stop promotion"]
N4 -->|No| N6
4. Verify the result
Use matching low-cardinality labels and a minimum traffic gate. Missing traffic can yield no valid sample.
Validation version-dependent (YAML parse). Status definitions.