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 ReadyReplicas metric to deployment metric family #1534

Merged
merged 4 commits into from
Aug 3, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
15 changes: 15 additions & 0 deletions internal/store/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,21 @@ func deploymentMetricFamilies(allowLabelsList []string) []generator.FamilyGenera
}
}),
),
*generator.NewFamilyGenerator(
"kube_deployment_status_ready_replicas",
akshitgrover marked this conversation as resolved.
Show resolved Hide resolved
"The number of ready replicas per deployment.",
metric.Gauge,
"",
wrapDeploymentFunc(func(d *v1.Deployment) *metric.Family {
return &metric.Family{
Metrics: []*metric.Metric{
{
Value: float64(d.Status.ReadyReplicas),
},
},
}
}),
),
*generator.NewFamilyGenerator(
"kube_deployment_status_replicas_available",
"The number of available replicas per deployment.",
Expand Down
6 changes: 6 additions & 0 deletions internal/store/deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ func TestDeploymentStore(t *testing.T) {
# TYPE kube_deployment_spec_replicas gauge
# HELP kube_deployment_status_replicas The number of replicas per deployment.
# TYPE kube_deployment_status_replicas gauge
# HELP kube_deployment_status_ready_replicas The number of ready replicas per deployment.
# TYPE kube_deployment_status_ready_replicas gauge
# HELP kube_deployment_status_replicas_available The number of available replicas per deployment.
# TYPE kube_deployment_status_replicas_available gauge
# HELP kube_deployment_status_replicas_unavailable The number of unavailable replicas per deployment.
Expand Down Expand Up @@ -84,6 +86,7 @@ func TestDeploymentStore(t *testing.T) {
},
Status: v1.DeploymentStatus{
Replicas: 15,
ReadyReplicas: 10,
AvailableReplicas: 10,
UnavailableReplicas: 5,
UpdatedReplicas: 2,
Expand Down Expand Up @@ -116,6 +119,7 @@ func TestDeploymentStore(t *testing.T) {
kube_deployment_status_replicas_unavailable{deployment="depl1",namespace="ns1"} 5
kube_deployment_status_replicas_updated{deployment="depl1",namespace="ns1"} 2
kube_deployment_status_replicas{deployment="depl1",namespace="ns1"} 15
kube_deployment_status_ready_replicas{deployment="depl1",namespace="ns1"} 10
kube_deployment_status_condition{deployment="depl1",namespace="ns1",condition="Available",status="true"} 1
kube_deployment_status_condition{deployment="depl1",namespace="ns1",condition="Progressing",status="true"} 1
kube_deployment_status_condition{deployment="depl1",namespace="ns1",condition="Available",status="false"} 0
Expand All @@ -136,6 +140,7 @@ func TestDeploymentStore(t *testing.T) {
},
Status: v1.DeploymentStatus{
Replicas: 10,
ReadyReplicas: 5,
AvailableReplicas: 5,
UnavailableReplicas: 0,
UpdatedReplicas: 1,
Expand Down Expand Up @@ -169,6 +174,7 @@ func TestDeploymentStore(t *testing.T) {
kube_deployment_status_replicas_unavailable{deployment="depl2",namespace="ns2"} 0
kube_deployment_status_replicas_updated{deployment="depl2",namespace="ns2"} 1
kube_deployment_status_replicas{deployment="depl2",namespace="ns2"} 10
kube_deployment_status_ready_replicas{deployment="depl2",namespace="ns2"} 5
kube_deployment_status_condition{deployment="depl2",namespace="ns2",condition="Available",status="true"} 0
kube_deployment_status_condition{deployment="depl2",namespace="ns2",condition="Progressing",status="true"} 0
kube_deployment_status_condition{deployment="depl2",namespace="ns2",condition="ReplicaFailure",status="true"} 1
Expand Down