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

CAMEL-16577 add support to set the index time #5504

Merged
merged 3 commits into from May 15, 2021
Merged

Conversation

iridian-ks
Copy link
Contributor

Add new option in the splunk-hec component in order to set the time the event occurred rather than defaulting the time to the index time.

@davsclaus
Copy link
Contributor

I wonder if you wont want to have a header with the time that can take precedence, instead of endpoint option. Endpoint options tend to be more static.

Copy link
Contributor

@oscerd oscerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it makes sense to have a time header too with precedence.

@iridian-ks
Copy link
Contributor Author

Thanks for the feedback!!!

To be clear. What is the desired approach here?

  1. Header ONLY
  2. Header AND option and Header takes precedence
  3. Option AND header and Option takes precedence

My initial idea was to use `.toD("${header.splunkTime}"). So, yes the header is pretty much always required when using this feature. Thank you for the time and guidance in this! :)

@davsclaus
Copy link
Contributor

Option2 is what other components would do.

@davsclaus
Copy link
Contributor

Do you have time to work on this, we are getting close to be ready for building the next release.

@iridian-ks
Copy link
Contributor Author

Thanks for the reminder @davsclaus

I pushed a new commit that adds support for the header as well as some update to the documentation. I am definitely still learning the ropes of best practices so feedback is welcomed!

Thanks for your time on this.

@@ -128,5 +131,25 @@ private void buildPayload(Map<String, Object> payload) {
if (endpoint.getConfiguration().getHost() != null) {
payload.put("host", endpoint.getConfiguration().getHost());
}

Object timeInput = message.getHeader(SplunkHECComponent.INDEX_TIME, endpoint.getConfiguration().getTime());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use Camel's type converter, and use getHeader where you can specify the returned time as Long so Camel deal with type conversions. Then all the code below can be removed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@davsclaus davsclaus merged commit c352993 into apache:main May 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants