My use case is a watcher for percentage drop. I have a query from a single field say “submit” and I want to get the percentage drop for the “submit”. Something like c_submit will be the current submit and p_submit is the submit 5 minutes earlier than c_submit. So, say the latest query for “submit” is 10, that will be the value for c_submit and say the query 5 minutes ago for “submit” was 20, that will be the value for p_submit, then I’ll get the percentage.
c_submit = 10
p_submit = 20
Script will be c_submit / p_submit * 100
10 / 20 * 100 = 50%
50% will be the percentage drop, so, if I have my threshold set to < 60, alert should be triggered.
Need help on how I can achieve a working watcher for the above case. Thank you very much in advance.
you have not mentioned at all, where your problem is. Is it writing the query? Is it writing the condition? Or the action? Maybe you start, where you cannot proceed, and we go from there.
Also, when writing watches, you should check out this blog post, which guides you through the most productive experience writing watches.
I'm already good with the value for c_submit. What I am trying to get is the value for p_submit which is from the same data but 5 minutes earlier than the data for c_submit.
I am confused now. Is this a watcher question or is this a pipeline aggregations question?
Also you query looks confusing. You are querying for the last 15 minutes, but then creating a date histogram with an interval of a month. That does not seem to make sense to me.
You could do two things here: First, simply execute two requests, which are similar, except they filter for different time ranges. Then check the percentage in the condition.
Second, execute one request, search for the whole timerange (the last one and the current one), and then use the filters aggregation or a date range aggregation (note the s at the end), to create one bucket for each time range.
Sorry for the confusion but this is really a watcher question. Its a watcher that will trigger if the percentage drop is below 60% or 50%. With regards to the date histogram, I’m just testing it out but what I really need is the current count and the count last five minutes ago. I can get the current count but having a hard time getting the last five minutes count on the same query. Can you give me a sample query that will filter from two different time range so I can use it as reference.
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.