Skip to content
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

Prometheus metrics scraping from CNI metrics helper #2603

Merged
merged 2 commits into from
Nov 15, 2023

Conversation

jayanthvn
Copy link
Contributor

@jayanthvn jayanthvn commented Oct 4, 2023

What type of PR is this?
Feature

Which issue does this PR fix:
Fixes #2071

What does this PR do / Why do we need it:
Reopening #2192 and some additional refactoring.

CNI metrics helper merges all the metrics from aws-nodes and aggregates the metrics to send for CW. With this PR the aggregated data is sent to Prometheus when "USE_PROMETHEUS" is set. As part of initial enhancement only Prometheus type GAUGE is streamed for prometheus. Future enhancements will be made for other types of metrics.

This will include -

                "awscni_eni_max":                   EnisMax,
		"awscni_ip_max":                    IpMax,
		"awscni_add_ip_req_count":          AddIPCnt,
		"awscni_del_ip_req_count":          DelIPCnt,
		"awscni_eni_allocated":             Enis,
		"awscni_total_ip_addresses":        TotalIPs,
		"awscni_assigned_ip_addresses":     AssignedIPs,
		"awscni_force_removed_enis":        ForceRemovedENIs,
		"awscni_force_removed_ips":         ForceRemovedIPs,
		"awscni_total_ipv4_prefixes":       TotalPrefixes,
		"awscni_no_available_ip_addresses": NoAvailableIPAddrs,

If an issue # is not available please add repro steps and logs from IPAMD/CNI showing the issue:

Testing done on this change:

kube-system   cni-metrics-helper-5d4d84b8d4-6pxmn                    1/1     Running   0          3m3s   192.168.38.249   
curl http://192.168.38.249:61681/metrics
# HELP awscni_add_ip_req_count The number of add IP address requests
# TYPE awscni_add_ip_req_count gauge
awscni_add_ip_req_count 0
# HELP awscni_assigned_ip_addresses The number of IP addresses assigned to pods
# TYPE awscni_assigned_ip_addresses gauge
awscni_assigned_ip_addresses 14
# HELP awscni_eni_allocated The number of ENIs allocated
# TYPE awscni_eni_allocated gauge
awscni_eni_allocated 4
# HELP awscni_eni_max The maximum number of ENIs that can be attached to the instance, accounting for unmanaged ENIs
# TYPE awscni_eni_max gauge
awscni_eni_max 8
# HELP awscni_force_removed_enis The number of ENIs force removed while they had assigned pods
# TYPE awscni_force_removed_enis gauge
awscni_force_removed_enis 0
# HELP awscni_force_removed_ips The number of IPs force removed while they had assigned pods
# TYPE awscni_force_removed_ips gauge
awscni_force_removed_ips 0
# HELP awscni_ip_max The maximum number of IP addresses that can be allocated to the instance
# TYPE awscni_ip_max gauge
awscni_ip_max 112
# HELP awscni_no_available_ip_addresses The number of pod IP assignments that fail due to no available IP addresses
# TYPE awscni_no_available_ip_addresses gauge
awscni_no_available_ip_addresses 0
# HELP awscni_total_ip_addresses The total number of IP addresses
# TYPE awscni_total_ip_addresses gauge
awscni_total_ip_addresses 56
# HELP awscni_total_ipv4_prefixes The total number of IPv4 prefixes
# TYPE awscni_total_ipv4_prefixe

Automation added to e2e:

N/A

Will this PR introduce any new dependencies?:

No

Will this break upgrades or downgrades. Has updating a running cluster been tested?:
No

Does this change require updates to the CNI daemonset config files to work?:

No

Does this PR introduce any user-facing change?:


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@jayanthvn jayanthvn requested a review from a team as a code owner October 4, 2023 05:16
@jayanthvn jayanthvn marked this pull request as draft October 4, 2023 05:16
Copy link
Contributor

@jdn5126 jdn5126 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change overall LGTM

cmd/cni-metrics-helper/main.go Show resolved Hide resolved
utils/utils.go Outdated Show resolved Hide resolved
utils/prometheusmetrics/prometheusmetrics.go Show resolved Hide resolved
@jayanthvn
Copy link
Contributor Author

Let's wait on merge..I see an issue here.

@jayanthvn jayanthvn force-pushed the cni-metrics-prometheus branch 2 times, most recently from bb53cd4 to 574675a Compare October 5, 2023 00:40
@jayanthvn jayanthvn marked this pull request as ready for review October 5, 2023 00:40
@jayanthvn
Copy link
Contributor Author

Issue with aggregation fixed..

@jayanthvn jayanthvn force-pushed the cni-metrics-prometheus branch 2 times, most recently from 2bf230a to 140c6be Compare October 5, 2023 19:36
Copy link
Contributor

@jdn5126 jdn5126 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good overall, just a few nits. Can you also rebase to latest master?

cmd/cni-metrics-helper/main.go Show resolved Hide resolved
cmd/cni-metrics-helper/metrics/metrics.go Outdated Show resolved Hide resolved
cmd/cni-metrics-helper/metrics/metrics.go Outdated Show resolved Hide resolved
pkg/ipamd/ipamd.go Show resolved Hide resolved
@jdn5126 jdn5126 force-pushed the cni-metrics-prometheus branch from 7ac8bd6 to c62c4ab Compare November 15, 2023 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose metrics for cni-metrics-helper for prometheus to scrape it
2 participants