Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mithunbelur committed Oct 24, 2024
1 parent de3bfee commit bcbd332
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions processor/k8sattributesprocessor/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,6 @@ func (kp *kubernetesprocessor) processLogs(ctx context.Context, ld plog.Logs) (p

// processResource adds Pod metadata tags to resource based on pod association configuration
func (kp *kubernetesprocessor) processResource(ctx context.Context, resource pcommon.Resource) {
podIdentifierValue := extractPodID(ctx, resource.Attributes(), kp.podAssociations)
kp.logger.Debug("evaluating pod identifier", zap.Any("value", podIdentifierValue))

resource.Attributes().Range(func(k string, v pcommon.Value) bool {
kp.logger.Debug("res-attributes", zap.Any(k, v.Str()))
return true
Expand All @@ -163,6 +160,9 @@ func (kp *kubernetesprocessor) processResource(ctx context.Context, resource pco
}
}

podIdentifierValue := extractPodID(ctx, resource.Attributes(), kp.podAssociations)
kp.logger.Debug("evaluating pod identifier", zap.Any("value", podIdentifierValue))

for i := range podIdentifierValue {
if podIdentifierValue[i].Source.From == kube.ConnectionSource && podIdentifierValue[i].Value != "" {
if _, found := resource.Attributes().Get(kube.K8sIPLabelName); !found {
Expand Down Expand Up @@ -257,16 +257,13 @@ func (kp *kubernetesprocessor) processEventBody(resourceLogs plog.ResourceLogs)
func (kp *kubernetesprocessor) addOpsrampEventResourceAttributes(ctx context.Context, resource pcommon.Resource) {

if val, found := resource.Attributes().Get("type"); found && val.Str() == "event" {
kp.logger.Debug("addOpsrampEventResourceAttributes ")

resource.Attributes().PutStr("source", "kubernetes")
resource.Attributes().PutStr("level", "Unknown")
resource.Attributes().PutStr("cluster_name", kp.redisConfig.ClusterName)
resource.Attributes().PutStr("host", kp.redisConfig.ClusterName)
resource.Attributes().PutStr("resourceUUID", kp.redisConfig.ClusterUid)

if val, found := resource.Attributes().Get("k8s.namespace.name"); found {
kp.logger.Debug("addOpsrampEventResourceAttributes ", zap.Any("namespace", val.Str()))
resource.Attributes().PutStr("namespace", val.Str())
}

Expand All @@ -275,13 +272,9 @@ func (kp *kubernetesprocessor) addOpsrampEventResourceAttributes(ctx context.Con
host = val.Str()
if host != "" {
//overwrite node opsramp resource UUID in resourceUUID
kp.logger.Debug("addOpsrampEventResourceAttributes ", zap.Any("host", host))

resource.Attributes().PutStr("host", host)

if resourceUuid := kp.GetResourceUuidUsingResourceNodeMoid(ctx, resource); resourceUuid != "" {
kp.logger.Debug("addOpsrampEventResourceAttributes ", zap.Any("resourceUUID", resourceUuid))

resource.Attributes().PutStr("resourceUUID", resourceUuid)
}
}
Expand Down

0 comments on commit bcbd332

Please sign in to comment.