Skip to content
This repository has been archived by the owner on May 24, 2023. It is now read-only.

Add latency metrics support #21

Merged
merged 4 commits into from
Sep 24, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions deploy/crds/k8s.nginx.org_nginxingresscontrollers_crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,11 @@ spec:
required:
- enable
type: object
enableLatencyMetrics:
LorcanMcVeigh marked this conversation as resolved.
Show resolved Hide resolved
description: Bucketed response times from when NGINX establishes a
connection to an upstream server to when the last byte of the response body is received by NGINX.
nullable: true
type: boolean
replicas:
description: The number of replicas of the Ingress Controller pod. The
default is 1. Only applies if the type is set to deployment.
Expand Down
2 changes: 2 additions & 0 deletions docs/nginx-ingress-controller.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ spec:
nginxReloadTimeout: 5000
appProtect:
enable: false
enableLatencyMetrics: false
```

| Field | Type | Description | Required |
Expand Down Expand Up @@ -99,6 +100,7 @@ spec:
| `enableTLSPassthrough` | `boolean` | Enable TLS Passthrough on port 443. Requires enableCRDs set to true. | No |
| `appprotect` | [appprotect](#nginxingresscontrollerappprotect) | App Protect support configuration. Requires nginxPlus set to true. | No |
| `nginxReloadTimeout` | `int`| Timeout in milliseconds which the Ingress Controller will wait for a successful NGINX reload after a change or at the initial start. (default is 4000. Default is 20000 instead if `enable-app-protect` is true) | No |
| `enableLatencyMetrics` | `boolean` | Bucketed response times from when NGINX establishes a connection to an upstream server to when the last byte of the response body is received by NGINX. **Note** The metric for the upstream isn't available until traffic is sent to the upstream | No |
LorcanMcVeigh marked this conversation as resolved.
Show resolved Hide resolved

## NginxIngressController.Image

Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/k8s/v1alpha1/nginxingresscontroller_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ type NginxIngressControllerSpec struct {
// +nullable
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true
Prometheus *Prometheus `json:"prometheus,omitempty"`
// Enable collection of latency metrics for upstreams.
// +kubebuilder:validation:Optional
// +nullable
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true
EnableLatencyMetrics bool `json:"enableLatencyMetrics"`
// Initial values of the Ingress Controller ConfigMap.
// Check https://docs.nginx.com/nginx-ingress-controller/configuration/global-configuration/configmap-resource/ for
// more information about possible values.
Expand Down
4 changes: 4 additions & 0 deletions pkg/controller/nginxingresscontroller/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ func generatePodArgs(instance *k8sv1alpha1.NginxIngressController) []string {
if instance.Spec.Prometheus.Port != nil {
args = append(args, fmt.Sprintf("-prometheus-metrics-listen-port=%v", *instance.Spec.Prometheus.Port))
}

if instance.Spec.EnableLatencyMetrics {
LorcanMcVeigh marked this conversation as resolved.
Show resolved Hide resolved
args = append(args, "-enable-latency-metrics")
}
}

if instance.Spec.EnableCRDs {
Expand Down
2 changes: 2 additions & 0 deletions pkg/controller/nginxingresscontroller/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ func TestGeneratePodArgs(t *testing.T) {
Enable: true,
Port: &promPort,
},
EnableLatencyMetrics: true,
GlobalConfiguration: "my-nginx-ingress/globalconfiguration",
EnableSnippets: true,
EnableTLSPassthrough: true,
Expand Down Expand Up @@ -209,6 +210,7 @@ func TestGeneratePodArgs(t *testing.T) {
"-wildcard-tls-secret=my-nginx-ingress/wildcard-secret",
"-enable-prometheus-metrics",
"-prometheus-metrics-listen-port=9114",
"-enable-latency-metrics",
"-nginx-reload-timeout=5000",
},
},
Expand Down