# How to prepare a proper SLA query in Elasticsearch

**URL:** <https://discuss.elastic.co/t/how-to-prepare-a-proper-sla-query-in-elasticsearch/216857>\
**Category:** Elasticsearch\
**Created:** [January 28, 2020, 2:17pm UTC](https://discuss.elastic.co/t/how-to-prepare-a-proper-sla-query-in-elasticsearch/216857 "2020-01-28T14:17:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![An\_Eye](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/an_eye/32/61548_2.png) [@An\_Eye](https://discuss.elastic.co/u/An_Eye)\
**Post date:** [January 28, 2020, 2:17pm UTC](https://discuss.elastic.co/t/how-to-prepare-a-proper-sla-query-in-elasticsearch/216857/1 "2020-01-28T14:17:14Z")

</div>

Hello!

Currently I am using ELK + Grafana stack and I am supplying it with data from JMeter. Jmeter is responsible for testing web service and asserting the responses - which later on are being pushed to my ELKG stack.

I have created a simple SLA query, which counts all occurences of a particular log, then counts how many of them does have ErrorCount:1 (assertion made in JMeter) and finally I am using a simple math formula to calculate the percentage of SLA:

((all\_occurences - errors) \* 100 ) / all\_occurences

Is it possible to create a query which will count a downtime towards SLA only if.. lets say 10 last occurences of particular element has failed? In other words - I would like to lower the total SLA value only if error has occured 10 times in a row.

It would be the best if I could use the solution directly in Grafana query bar, but I would be happy with anything else.

I have failed miserably trying to find similar issues and I feel helpless at this point. I would be very grateful for any help, keywords, links that could help me achieve my goal.

Thanks in advance for any help!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 25, 2020, 2:17pm UTC](https://discuss.elastic.co/t/how-to-prepare-a-proper-sla-query-in-elasticsearch/216857/2 "2020-02-25T14:17:17Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
