serilog-sinks-elasticsearch
serilog-sinks-elasticsearch copied to clipboard
Autogreate template failes
Trying to use the elastic sink. It works for a short time, then failes...
This is my setup :
return m_LoggerConfiguration.WriteTo.Elasticsearch(new ElasticsearchSinkOptions(new Uri(TmpURL)) { AutoRegisterTemplate = true ,
AutoRegisterTemplateVersion
= AutoRegisterTemplateVersion.ESv6,
CustomFormatter
= new ElasticsearchJsonFormatter(false , null , true , null , null , true , false, false) ,
});
This is the error 👍
<Message>2020-04-24T13:34:11.8038088Z Failed to create the template. Elasticsearch.Net.ElasticsearchClientException: Den eksterne serveren returnerte feilen (400) Ugyldig forespørsel.. Call: Status code 400 from: PUT /_template/serilog-events-template ---> System.Net.WebException: Den eksterne serveren returnerte feilen (400) Ugyldig forespørsel.
ved System.Net.HttpWebRequest.GetResponse()
ved Elasticsearch.Net.HttpWebRequestConnection.Request[TResponse](RequestData requestData)
--- Slutten på sporingen av intern unntaksstakk ---
ved Elasticsearch.Net.Transport1.HandleElasticsearchClientException(RequestData data, Exception clientException, IElasticsearchResponse response) ved Elasticsearch.Net.Transport1.FinalizeResponse[TResponse](RequestData requestData, IRequestPipeline pipeline, List1 seenExceptions, TResponse response) ved Elasticsearch.Net.Transport1.Request[TResponse](HttpMethod method, String path, PostData data, IRequestParameters requestParameters)
ved Elasticsearch.Net.ElasticLowLevelClient.DoRequest[TResponse](HttpMethod method, String path, PostData data, IRequestParameters requestParameters)
ved Elasticsearch.Net.NamespacedClientProxy.DoRequest[TResponse](HttpMethod post, String url, PostData body, IRequestParameters params)
ved Elasticsearch.Net.Specification.IndicesApi.LowLevelIndicesNamespace.PutTemplateForAll[TResponse](String name, PostData body, PutIndexTemplateRequestParameters requestParameters)
ved Serilog.Sinks.Elasticsearch.ElasticsearchSinkState.RegisterTemplateIfNeeded()</Message>
Any idea what's going on ?
Regards
Hard to see why it is rejecting this. Can you see from the ES logs why it is returning a 400?
I have a similar issue, I'm using Elasticsearch 7.8.0 on Docker (Linux) and the sink on NetCore3.1 and get the following error:
Request failed to execute. Call: Status code 400 from: PUT /_template/serilog-events-template. ServerError: Type: mapper_parsing_exception Reason: "Failed to parse mapping [_doc]: Root mapping definition has unsupported parameters: [default : {dynamic_templates=[{numerics_in_fields={match_pattern=regex, path_match=fields\.[\d+]$, mapping={index=analyzed, omit_norms=true, type=string}}}, {string_fields={mapping={index=analyzed, omit_norms=true, type=string, fields={raw={ignore_above=256, index=not_analyzed, type=string}}}, match_mapping_type=string, match=}}], _all={omit_norms=true, enabled=true}, properties={message={index=analyzed, type=string}, exceptions={type=nested, properties={ExceptionMessage={type=object, properties={MemberType={type=integer}}}, StackTraceString={index=analyzed, type=string}, HResult={type=integer}, RemoteStackTraceString={index=analyzed, type=string}, RemoteStackIndex={type=integer}, Depth={type=integer}}}}}]" CausedBy: "Type: mapper_parsing_exception Reason: "Root mapping definition has unsupported parameters: [default : {dynamic_templates=[{numerics_in_fields={match_pattern=regex, path_match=fields\.[\d+]$, mapping={index=analyzed, omit_norms=true, type=string}}}, {string_fields={mapping={index=analyzed, omit_norms=true, type=string, fields={raw={ignore_above=256, index=not_analyzed, type=string}}}, match_mapping_type=string, match=}}], _all={omit_norms=true, enabled=true}, properties={message={index=analyzed, type=string}, exceptions={type=nested, properties={ExceptionMessage={type=object, properties={MemberType={type=integer}}}, StackTraceString={index=analyzed, type=string}, HResult={type=integer}, RemoteStackTraceString={index=analyzed, type=string}, RemoteStackIndex={type=integer}, Depth={type=integer}}}}}]"""} Elasticsearch.Net.ElasticsearchClientException
In my case, it helps to set AutoRegisterTemplate to false, however...
I will try to get the database log as well.
I fixed this using AutoRegisterTemplateVersion = AutoRegisterTemplateVersion.ESv7.