Skip to content

Commit

Permalink
Adding Some debug Messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Ehsan Aliakbar committed Jul 31, 2023
1 parent 2a02289 commit cf9edf7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ func collectMetrics() {
log.Fatalf("Error obtaining endpoints matching selector (%v) in namespace (%v): %v", namespace, opts.Selector, err.Error())
}

log.Debugf("found %d Enpoint with selector %s in namespace %s", len(endpointsList.Items), opts.Selector, namespace)

// Iterate over all of the endpoints and add them to the data structure
for _, endpoints := range endpointsList.Items { // This loop represents a service

Expand All @@ -168,14 +170,16 @@ func collectMetrics() {
for _, address := range endpointSubset.Addresses { // This loop represents each individual endpoint
shardedInstanceName := address.TargetRef.Name // Name of sharded instance e.g. prometheus-kubernetes-0
instanceID := namespace + "_" + prometheusInstanceName + "_" + shardedInstanceName
InstanceAddress := "https://" + address.IP + ":9091"

if _, ok := cardinalityInfoByInstance[instanceID]; !ok {
log.Debugf("Adding %s to list of instances", InstanceAddress)
// Add a newly found endpoint to the data structure
cardinalityInfoByInstance[instanceID] = &cardinality.PrometheusCardinalityInstance{
Namespace: namespace,
InstanceName: prometheusInstanceName,
ShardedInstanceName: shardedInstanceName,
InstanceAddress: "https://" + address.IP + ":9091",
InstanceAddress: InstanceAddress,
TrackedLabels: cardinality.TrackedLabelNames{
SeriesCountByMetricNameLabels: [10]string{},
LabelValueCountByLabelNameLabels: [10]string{},
Expand All @@ -185,7 +189,7 @@ func collectMetrics() {
}
} else {
// If the endpoint is already known, update it's address
cardinalityInfoByInstance[instanceID].InstanceAddress = "https://" + address.IP + ":9091"
cardinalityInfoByInstance[instanceID].InstanceAddress = InstanceAddress
}

if authValue, ok := promAPIAuthValues[instanceID]; ok { // Check for Prometheus API credentials for sharded instance
Expand Down

0 comments on commit cf9edf7

Please sign in to comment.