diff --git a/global.json b/global.json
index 341f9fea..99e7444e 100644
--- a/global.json
+++ b/global.json
@@ -1,5 +1,5 @@
{
"sdk": {
- "version": "2.1.4"
+ "version": "2.1.500"
}
}
\ No newline at end of file
diff --git a/src/Serilog.Sinks.Elasticsearch/Serilog.Sinks.Elasticsearch.csproj b/src/Serilog.Sinks.Elasticsearch/Serilog.Sinks.Elasticsearch.csproj
index b1d79191..d2e3559f 100644
--- a/src/Serilog.Sinks.Elasticsearch/Serilog.Sinks.Elasticsearch.csproj
+++ b/src/Serilog.Sinks.Elasticsearch/Serilog.Sinks.Elasticsearch.csproj
@@ -33,7 +33,6 @@
-
@@ -43,7 +42,16 @@
+
+
+
+
+
+
+
+
+
1591;1701;1702
diff --git a/src/Serilog.Sinks.Elasticsearch/Sinks/ElasticSearch/ElasticSearchSink.cs b/src/Serilog.Sinks.Elasticsearch/Sinks/ElasticSearch/ElasticSearchSink.cs
index 0bb75390..d89136fd 100644
--- a/src/Serilog.Sinks.Elasticsearch/Sinks/ElasticSearch/ElasticSearchSink.cs
+++ b/src/Serilog.Sinks.Elasticsearch/Sinks/ElasticSearch/ElasticSearchSink.cs
@@ -71,7 +71,7 @@ protected override void EmitBatch(IEnumerable events)
var items = result.Body["items"];
foreach (var item in items)
{
- if (item.index != null && item.index.error != null)
+ if (item["index"] != null && item["index"]["error"] != null)
{
var e = events.ElementAt(indexer);
if (_state.Options.EmitEventFailure.HasFlag(EmitEventFailureHandling.WriteToSelfLog))
@@ -80,8 +80,8 @@ protected override void EmitBatch(IEnumerable events)
SelfLog.WriteLine(
"Failed to store event with template '{0}' into Elasticsearch. Elasticsearch reports for index {1} the following: {2}",
e.MessageTemplate,
- item.index._index,
- item.index.error);
+ item["index"]["_index"],
+ _state.Serialize(item["index"]["error"]));
}
if (_state.Options.EmitEventFailure.HasFlag(EmitEventFailureHandling.WriteToFailureSink) &&
diff --git a/src/Serilog.Sinks.Elasticsearch/Sinks/ElasticSearch/ElasticSearchTemplateProvider.cs b/src/Serilog.Sinks.Elasticsearch/Sinks/ElasticSearch/ElasticSearchTemplateProvider.cs
index 3847a4b0..0325992b 100644
--- a/src/Serilog.Sinks.Elasticsearch/Sinks/ElasticSearch/ElasticSearchTemplateProvider.cs
+++ b/src/Serilog.Sinks.Elasticsearch/Sinks/ElasticSearch/ElasticSearchTemplateProvider.cs
@@ -19,7 +19,11 @@ public enum AutoRegisterTemplateVersion
///
/// Elasticsearch version >= version 6.0
///
- ESv6 = 2
+ ESv6 = 2,
+ ///
+ /// Elasticsearch version >= version 7.0
+ ///
+ ESv7 = 3
}
///
@@ -45,6 +49,8 @@ public static object GetTemplate(
return GetTemplateESv5(settings, templateMatchString);
case AutoRegisterTemplateVersion.ESv6:
return GetTemplateESv6(settings, templateMatchString);
+ case AutoRegisterTemplateVersion.ESv7:
+ return GetTemplateESv7(settings, templateMatchString);
case AutoRegisterTemplateVersion.ESv2:
return GetTemplateESv2(settings, templateMatchString);
default:
@@ -52,6 +58,96 @@ public static object GetTemplate(
}
}
+ private static object GetTemplateESv7(
+ Dictionary settings,
+ string templateMatchString)
+ {
+ return new
+ {
+ index_patterns = new[] { templateMatchString },
+ settings = settings,
+ mappings = new
+ {
+ dynamic_templates = new List
+
@@ -39,7 +41,6 @@
-
@@ -61,8 +62,19 @@
+
+
+
+
+
+
+
+
+
+
+
$(DefineConstants);DOTNETCORE;NO_SERIALIZATION
diff --git a/test/Serilog.Sinks.Elasticsearch.Tests/Templating/template_v7.json b/test/Serilog.Sinks.Elasticsearch.Tests/Templating/template_v7.json
new file mode 100644
index 00000000..585f5323
--- /dev/null
+++ b/test/Serilog.Sinks.Elasticsearch.Tests/Templating/template_v7.json
@@ -0,0 +1,75 @@
+{
+ "index_patterns": [ "logstash-*" ],
+ "settings": {
+ "index.refresh_interval": "5s"
+ },
+ "mappings": {
+ "dynamic_templates": [
+ {
+ "numerics_in_fields": {
+ "path_match": "fields\\.[\\d+]$",
+ "match_pattern": "regex",
+ "mapping": {
+ "type": "text",
+ "index": true,
+ "norms": false
+ }
+ }
+ },
+ {
+ "string_fields": {
+ "match": "*",
+ "match_mapping_type": "string",
+ "mapping": {
+ "type": "text",
+ "index": true,
+ "norms": false,
+ "fields": {
+ "raw": {
+ "type": "keyword",
+ "index": true,
+ "ignore_above": 256
+ }
+ }
+ }
+ }
+ }
+ ],
+ "properties": {
+ "message": {
+ "type": "text",
+ "index": "true"
+ },
+ "exceptions": {
+ "type": "nested",
+ "properties": {
+ "Depth": {
+ "type": "integer"
+ },
+ "RemoteStackIndex": {
+ "type": "integer"
+ },
+ "HResult": {
+ "type": "integer"
+ },
+ "StackTraceString": {
+ "type": "text",
+ "index": "true"
+ },
+ "RemoteStackTraceString": {
+ "type": "text",
+ "index": "true"
+ },
+ "ExceptionMessage": {
+ "type": "object",
+ "properties": {
+ "MemberType": {
+ "type": "integer"
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}