Calculate Error Budget Metric

Hello Elastic team,

I'm actually working on SLI/SLO visualization on Kibana.
My request is a bit complexe :
I need to visualize the remaining error budget using this formula :
EB = 436 minutes
IF (not status = "500" or latency < 2) / (status : *) < 0.98 :
THEN Remaining EB = EB - 1
And I need to Show the value on a Metric.
Is there a way to do so ?

I'll give more details in this comment.
So basically I have a huge amount of logs on my elastic,
In a first step I calculate the ratio (number of requests not 500 and number of requests < specified latency) / total number of requests which I define as availability ratio.
In a next step we define a remaining error budget = 436 minutes.
Last step : If availability ratio (during 1 minute time-window) < 0.98 we consider this minute as burned or HS so we do error budget = error budget - 1

My main objective is to keep track of this remaining error budget

@Marius_Dragomir want to take a look at this? Thanks!

Hello Again Elastic community,
So basically I found a solution. Yet, I'm not sure if it's the best solution.

  • Going through a transformation

value={
"id": "13",
"version": "7.16.2",
"create_time": 1655827411304,
"source": {
"index": [
"logs-github-unicorn*"
],
"query": {
"match_all": {}
}
},
"dest": {
"index": "transformed-unicorn"
},
"frequency": "1m",
"pivot": {
"group_by": {
"@timestamp": {
"date_histogram": {
"field": "@timestamp",
"calendar_interval": "1m"
}
}
},
"aggregations": {
"Total_request": {
"value_count": {
"field": "status"
}
},
"failed_req": {
"filter": {
"term": {
"status": "500"
}
}
},
"latency_err": {
"filter": {
"range": {
"latency": {
"gt": 4
}
}
}
}
}
},
"settings": {
"max_page_search_size": 500
}
}

  • In a second step I add painless scripted field (Field name : SLI)

emit ((doc['latency.filter'].value + doc['500'].value)/doc['now.value_count'].value)

Finally I create a metric with a formula ( 436 - count () ) While filtering on SLI > 2%