-
Notifications
You must be signed in to change notification settings - Fork 798
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
ElasticsearchSink 2.0 #394
Comments
Where is the 'like' button on github when you need it :) |
A ponder that surfaced while implementing: I think its best to omit the |
Here's an example of the new uniform output to elasticsearch: https://gist.github.com/Mpdreamz/9fe1e18aca522f50b702 The Thoughts appreciated! |
I have shared some modification I did to the current sink to make it more usable here: http://1drv.ms/1AVHkVN Let me highlight a few points.
protected override void WriteJsonProperty(string propertyName, object propertyValue, ref string precedingDelimiter, TextWriter output) Methos ApplyTypeSuffixToPropertyName is also shared. The big point is Elasticsearch chokes if some property first came in as integer (for instance) and later some value for that property cannot be interpreted as integer. This causes ES to throw out the whole log record, which for Serilog purposes is catastrophic. Applying type dependent suffixes to properties names I make sure that if some property is recognized as particular type it stays “compatible”.
Regarding exceptions – I don’t want exception object to be treated any special. It is just the regular object we log with destructuring. Look at SerilogExceptionEnricher.cs I have shared. Exception object will be in the output, I just don’t want it to be rendered any different than others, so WriteException is suppressed.
Thank you for consideration! Konstantin |
It will prevent duplicate data and you can indeed easily find the root exception using the depth 0 filtering. Our original idea was to still have the old behaviour with the Exception property to be there, but since it is a version 2 anyway it makes sense to do it right and not store duplicate data. |
@konste How much details do you want here? We discussed to log it at least to the selflog of serilog. But the trouble is that you need to explicitly monitor this selflog. Does it make sense to have an event that gets the rejected/faulted events so you can do something else with it? Because I think in your implementation you send it to another logging system. And for that you really need to override the sinks. If there is a way to hook into the error handling of the ES sink we might be able to overcome this. |
Yeah, we noticed the same. Part of it is also that the mappings are not that nice like @Mpdreamz mentioned. We discussed if we can have a better one that we optionally put to ES at startup. And in there we correct at least the indexed properties (like {0} {1} etc) to be a string. Not sure if that is enough (I think in my situation it is), but it is on our agenda to see how to overcome this. |
@mivano: Using SelfLog for ES failures seems to be the only option and we should use it. I also shared SerilogSelfLogShipper.cs (at the same location). When we initialize primary logging system we do // Provision for self logging for the logging subsystem. and with that we get selflog shipped to Seq for analysis. Proved to be way more effective that hunting the exceptions directly in Elasticsearch own logs. |
|
The code is now at https://github.com/serilog/serilog-sinks-elasticsearch Just adding this note since no CI is set up yet, and hence there's no "2.0" package published. It would be great for eveyrone on this thread to coordinate around making any changes that should go in before it ships! :) |
All, is this one closable now? Cheers! |
I would say yes. If there are any outstanding issues, lets create new issues to track them separately. |
Today I met up in person with @mivano, who initially wrote the sink, and @zidad. Together we hashed out some steps to get to a more stable/uniform elasticsearch sink.
fields
exception
but also duplicated underexceptions
which is a flattened view of the exception and all its inner exceptions up to a configurable depth (default 20?). This allows you to aggregate onexceptions.ClassName
uniformly.ElasticSearch()
obsolete extension methods. Allow a complex object to be initialized from appsettings as well. @nblumhardt I have some idea's on supporting any parameter of typeISinkOptions
to be new()'ed and populated by serilog rather then relying on named parameters, is this something you've explored already?fields
with a fixed string mapping when you proxy 3rd party logging to serilog.cc @tynor88 @konste @mookid8000 @gmarz
Some of these are breaking and thus the
2.0
, something I initially tried hard to avoid but in order to move forward we'll need to.this ties into #391 and #384
The text was updated successfully, but these errors were encountered: