Skip to content

Commit

Permalink
Merge pull request open-telemetry#61 from chadpatel/cluster_number_of…
Browse files Browse the repository at this point in the history
…_running_pods

Cluster number of running pods
  • Loading branch information
chadpatel authored Jul 27, 2023
2 parents f675755 + 1c3dc4a commit d272937
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 12 deletions.
23 changes: 12 additions & 11 deletions receiver/awscontainerinsightreceiver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -340,17 +340,18 @@ kubectl apply -f config.yaml

## Available Metrics and Resource Attributes
### Cluster
| Metric | Unit |
|------------------------------------------------------------|---------|
| cluster_failed_node_count | Count |
| cluster_node_count | Count |
| apiserver_storage_objects | Count |
| apiserver_request_total | Count |
| apiserver_request_duration_seconds | Seconds |
| apiserver_admission_controller_admission_duration_seconds | Seconds |
| rest_client_request_duration_seconds | Seconds |
| rest_client_requests_total | Count |
| etcd_request_duration_seconds | Seconds |
| Metric | Unit |
|-----------------------------------------------------------|---------|
| cluster_failed_node_count | Count |
| cluster_node_count | Count |
| cluster_number_of_running_pods | Count |
| apiserver_storage_objects | Count |
| apiserver_request_total | Count |
| apiserver_request_duration_seconds | Seconds |
| apiserver_admission_controller_admission_duration_seconds | Seconds |
| rest_client_request_duration_seconds | Seconds |
| rest_client_requests_total | Count |
| etcd_request_duration_seconds | Seconds |



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@ func (k *K8sAPIServer) getClusterMetrics(clusterName, timestampNs string) pmetri
"cluster_failed_node_count": k.leaderElection.nodeClient.ClusterFailedNodeCount(),
"cluster_node_count": k.leaderElection.nodeClient.ClusterNodeCount(),
}

namespaceMap := k.leaderElection.podClient.NamespaceToRunningPodNum()
clusterPodCount := 0
for _, value := range namespaceMap {
clusterPodCount += value
}
fields["cluster_number_of_running_pods"] = clusterPodCount

attributes := map[string]string{
ci.ClusterNameKey: clusterName,
ci.MetricType: ci.TypeCluster,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,8 @@ func TestK8sAPIServer_GetMetrics(t *testing.T) {
case ci.TypeCluster:
assertMetricValueEqual(t, metric, "cluster_failed_node_count", int64(1))
assertMetricValueEqual(t, metric, "cluster_node_count", int64(1))
assertMetricValueEqual(t, metric, "cluster_number_of_running_pods", int64(2))

case ci.TypeClusterService:
assertMetricValueEqual(t, metric, "service_number_of_running_pods", int64(1))
assert.Contains(t, []string{"service1", "service2"}, getStringAttrVal(metric, ci.TypeService))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ type podClient interface {

type PodStore struct {
cache *mapWithExpiry
// preMeasurements per each Type (Pod, Container, etc)
// prevMeasurements per each Type (Pod, Container, etc)
prevMeasurements sync.Map // map[string]*mapWithExpiry
podClient podClient
k8sClient replicaSetInfoProvider
Expand Down

0 comments on commit d272937

Please sign in to comment.