mirror of
https://github.com/Luzifer/mondash.git
synced 2024-12-23 04:21:18 +00:00
Allow to use passed status instead of MAD
This commit is contained in:
parent
bf1b40a7bc
commit
8a3cf7db08
3 changed files with 14 additions and 3 deletions
|
@ -72,6 +72,7 @@ This API controls the metrics on your dashboard
|
||||||
+ status (required, enum[string]) - One of: OK, Warning, Critical, Unknown
|
+ status (required, enum[string]) - One of: OK, Warning, Critical, Unknown
|
||||||
+ expires: 604800 (optional, number) - Time in seconds when to remove the metric if there is no update (Valid: `0 < x < 604800`)
|
+ expires: 604800 (optional, number) - Time in seconds when to remove the metric if there is no update (Valid: `0 < x < 604800`)
|
||||||
+ freshness: 3600 (optional, number) - Time in seconds when to switch to `Unkown` state of there is no update (Valid: `0 < x < 604800`)
|
+ freshness: 3600 (optional, number) - Time in seconds when to switch to `Unkown` state of there is no update (Valid: `0 < x < 604800`)
|
||||||
|
+ ignore_mad: false (optional, boolean) - If set to true the status passed in the update will be used instead of the median absolute deviation
|
||||||
|
|
||||||
+ Response 200 (text/plain)
|
+ Response 200 (text/plain)
|
||||||
|
|
||||||
|
|
10
structs.go
10
structs.go
|
@ -61,6 +61,7 @@ type dashboardMetric struct {
|
||||||
Value float64 `json:"value,omitifempty"`
|
Value float64 `json:"value,omitifempty"`
|
||||||
Expires int64 `json:"expires,omitifempty"`
|
Expires int64 `json:"expires,omitifempty"`
|
||||||
Freshness int64 `json:"freshness,omitifempty"`
|
Freshness int64 `json:"freshness,omitifempty"`
|
||||||
|
IgnoreMAD bool `json:"ignore_mad"`
|
||||||
HistoricalData dashboardMetricHistory `json:"history,omitifempty"`
|
HistoricalData dashboardMetricHistory `json:"history,omitifempty"`
|
||||||
Meta dashboardMetricMeta `json:"meta,omitifempty"`
|
Meta dashboardMetricMeta `json:"meta,omitifempty"`
|
||||||
}
|
}
|
||||||
|
@ -166,6 +167,14 @@ func (dm *dashboardMetric) StatisticalStatus() string {
|
||||||
return "OK"
|
return "OK"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (dm *dashboardMetric) PreferredStatus() string {
|
||||||
|
if dm.IgnoreMAD {
|
||||||
|
return dm.Status
|
||||||
|
}
|
||||||
|
|
||||||
|
return dm.StatisticalStatus()
|
||||||
|
}
|
||||||
|
|
||||||
func (dm *dashboardMetric) LabelHistory() []string {
|
func (dm *dashboardMetric) LabelHistory() []string {
|
||||||
s := []string{}
|
s := []string{}
|
||||||
|
|
||||||
|
@ -201,6 +210,7 @@ func (dm *dashboardMetric) Update(m *dashboardMetric) {
|
||||||
dm.Description = m.Description
|
dm.Description = m.Description
|
||||||
dm.Status = m.Status
|
dm.Status = m.Status
|
||||||
dm.Value = m.Value
|
dm.Value = m.Value
|
||||||
|
dm.IgnoreMAD = m.IgnoreMAD
|
||||||
if m.Expires != 0 {
|
if m.Expires != 0 {
|
||||||
dm.Expires = m.Expires
|
dm.Expires = m.Expires
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,11 +81,11 @@
|
||||||
</div>
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
{% for metric in metrics %}
|
{% for metric in metrics %}
|
||||||
{% if metric.StatisticalStatus == "OK" %}
|
{% if metric.PreferredStatus == "OK" %}
|
||||||
<div class="row alert alert-success">
|
<div class="row alert alert-success">
|
||||||
{% elif metric.StatisticalStatus == "Warning" %}
|
{% elif metric.PreferredStatus == "Warning" %}
|
||||||
<div class="row alert alert-warning">
|
<div class="row alert alert-warning">
|
||||||
{% elif metric.StatisticalStatus == "Critical" %}
|
{% elif metric.PreferredStatus == "Critical" %}
|
||||||
<div class="row alert alert-danger">
|
<div class="row alert alert-danger">
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="row alert alert-info">
|
<div class="row alert alert-info">
|
||||||
|
|
Loading…
Reference in a new issue