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

Add Kubernetes(Collector) #5

Merged
merged 9 commits into from
Dec 21, 2019
Merged

Add Kubernetes(Collector) #5

merged 9 commits into from
Dec 21, 2019

Conversation

DazWilkin
Copy link
Contributor

@DazWilkin DazWilkin commented Dec 19, 2019

What do you think to my progressing this?

It provides basic (cluster, nodepool, node) counts for Digital Ocean's Kubernetes service.

digitalocean_errors_total{collector="kubernetes"} 0
# HELP digitalocean_kubernetes_cluster_count Number of Kubernetes clusters
# TYPE digitalocean_kubernetes_cluster_count gauge
digitalocean_kubernetes_cluster_count 1
# HELP digitalocean_kubernetes_cluster_up If 1 the kubernetes cluster is up and running, 0 otherwise
# TYPE digitalocean_kubernetes_cluster_up gauge
digitalocean_kubernetes_cluster_up{id="[[REDACTED]]",name="[[REDACTED]]",region="sfo2"} 0
# HELP digitalocean_kubernetes_nodepools_count Number of Kubernetes nodepools
# TYPE digitalocean_kubernetes_nodepools_count gauge
digitalocean_kubernetes_nodepools_count{id="[[REDACTED]]",name="[[REDACTED]]",region="sfo2"} 1
# HELP digitalocean_kubernetes_nodes_count Number of Kubernetes nodes
# TYPE digitalocean_kubernetes_nodes_count gauge
digitalocean_kubernetes_nodes_count{id="[[REDACTED]]",name="[[REDACTED]]",region=""} 3

By the way, this inspired a similar solution for Linode (link). My motivation is to standardize on a way to monitor and alert on resources I'm using across multiple cloud platforms (Google Cloud Platform, Digital Ocean and Linode) in order to keep my bills reasonable.

Since you created this, Go Modules are now a good package management solution for Golang.If you're supportive, I propose replacing dep with Go Modules?

@metalmatze
Copy link
Owner

Thank you for starting this.
I'm both a users of Digitalocean's Kubernetes offering and use Go modules everywhere now. So I'm 100% positive on continuing with this! 😊 💯

var wg sync.WaitGroup
for _, nodepool := range cluster.NodePools {
wg.Add(1)
go func(np *godo.KubernetesNodePool) {
Copy link
Owner

Choose a reason for hiding this comment

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

We don't really need this goroutine here, do we? It should just work without it and then we don't need the working group either.
Am I missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was anticipating having more work to do calculating metrics for the NodePools; I'll remove.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Resolved: 4b6ac4c

@DazWilkin
Copy link
Contributor Author

I think this is a suitable basic implementation.

collector/kubernetes.go Outdated Show resolved Hide resolved
collector/kubernetes.go Show resolved Hide resolved
@metalmatze
Copy link
Owner

Alright. One last comment about the metric names.
The _count suffix is usually not used in Prometheus metrics, we can just leave it away as it's implicit.

- digitalocean_kubernetes_cluster_count 1
+ digitalocean_kubernetes_clusters 1
digitalocean_kubernetes_cluster_up{id="f74f45ec-0c53-4e96-8f22-XXX",name="metalmatze",region="fra1",version="1.14.8-do.2"} 1
- digitalocean_kubernetes_nodepools_count{id="f74f45ec-0c53-4e96-8f22-XXX",name="metalmatze",region="fra1",version="1.14.8-do.2"} 1
+ digitalocean_kubernetes_nodepools{id="f74f45ec-0c53-4e96-8f22-XXX",name="metalmatze",region="fra1",version="1.14.8-do.2"} 1
- digitalocean_kubernetes_nodes_count{id="5879b3c5-1b25-49d3-9ff3-XXX",name="pool-0dgh51ahd",region="fra1"} 3
+ digitalocean_kubernetes_nodes{id="5879b3c5-1b25-49d3-9ff3-XXX",name="pool-0dgh51ahd",region="fra1"} 3

If you want to, you can rebase against the new current master to make use of Go modules and the activated Drone CI, otherwise, we can simply merge it too, as I verified it locally. 😊

@DazWilkin
Copy link
Contributor Author

I realized my mistake in computing _count too.

I will remove the metric entirely.

Count should be computed by summing the e.g. _up metrics.

@metalmatze
Copy link
Owner

Ready when you are. Is this good to go from your side?

@metalmatze
Copy link
Owner

Thanks a lot for this valuable contribution! 🎉

@metalmatze metalmatze merged commit 61b1f9c into metalmatze:master Dec 21, 2019
@DazWilkin DazWilkin deleted the kubernetescollector branch December 21, 2019 14:48
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.

2 participants