I am quite new to Bosun and have been trying to configure predictive alerts for tablespace usage. I will paste my template and alert code
template predict_diskspace {
body = `{{template "header" .}}
<p>Host: <a href="{{.HostView .Group.host | short }}">{{.Group.host}}</a>
#<br>Disk: {{.Group.disk}}
<p>Free Space: {{.Eval .Alert.Vars.free_space | printf "%.2f"}}%
<br>Used: {{.Eval .Alert.Vars.used | bytes}}
<br>Total: {{.Eval .Alert.Vars.total | bytes}}
<br>Est. {{.Eval .Alert.Vars.days_to_full | printf "%.2f"}} days remain until 0% free space
{{/* .Graph .Alert.Vars.percent_free_graph */}}
`
subject = {{.Last.Status}}: Oracle Tablespace: ({{.Alert.Vars.used | .Eval | bytes}}/{{.Alert.Vars.total | .Eval | bytes}}) {{.Alert.Vars.free_space | .Eval | printf "%.2f"}}% (Est. {{.Eval .Alert.Vars.days_to_full | printf "%.2f"}} days remain)
}
alert predict_orcl_tbs {
$notes = This alert triggers when there are issues detected in Oracle tablespace free space (hopefully).
template=predict_diskspace
$filter=host=testhost,tablespace_name=*,oracle_database=*
## Forecast Section
$days_to_full=(forecastlr(q("sum:6h-avg:oracle.tablespace_usage{$filter}", "7d", ""), 0) / 60 / 60 / 24)
$warn_days = $days_to_full > 0 && $days_to_full < 7
$crit_days = $days_to_full > 0 && $days_to_full < 1
##Percent Free Section
$pf_time = "5m"
$used = avg(q("max:oracle.tablespace_usage{$filter}", $pf_time, ""))
$total = avg(q("sum:oracle.tablespace_usage{$filter}", $pf_time, ""))
$free_space = $total - $used
# For Graph
$percent_free_graph = q("avg:1h-min:oracle.tablespace_usage{$filter}", "4d", "")
warn = $warn_days
crit = $crit_days
}
I am expecting that the result it should give as in how many days will my tablespace usage will be 100% full.
But the output is a bit weird and I am not sure what the issue is. Sample output from the template is
" Subject normal: Oracle Tablespace: (NaNB/NaNB) NaN% (Est. -3650.00 days remain) Body
Acknowledge alert
View the Rule + Template in the Bosun's Rule Page
Notes: This alert triggers when there are issues detected in Oracle tablespace free space.
View Host dba in Opserver
Host: testhost # Disk:
Free Space: NaN% Used: NaNB Total: NaNB Est. -3650.00 days remain until 0% free space " The values of Est. days remain, Free space, Used, Total are coming wrong. Can someone help me in correcting the alert?
Thanks