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

Update event payload to send JSON object #22

Merged
merged 3 commits into from
Jun 15, 2024
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
Next Next commit
update event payload to send JSON object
  • Loading branch information
smithclay committed Jun 13, 2024
commit 21f02714f952f4a14f14d347dbff655f14d9e15a
9 changes: 2 additions & 7 deletions collector/components/servicenowexporter/servicenow.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package servicenowexporter
import (
"bytes"
"context"
"encoding/json"
"strconv"
"strings"

Expand Down Expand Up @@ -362,7 +361,7 @@ func buildPath(name string, attributes pcommon.Map) string {
return buf.String()
}

func formatAdditionalInfo(attrs map[string]string, resourceAttrs map[string]string) (string, error) {
func formatAdditionalInfo(attrs map[string]string, resourceAttrs map[string]string) (map[string]string, error) {
// merge attrs + resource attrs
newAttrs := make(map[string]string)
for k, v := range resourceAttrs {
Expand All @@ -383,11 +382,7 @@ func formatAdditionalInfo(attrs map[string]string, resourceAttrs map[string]stri
newAttrs[k] = v
}

bytes, err := json.Marshal(newAttrs)
if err != nil {
return "", err
}
return string(bytes), nil
return newAttrs, nil
}

func formatNode(resourceAttrs map[string]string) string {
Expand Down
4 changes: 2 additions & 2 deletions collector/components/servicenowexporter/servicenow_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ type ServiceNowEvent struct {
Description string `json:"description"`
Timestamp string `json:"time_of_event"` // yyyy-MM-dd HH:mm:ss
// k8s.cluster.name:test-cluster,k8s.cluster.uid=12345
AdditionalInfo string `json:"additional_info,omitempty"` // actually a json string
Source string `json:"source"`
AdditionalInfo map[string]string `json:"additional_info,omitempty"` // actually a json string
Source string `json:"source"`
}
Loading