I have recently created a watch that is supposed to send a formatted email with details about the query to the recipients. As a test to get the format of an html table correct I have the email body setup like this:
Basically I am attempting to make a table that contains a two headers "Number 1" and "Number 2" and then for each hit in ctx.payload.hits.hits create a row with 1 and 2 as the values in the table. This is strictly a placeholder as I have been unable to get the formatting correct. When looking at the .watch_history index I noticed that the output looked like:
Can someone explain to me why it appears the head, body, and table tags were moved and the row/data tags were pushed to the end? Is this expected behavior or a bug?
The email html body goes through a sanitization process before it's fully rendered. And so there are two problems that you're facing:
The html you defined is illegal. The <th> elements should be defined within a <tr> element.
By default, the html sanitizer disallows the <th> elements, so these will be stripped.
Luckily, there is a way out:
it is possible to configure the sanitization by defining what html elements are allowed. Here is a setting that extends the default list of tags by adding the <th> to the list (place this setting in the elasticsearch.yml file... requires node restart):
Thank you for the reply Uri. It appears that my dumb html screw up was the only issue. By fixing that the output shows up as expected. As an aside I would expect the watcher service to report an issue with the html in the .watch_history instead of moving things around.
Also it shows in the documentation that _tables is allowed by default:
By default, Watcher allows the following features: body, head, _tables, _links, _blocks, _formatting and img:embedded.
yes, _tables are enabled by default, but unfortunately there's a bug. The <th> tag is not supported by default - it's not part of the _tables element group even though it's documented as such. We'll make sure to fix this bug in 2.0. This effectively means that right now, with default settings the <th> tags are stripped. If you want to keep them, you'll need to apply the setting above.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.