metric variables documentation and e2e tests

Signed-off-by: Nelson Johnstone <93178586+njohnstone2@users.noreply.github.com>
This commit is contained in:
Nelson Johnstone
2023-02-08 19:49:22 +10:00
committed by Nelson Johnstone
parent 6786668684
commit 2b45c2013c
5 changed files with 69 additions and 4 deletions
+45
View File
@@ -62,6 +62,7 @@ The following variables are available in query templates:
* `service` (canary.spec.service.name)
* `ingress` (canary.spec.ingresRef.name)
* `interval` (canary.spec.analysis.metrics[].interval)
* `variables` (canary.spec.analysis.metrics[].templateVariables)
A canary analysis metric can reference a template with `templateRef`:
@@ -82,6 +83,50 @@ A canary analysis metric can reference a template with `templateRef`:
interval: 1m
```
A canary analysis metric can reference a set of custom variables with `templateVariables`. These variables will be then injected into the query defined in the referred `MetricTemplate` object during canary analysis:
```yaml
analysis:
metrics:
- name: "my metric"
templateRef:
name: my-metric
namespace: flagger
# accepted values
thresholdRange:
min: 10
max: 1000
# metric query time window
interval: 1m
# custom variables used within the referenced metric template
templateVariables:
direction: inbound
```
```yaml
apiVersion: flagger.app/v1beta1
kind: MetricTemplate
metadata:
name: my-metric
spec:
provider:
type: prometheus
address: http://prometheus.linkerd-viz:9090
query: |
histogram_quantile(
0.99,
sum(
rate(
response_latency_ms_bucket{
namespace="{{ namespace }}",
deployment=~"{{ target }}",
direction="{{ variables.direction }}"
}[{{ interval }}]
)
) by (le)
)
```
## Prometheus
You can create custom metric checks targeting a Prometheus server by
+11 -1
View File
@@ -22,7 +22,7 @@ spec:
sum(
rate(
istio_request_duration_milliseconds_bucket{
reporter="destination",
reporter="{{ variables.reporter }}",
destination_workload_namespace="{{ namespace }}",
destination_workload=~"{{ target }}"
}[{{ interval }}]
@@ -75,6 +75,8 @@ spec:
thresholdRange:
max: 500
interval: 1m
templateVariables:
reporter: destination
webhooks:
- name: load-test
url: http://flagger-loadtester.test/
@@ -195,6 +197,8 @@ spec:
thresholdRange:
max: 500
interval: 30s
templateVariables:
reporter: destination
webhooks:
- name: http-acceptance-test
type: pre-rollout
@@ -293,6 +297,8 @@ spec:
thresholdRange:
max: 500
interval: 30s
templateVariables:
reporter: destination
webhooks:
- name: pre
type: pre-rollout
@@ -376,6 +382,8 @@ spec:
thresholdRange:
max: 500
interval: 30s
templateVariables:
reporter: destination
webhooks:
- name: pre
type: pre-rollout
@@ -509,6 +517,8 @@ spec:
thresholdRange:
max: 500
interval: 30s
templateVariables:
reporter: destination
webhooks:
- name: pre
type: pre-rollout
+3 -1
View File
@@ -24,7 +24,7 @@ spec:
response_latency_ms_bucket{
namespace="{{ namespace }}",
deployment=~"{{ target }}",
direction="inbound"
direction="{{ variables.direction }}"
}[{{ interval }}]
)
) by (le)
@@ -65,6 +65,8 @@ spec:
namespace: linkerd
threshold: 300
interval: 1m
templateVariables:
direction: inbound
webhooks:
- name: http-acceptance-test
type: pre-rollout
+5 -1
View File
@@ -49,7 +49,7 @@ spec:
http_request_duration_seconds_bucket{
kubernetes_namespace="{{ namespace }}",
kubernetes_pod_name=~"{{ target }}-[0-9a-zA-Z]+(-[0-9a-zA-Z]+)",
path="root"
path="{{ variables.path }}"
}[{{ interval }}]
)
) by (le)
@@ -92,6 +92,8 @@ spec:
thresholdRange:
max: 0.5
interval: 30s
templateVariables:
path: root
webhooks:
- name: load-test
url: http://flagger-loadtester.test/
@@ -229,6 +231,8 @@ spec:
thresholdRange:
max: 0.5
interval: 30s
templateVariables:
path: root
webhooks:
- name: test-header-routing
type: rollout
+5 -1
View File
@@ -22,7 +22,7 @@ spec:
rate(
osm_request_duration_ms_bucket{
destination_namespace="{{ namespace }}",
destination_kind="Deployment",
destination_kind="{{ variables.destination_kind }}",
destination_name=~"{{ target }}"
}[{{ interval }}]
)
@@ -67,6 +67,8 @@ spec:
namespace: osm-system
threshold: 300
interval: 1m
templateVariables:
destination_kind: Deployment
webhooks:
- name: acceptance-test
type: pre-rollout
@@ -184,6 +186,8 @@ spec:
namespace: osm-system
threshold: 300
interval: 1m
templateVariables:
destination_kind: Deployment
webhooks:
- name: acceptance-test
type: pre-rollout