-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feat(ingress): add kube_ingress_status_load_balancer metric #2863
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
redbaron
wants to merge
1
commit into
kubernetes:main
Choose a base branch
from
redbaron:report-ingress-status
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+114
−9
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,12 @@ | ||
| # Ingress Metrics | ||
|
|
||
| | Metric name | Metric type | Description | Labels/tags | Status | | ||
| | -------------------------------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------- |------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| ------------ | | ||
| | kube_ingress_annotations | Gauge | Kubernetes annotations converted to Prometheus labels controlled via [--metric-annotations-allowlist](../../developer/cli-arguments.md) | `ingress`=<ingress-name> <br> `namespace`=<ingress-namespace> <br> `annotation_INGRESS_ANNOTATION`=<ANNOTATION_LABEL> | EXPERIMENTAL | | ||
| | kube_ingress_info | Gauge | | `ingress`=<ingress-name> <br> `namespace`=<ingress-namespace> <br> `ingressclass`=<ingress-class> or `_default` if not set | STABLE | | ||
| | kube_ingress_labels | Gauge | Kubernetes labels converted to Prometheus labels controlled via [--metric-labels-allowlist](../../developer/cli-arguments.md) | `ingress`=<ingress-name> <br> `namespace`=<ingress-namespace> <br> `label_INGRESS_LABEL`=<INGRESS_LABEL> | STABLE | | ||
| | kube_ingress_created | Gauge | | `ingress`=<ingress-name> <br> `namespace`=<ingress-namespace> | STABLE | | ||
| | kube_ingress_metadata_resource_version | Gauge | | `ingress`=<ingress-name> <br> `namespace`=<ingress-namespace> | EXPERIMENTAL | | ||
| | kube_ingress_path | Gauge | | `ingress`=<ingress-name> <br> `namespace`=<ingress-namespace> <br> `host`=<ingress-host> <br> `path`=<ingress-path> <br> `path_type`=<ingress-path type> <br> If path served by Service Backend <br> `service_name`=<service name for the path> <br> `service_port`=<service port for the path> <br> If path served by Resource Backend <br> `resource_api_group`=<resource backend api group> <br> `resource_kind`=<resource backend kind> <br> `resource_name`=<resource backend name> | STABLE | | ||
| | kube_ingress_tls | Gauge | | `ingress`=<ingress-name> <br> `namespace`=<ingress-namespace> <br> `tls_host`=<tls hostname> <br> `secret`=<tls secret name> | STABLE | | ||
| | Metric name | Metric type | Description | Labels/tags | Status | Opt-in | | ||
| | -------------------------------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------- |------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| ------------ | ------ | | ||
| | kube_ingress_annotations | Gauge | Kubernetes annotations converted to Prometheus labels controlled via [--metric-annotations-allowlist](../../developer/cli-arguments.md) | `ingress`=<ingress-name> <br> `namespace`=<ingress-namespace> <br> `annotation_INGRESS_ANNOTATION`=<ANNOTATION_LABEL> | EXPERIMENTAL | - | | ||
| | kube_ingress_info | Gauge | | `ingress`=<ingress-name> <br> `namespace`=<ingress-namespace> <br> `ingressclass`=<ingress-class> or `_default` if not set | STABLE | - | | ||
| | kube_ingress_labels | Gauge | Kubernetes labels converted to Prometheus labels controlled via [--metric-labels-allowlist](../../developer/cli-arguments.md) | `ingress`=<ingress-name> <br> `namespace`=<ingress-namespace> <br> `label_INGRESS_LABEL`=<INGRESS_LABEL> | STABLE | - | | ||
| | kube_ingress_created | Gauge | | `ingress`=<ingress-name> <br> `namespace`=<ingress-namespace> | STABLE | - | | ||
| | kube_ingress_metadata_resource_version | Gauge | | `ingress`=<ingress-name> <br> `namespace`=<ingress-namespace> | EXPERIMENTAL | - | | ||
| | kube_ingress_path | Gauge | | `ingress`=<ingress-name> <br> `namespace`=<ingress-namespace> <br> `host`=<ingress-host> <br> `path`=<ingress-path> <br> `path_type`=<ingress-path type> <br> If path served by Service Backend <br> `service_name`=<service name for the path> <br> `service_port`=<service port for the path> <br> If path served by Resource Backend <br> `resource_api_group`=<resource backend api group> <br> `resource_kind`=<resource backend kind> <br> `resource_name`=<resource backend name> | STABLE | - | | ||
| | kube_ingress_tls | Gauge | | `ingress`=<ingress-name> <br> `namespace`=<ingress-namespace> <br> `tls_host`=<tls hostname> <br> `secret`=<tls secret name> | STABLE | - | | ||
| | kube_ingress_status_load_balancer | Gauge | Ingress load balancer status | `ingress`=<ingress-name> <br> `namespace`=<ingress-namespace> <br> `ip`=<load balancer ip> <br> `hostname`=<load balancer hostname> | EXPERIMENTAL | Opt-in | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -235,6 +235,82 @@ func TestIngressStore(t *testing.T) { | |
| `, | ||
| MetricNames: []string{"kube_ingress_info", "kube_ingress_metadata_resource_version", "kube_ingress_created", "kube_ingress_labels", "kube_ingress_path", "kube_ingress_tls"}, | ||
| }, | ||
| { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A test case to verify no metric family is returned when no load balancer ingress exists will verify there is no unwanted behavior either. |
||
| Obj: &networkingv1.Ingress{ | ||
| ObjectMeta: metav1.ObjectMeta{ | ||
| Name: "ingress8", | ||
| Namespace: "ns8", | ||
| CreationTimestamp: metav1StartTime, | ||
| ResourceVersion: "123456", | ||
| }, | ||
| Status: networkingv1.IngressStatus{ | ||
| LoadBalancer: networkingv1.IngressLoadBalancerStatus{ | ||
| Ingress: []networkingv1.IngressLoadBalancerIngress{ | ||
| { | ||
| IP: "1.2.3.4", | ||
| Hostname: "www.example.com", | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| Want: ` | ||
| # HELP kube_ingress_status_load_balancer Ingress load balancer status. | ||
| # TYPE kube_ingress_status_load_balancer gauge | ||
| kube_ingress_status_load_balancer{namespace="ns8",ingress="ingress8",ip="1.2.3.4",hostname="www.example.com"} 1 | ||
| `, | ||
| MetricNames: []string{"kube_ingress_status_load_balancer"}, | ||
| }, | ||
| { | ||
| Obj: &networkingv1.Ingress{ | ||
| ObjectMeta: metav1.ObjectMeta{ | ||
| Name: "ingress9", | ||
| Namespace: "ns9", | ||
| CreationTimestamp: metav1StartTime, | ||
| ResourceVersion: "123456", | ||
| }, | ||
| Status: networkingv1.IngressStatus{ | ||
| LoadBalancer: networkingv1.IngressLoadBalancerStatus{ | ||
| Ingress: []networkingv1.IngressLoadBalancerIngress{ | ||
| { | ||
| IP: "1.2.3.4", | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| Want: ` | ||
| # HELP kube_ingress_status_load_balancer Ingress load balancer status. | ||
| # TYPE kube_ingress_status_load_balancer gauge | ||
| kube_ingress_status_load_balancer{namespace="ns9",ingress="ingress9",ip="1.2.3.4",hostname=""} 1 | ||
| `, | ||
| MetricNames: []string{"kube_ingress_status_load_balancer"}, | ||
| }, | ||
| { | ||
| Obj: &networkingv1.Ingress{ | ||
| ObjectMeta: metav1.ObjectMeta{ | ||
| Name: "ingress10", | ||
| Namespace: "ns10", | ||
| CreationTimestamp: metav1StartTime, | ||
| ResourceVersion: "123456", | ||
| }, | ||
| Status: networkingv1.IngressStatus{ | ||
| LoadBalancer: networkingv1.IngressLoadBalancerStatus{ | ||
| Ingress: []networkingv1.IngressLoadBalancerIngress{ | ||
| { | ||
| Hostname: "www.example.com", | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| Want: ` | ||
| # HELP kube_ingress_status_load_balancer Ingress load balancer status. | ||
| # TYPE kube_ingress_status_load_balancer gauge | ||
| kube_ingress_status_load_balancer{namespace="ns10",ingress="ingress10",ip="",hostname="www.example.com"} 1 | ||
| `, | ||
| MetricNames: []string{"kube_ingress_status_load_balancer"}, | ||
| }, | ||
| } | ||
| for i, c := range cases { | ||
| c.Func = generator.ComposeMetricGenFuncs(ingressMetricFamilies(c.AllowAnnotationsList, c.AllowLabelsList)) | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a need for the early return?
If
i.Status.LoadBalancer.Ingressis empty thenmswill be equally empty and thusMetrics: ms, will be equal toMetrics: []*metric.Metric{}in this early return.