Add metrics templates

Signed-off-by: Alex Leong <alex@buoyant.io>
This commit is contained in:
Alex Leong
2023-09-15 15:08:32 -07:00
parent efc588001f
commit 04a1f2fa68
3 changed files with 192 additions and 11 deletions
+52 -6
View File
@@ -6,6 +6,40 @@ set -o errexit
REPO_ROOT=$(git rev-parse --show-toplevel)
cat <<EOF | kubectl apply -f -
apiVersion: flagger.app/v1beta1
kind: MetricTemplate
metadata:
name: success-rate
namespace: linkerd
spec:
provider:
type: prometheus
address: http://prometheus.linkerd-viz:9090
query: |
sum(
rate(
response_total{
namespace="{{ namespace }}",
deployment=~"{{ target }}",
classification!="failure",
direction="{{ variables.direction }}"
}[{{ interval }}]
)
)
/
sum(
rate(
response_total{
namespace="{{ namespace }}",
deployment=~"{{ target }}",
direction="{{ variables.direction }}"
}[{{ interval }}]
)
)
* 100
EOF
cat <<EOF | kubectl apply -f -
apiVersion: flagger.app/v1beta1
kind: MetricTemplate
@@ -59,12 +93,14 @@ spec:
maxWeight: 50
stepWeight: 10
metrics:
- name: request-success-rate
- name: success-rate
templateRef:
name: success-rate
namespace: linkerd
threshold: 99
interval: 1m
- name: request-duration
threshold: 500
interval: 30s
templateVariables:
direction: inbound
- name: latency
templateRef:
name: latency
@@ -218,12 +254,22 @@ spec:
maxWeight: 50
stepWeight: 10
metrics:
- name: request-success-rate
- name: success-rate
templateRef:
name: success-rate
namespace: linkerd
threshold: 99
interval: 1m
- name: request-duration
templateVariables:
direction: inbound
- name: latency
templateRef:
name: latency
namespace: linkerd
threshold: 500
interval: 30s
templateVariables:
direction: inbound
webhooks:
- name: http-acceptance-test
type: pre-rollout
+71 -2
View File
@@ -4,6 +4,65 @@
set -o errexit
cat <<EOF | kubectl apply -f -
apiVersion: flagger.app/v1beta1
kind: MetricTemplate
metadata:
name: success-rate
namespace: linkerd
spec:
provider:
type: prometheus
address: http://prometheus.linkerd-viz:9090
query: |
sum(
rate(
response_total{
namespace="{{ namespace }}",
deployment=~"{{ target }}",
classification!="failure",
direction="{{ variables.direction }}"
}[{{ interval }}]
)
)
/
sum(
rate(
response_total{
namespace="{{ namespace }}",
deployment=~"{{ target }}",
direction="{{ variables.direction }}"
}[{{ interval }}]
)
)
* 100
EOF
cat <<EOF | kubectl apply -f -
apiVersion: flagger.app/v1beta1
kind: MetricTemplate
metadata:
name: latency
namespace: linkerd
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)
)
EOF
cat <<EOF | kubectl apply -f -
apiVersion: flagger.app/v1beta1
kind: Canary
@@ -32,12 +91,22 @@ spec:
maxWeight: 50
stepWeights: [10, 20, 30, 40, 50, 60]
metrics:
- name: request-success-rate
- name: success-rate
templateRef:
name: success-rate
namespace: linkerd
threshold: 99
interval: 1m
- name: request-duration
templateVariables:
direction: inbound
- name: latency
templateRef:
name: latency
namespace: linkerd
threshold: 500
interval: 30s
templateVariables:
direction: inbound
webhooks:
- name: load-test
url: http://flagger-loadtester.test/