Calculate a succes rate line with metrics

Hello,
I’d like to calculate a ratio between totalCalls and successCalls using a metric “log.prgoffer.foapi.baminfo.golden.exceptions”.

timeseries totalCalls=sum(log.prgoffer.foapi.baminfo.golden.exceptions),
interval:
duration(toLong(substring($Interval,from:0,to:stringLength($Interval)-1)),
unit:getCharacter($Interval,stringLength($Interval)-1))

and

timeseries successCalls=sum(log.prgoffer.foapi.baminfo.golden.exceptions),

filter: {
matchesValue(baminfo.exception, “OK”)
},
interval:
duration(toLong(substring($Interval,from:0,to:stringLength($Interval)-1)),
unit:getCharacter($Interval,stringLength($Interval)-1))

Hello @enrico_afkl!

You can try this one:

timeseries {
  totalCalls = sum(log.prgoffer.foapi.baminfo.golden.exceptions),

  successCalls = sum(
    log.prgoffer.foapi.baminfo.golden.exceptions,
    filter: matchesValue(baminfo.exception, "OK")
  )
},
interval: duration(
  toLong(substring($Interval, from: 0, to: stringLength($Interval) - 1)),
  unit: getCharacter($Interval, stringLength($Interval) - 1)
)
| fieldsAdd
    successRatio = successCalls[] / totalCalls[] * 100

I hope it helps 😀

that’s perfect thanks!