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

Splunk HEC only accepts flat JSON object (not nested) #17308

Closed
hvaghani221 opened this issue Dec 30, 2022 · 12 comments
Closed

Splunk HEC only accepts flat JSON object (not nested) #17308

hvaghani221 opened this issue Dec 30, 2022 · 12 comments
Assignees

Comments

@hvaghani221
Copy link
Member

hvaghani221 commented Dec 30, 2022

Component(s)

exporter/splunkhec, receiver/splunkhec

What happened?

Description

According to the Splunk HEC doc,
fields key specifies a JSON object that contains a flat (not nested) list of explicit custom fields to be defined at index time.

Steps to Reproduce

Execute the following curl request

curl -k -H "Authorization: Splunk 00000000-0000-0000-0000-000000000000" https://splunk:8088/services/collector -d '{"fields":{"keyArray":["A", [1]]}, "event": "hello world"}'
curl -k -H "Authorization: Splunk 00000000-0000-0000-0000-000000000000" https://splunk:8088/services/collector -d '{"fields":{"keyMap":{"field": "value"}}, "event": "hello world"}'

It throws this error

{"text":"Error in handling indexed fields","code":15,"invalid-event-number":0}

The implementation of the splunkhec exporter and receiver doesn't handle it explicitly. It can lead to unexpected failure/invalid behaviour in both the exporter/receiver

Collector version

v0.67.0

Environment information

No response

OpenTelemetry Collector configuration

No response

Log output

No response

Additional context

No response

@hvaghani221 hvaghani221 added bug Something isn't working needs triage New item requiring triage labels Dec 30, 2022
@hvaghani221
Copy link
Member Author

CC: @dmitryax @atoulme

@github-actions
Copy link
Contributor

github-actions bot commented Jan 3, 2023

Pinging code owners for receiver/splunkhec: @atoulme @keitwb. See Adding Labels via Comments if you do not have permissions to add labels yourself.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 3, 2023

Pinging code owners for exporter/splunkhec: @atoulme @dmitryax. See Adding Labels via Comments if you do not have permissions to add labels yourself.

@atoulme
Copy link
Contributor

atoulme commented Jan 3, 2023

Thank you for finding this bug!

@hvaghani221
Copy link
Member Author

@atoulme, I am thinking of fixing this bug later this week. For the receiver, it should return the same error as an actual Splunk HEC does.
But, I am not sure about the exporter. I can think of 3 ways to handle this:

  1. Drop the entire event (unreasonable)
  2. Drop the nested field
  3. Flatten the nested map and drop the nested array (I prefer this)

Please share your thoughts.

@fatsheep9146
Copy link
Contributor

can this issue be assigned to you? @atoulme

@atoulme
Copy link
Contributor

atoulme commented Jan 10, 2023

  1. seems ok with me. Serialize the map to a string?

@fatsheep9146 please feel free to assign to me, but it looks like @harshit-splunk is the one doing the work. It should probably go to him.

@fatsheep9146
Copy link
Contributor

ok, I assigned this to @harshit-splunk

@hvaghani221
Copy link
Member Author

hvaghani221 commented Jan 11, 2023

Serialize the map to a string?

We can serialise nested arrays, but not sure about the map. AFAIK, Splunk will not populate search-time fields from the indexed field if the indexed field contains any serialised map. User has to write their own field extraction logic in splunk.

@atoulme
Copy link
Contributor

atoulme commented Jan 15, 2023

Could we flatten the map, prefixing with the top key?

@atoulme atoulme added priority:p2 Medium and removed needs triage New item requiring triage labels Jan 15, 2023
@hvaghani221
Copy link
Member Author

Could we flatten the map, prefixing it with the top key?

Yes, that's what I am going to do.

@hvaghani221
Copy link
Member Author

Closing as fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants