From b63007d8b134d2aab3fd0fa89bdafa50f3b5af54 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Sun, 27 Mar 2016 21:13:36 +0200 Subject: [PATCH] Allow hiding of MAD by flag --- apiary.apib | 1 + structs.go | 2 ++ templates/dashboard.html | 56 +++++++++++++++++++++------------------- 3 files changed, 33 insertions(+), 26 deletions(-) diff --git a/apiary.apib b/apiary.apib index 7fef653..431a989 100644 --- a/apiary.apib +++ b/apiary.apib @@ -73,6 +73,7 @@ This API controls the metrics on your dashboard + 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`) + ignore_mad: false (optional, boolean) - If set to true the status passed in the update will be used instead of the median absolute deviation + + hide_mad: false (optional, boolean) - If set to true the median absolute deviation is hidden on the dashboard for this metric + Response 200 (text/plain) diff --git a/structs.go b/structs.go index 4ee0625..a344e90 100644 --- a/structs.go +++ b/structs.go @@ -62,6 +62,7 @@ type dashboardMetric struct { Expires int64 `json:"expires,omitifempty"` Freshness int64 `json:"freshness,omitifempty"` IgnoreMAD bool `json:"ignore_mad"` + HideMAD bool `json:"hide_mad"` HistoricalData dashboardMetricHistory `json:"history,omitifempty"` Meta dashboardMetricMeta `json:"meta,omitifempty"` } @@ -211,6 +212,7 @@ func (dm *dashboardMetric) Update(m *dashboardMetric) { dm.Status = m.Status dm.Value = m.Value dm.IgnoreMAD = m.IgnoreMAD + dm.HideMAD = m.HideMAD if m.Expires != 0 { dm.Expires = m.Expires } diff --git a/templates/dashboard.html b/templates/dashboard.html index cac48a8..b2b5034 100644 --- a/templates/dashboard.html +++ b/templates/dashboard.html @@ -93,34 +93,38 @@

{{ metric.Title }}

{{ metric.Description }}

- - {% if metric.Status == "OK" %} - Current Value: {{ metric.Value }} - {% elif metric.Status == "Warning" %} - Current Value: {{ metric.Value }} - {% elif metric.Status == "Critical" %} - Current Value: {{ metric.Value }} - {% else %} - Current Value: {{ metric.Value }} - {% endif %} - {{ metric.MadMultiplier }} MAD - above the Median ({{ metric.Median }}) - -
- + new Chartist.Line('.{{metric.MetricID}}', data); + + {% endif %} Updated {{ metric.Meta.LastUpdate|naturaltime}} {% if metric.Status != "OK" %}