var total = batch
|query(‘SELECT count(response_time) FROM “telegraf”.“autogen”.apm WHERE service=OBA’)
.period(1d)
.every(5s)
.groupBy(*)
// Get views batch data
var success = batch
|query(‘SELECT count(response_time) FROM “telegraf”.“autogen”.apm WHERE “service”=OBA AND “status”=Success’)
.period(1d)
.every(5s)
.groupBy(*)
// Join errors and views
success
|join(total)
.as(‘success’, ‘total’)
// Calculate percentage
|eval(lambda: 100.0 * float(“success.count”) / float(“total.count”))
.as(‘success_rate’)
|influxDBOut()
.database(‘telegraf’)
.retentionPolicy(‘autogen’)
.measurement(‘apm’)