Skip to content

Commit

Permalink
Use nginx controller canary metrics
Browse files Browse the repository at this point in the history
Signed-off-by: Léopold Jacquot <leopold.jacquot@infomaniak.com>
  • Loading branch information
L3o-pold committed Sep 27, 2021
1 parent 374a55d commit c6fae82
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/gitbook/tutorials/nginx-progressive-delivery.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This guide shows you how to use the NGINX ingress controller and Flagger to auto

## Prerequisites

Flagger requires a Kubernetes cluster **v1.19** or newer and NGINX ingress **v0.46** or newer.
Flagger requires a Kubernetes cluster **v1.19** or newer and NGINX ingress **v1.0.2** or newer.

Install the NGINX ingress controller with Helm v3:

Expand Down
10 changes: 7 additions & 3 deletions pkg/metrics/observers/nginx.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ var nginxQueries = map[string]string{
nginx_ingress_controller_requests{
namespace="{{ namespace }}",
ingress="{{ ingress }}",
canary!="",
status!~"5.*"
}[{{ interval }}]
)
Expand All @@ -40,7 +41,8 @@ var nginxQueries = map[string]string{
rate(
nginx_ingress_controller_requests{
namespace="{{ namespace }}",
ingress="{{ ingress }}"
ingress="{{ ingress }}",
canary!=""
}[{{ interval }}]
)
)
Expand All @@ -50,7 +52,8 @@ var nginxQueries = map[string]string{
rate(
nginx_ingress_controller_ingress_upstream_latency_seconds_sum{
namespace="{{ namespace }}",
ingress="{{ ingress }}"
ingress="{{ ingress }}",
canary!=""
}[{{ interval }}]
)
)
Expand All @@ -59,7 +62,8 @@ var nginxQueries = map[string]string{
rate(
nginx_ingress_controller_ingress_upstream_latency_seconds_count{
namespace="{{ namespace }}",
ingress="{{ ingress }}"
ingress="{{ ingress }}",
canary!=""
}[{{ interval }}]
)
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/metrics/observers/nginx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (

func TestNginxObserver_GetRequestSuccessRate(t *testing.T) {
t.Run("ok", func(t *testing.T) {
expected := ` sum( rate( nginx_ingress_controller_requests{ namespace="nginx", ingress="podinfo", status!~"5.*" }[1m] ) ) / sum( rate( nginx_ingress_controller_requests{ namespace="nginx", ingress="podinfo" }[1m] ) ) * 100`
expected := ` sum( rate( nginx_ingress_controller_requests{ namespace="nginx", ingress="podinfo", canary!="", status!~"5.*" }[1m] ) ) / sum( rate( nginx_ingress_controller_requests{ namespace="nginx", ingress="podinfo", canary!="" }[1m] ) ) * 100`
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
promql := r.URL.Query()["query"][0]
assert.Equal(t, expected, promql)
Expand Down
2 changes: 1 addition & 1 deletion test/nginx/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -o errexit

NGINX_HELM_VERSION=3.36.0 # ingress v0.49.0
NGINX_HELM_VERSION=3.38.0 # ingress v1.0.2
REPO_ROOT=$(git rev-parse --show-toplevel)

mkdir -p ${REPO_ROOT}/bin
Expand Down

0 comments on commit c6fae82

Please sign in to comment.