-
Notifications
You must be signed in to change notification settings - Fork 46
Send LogEvent timestamp as "time" in Http Collector json #15
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| namespace Serilog.Sinks.Splunk | ||
| { | ||
| using System; | ||
|
|
||
| internal static class EpochExtensions | ||
| { | ||
| private static DateTimeOffset Epoch = new DateTimeOffset(1970,1,1,0,0,0,TimeSpan.Zero); | ||
|
|
||
| public static double ToEpoch(this DateTimeOffset value) | ||
| { | ||
| // From Splunk HTTP Collector Protocol | ||
| // The default time format is epoch time format, in the format <sec>.<ms>. | ||
| // For example, 1433188255.500 indicates 1433188255 seconds and 500 milliseconds after epoch, | ||
| // or Monday, June 1, 2015, at 7:50:55 PM GMT. | ||
| // See: http://dev.splunk.com/view/SP-CAAAE6P | ||
|
|
||
| return Math.Round((value - Epoch).TotalSeconds, 3, MidpointRounding.AwayFromZero); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might want to use StringBuilder here
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another thing to consider is adding support for batching i.e. sending multiple events in a single request for efficiency. That would require having some sort of Flush() method. See here under Examples for how batching works.
Our logging library handles a lot of this natively (including retries, batching/flush, async), but it does't support DotNet core.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, also it takes a dependency on
Newtonsoft.JsonThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also we have this, could be improved however we do batch if needed. Needs to be revisited with the
epochtime allocated to each event.https://github.com/serilog/serilog-sinks-splunk/blob/dev/src/Serilog.Sinks.Splunk/Sinks/Splunk/EventCollectorSink.cs#L183
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point on Newtonsoft, my main point for linking to the code was showing how we do it. We basically have an in-memory queue where events are written to which allows us to process things (like batching) very efficiently in an async manner
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are using
ConcurrentQueue. I understand it has a some overhead. @glennblock, any chance you guys are going to port to dotnet core?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A chance at some point but there will have to be SIGNIFICANT demand in our
customer base, and well there is not currently ;-)
On Tue, May 24, 2016 at 10:32 PM Matthew Erbs notifications@github.com
wrote:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will try to fill the void 😀