Watcher: Fix watch history template for dynamic slack attachments (#30172)
The part of the history template responsible for slack attachments had a dynamic mapping configured which could lead to problems, when a string value looking like a date was configured in the value field of an attachment. This commit fixes the template by setting this field always to text. This also requires a change in the template numbering to be sure this will be applied properly when starting watcher.
This commit is contained in:
parent
2ac1f9fe89
commit
11d776ecf0
|
@ -12,8 +12,9 @@ public final class WatcherIndexTemplateRegistryField {
|
||||||
// version 3: include watch status in history
|
// version 3: include watch status in history
|
||||||
// version 6: upgrade to ES 6, removal of _status field
|
// version 6: upgrade to ES 6, removal of _status field
|
||||||
// version 7: add full exception stack traces for better debugging
|
// version 7: add full exception stack traces for better debugging
|
||||||
|
// version 8: fix slack attachment property not to be dynamic, causing field type issues
|
||||||
// Note: if you change this, also inform the kibana team around the watcher-ui
|
// Note: if you change this, also inform the kibana team around the watcher-ui
|
||||||
public static final String INDEX_TEMPLATE_VERSION = "7";
|
public static final String INDEX_TEMPLATE_VERSION = "8";
|
||||||
public static final String HISTORY_TEMPLATE_NAME = ".watch-history-" + INDEX_TEMPLATE_VERSION;
|
public static final String HISTORY_TEMPLATE_NAME = ".watch-history-" + INDEX_TEMPLATE_VERSION;
|
||||||
public static final String TRIGGERED_TEMPLATE_NAME = ".triggered_watches";
|
public static final String TRIGGERED_TEMPLATE_NAME = ".triggered_watches";
|
||||||
public static final String WATCHES_TEMPLATE_NAME = ".watches";
|
public static final String WATCHES_TEMPLATE_NAME = ".watches";
|
||||||
|
|
|
@ -507,6 +507,13 @@
|
||||||
"properties" : {
|
"properties" : {
|
||||||
"color" : {
|
"color" : {
|
||||||
"type" : "keyword"
|
"type" : "keyword"
|
||||||
|
},
|
||||||
|
"fields" : {
|
||||||
|
"properties" : {
|
||||||
|
"value" : {
|
||||||
|
"type" : "text"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,13 @@
|
||||||
},
|
},
|
||||||
"input": {
|
"input": {
|
||||||
"simple": {
|
"simple": {
|
||||||
"foo" : "something from input"
|
"foo" : "something from input",
|
||||||
|
"hits" : {
|
||||||
|
"hits" : [
|
||||||
|
{ "_source" : { "name" : "first", "value" : "2018-04-26T11:45:12.518Z" } },
|
||||||
|
{ "_source" : { "name" : "second", "value" : "anything" } }
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"actions": {
|
"actions": {
|
||||||
|
@ -49,7 +55,20 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"dynamic_attachments" : {
|
||||||
|
"list_path" : "ctx.payload.hits.hits",
|
||||||
|
"attachment_template" : {
|
||||||
|
"title": "Title",
|
||||||
|
"fields" : [
|
||||||
|
{
|
||||||
|
"title" : "Field title {{_source.name}}",
|
||||||
|
"value" : "{{_source.value}}",
|
||||||
|
"short" : true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue