Last question : how to tranform ctx.payload.error.hits.totals to calculate the error percentage from the total number, for example, I accept 10% error on total calls
If you just use the integrated editor in kibana (which enforces the 1-line limit of JSON), you can write multiple statements separated with semicolons.
A condition roughly like ((errors * 100) / total_messages) >= 10 should be enough; you have to verify the proper syntax, operators, maybe data types... this is not a literal code example.
If you want to save the resulting percentage value, you can add elements to the watch execution context object whenever you use painless script.
The ctx.vars would be a good place to set new variables.
Again, a pseudocode-ish example
"script": {
"source": "ctx.vars.error_percentage = ctx.payload.errors.hits.total * 100 / ctx.payload.all_messages.hits.total; more statements separated by semicolons"
If this is part of the condition, then it must finish with a suitable evaluation:
This way, you will be able to use this value later in the actions section (e.g. an email): "bla bla bla the system has registered {{ctx.vars.error_percentage}} % error rate"
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.