1
0
Fork 0
mirror of https://github.com/Luzifer/mondash.git synced 2024-12-23 04:21:18 +00:00

Allow hiding of MAD by flag

This commit is contained in:
Knut Ahlers 2016-03-27 21:13:36 +02:00
parent 593f0f9b17
commit b63007d8b1
3 changed files with 33 additions and 26 deletions

View file

@ -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`) + 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 + 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) + Response 200 (text/plain)

View file

@ -62,6 +62,7 @@ type dashboardMetric struct {
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"` IgnoreMAD bool `json:"ignore_mad"`
HideMAD bool `json:"hide_mad"`
HistoricalData dashboardMetricHistory `json:"history,omitifempty"` HistoricalData dashboardMetricHistory `json:"history,omitifempty"`
Meta dashboardMetricMeta `json:"meta,omitifempty"` Meta dashboardMetricMeta `json:"meta,omitifempty"`
} }
@ -211,6 +212,7 @@ func (dm *dashboardMetric) Update(m *dashboardMetric) {
dm.Status = m.Status dm.Status = m.Status
dm.Value = m.Value dm.Value = m.Value
dm.IgnoreMAD = m.IgnoreMAD dm.IgnoreMAD = m.IgnoreMAD
dm.HideMAD = m.HideMAD
if m.Expires != 0 { if m.Expires != 0 {
dm.Expires = m.Expires dm.Expires = m.Expires
} }

View file

@ -93,34 +93,38 @@
<div class="col-md-9"> <div class="col-md-9">
<h4>{{ metric.Title }}</h4> <h4>{{ metric.Title }}</h4>
<p>{{ metric.Description }}</p> <p>{{ metric.Description }}</p>
<span> <span>
{% if metric.Status == "OK" %} {% if metric.Status == "OK" %}
<span class="label label-success">Current Value: {{ metric.Value }}</span> <span class="label label-success">Current Value: {{ metric.Value }}</span>
{% elif metric.Status == "Warning" %} {% elif metric.Status == "Warning" %}
<span class="label label-warning">Current Value: {{ metric.Value }}</span> <span class="label label-warning">Current Value: {{ metric.Value }}</span>
{% elif metric.Status == "Critical" %} {% elif metric.Status == "Critical" %}
<span class="label label-danger">Current Value: {{ metric.Value }}</span> <span class="label label-danger">Current Value: {{ metric.Value }}</span>
{% else %} {% else %}
<span class="label label-info">Current Value: {{ metric.Value }}</span> <span class="label label-info">Current Value: {{ metric.Value }}</span>
{% endif %} {% endif %}
{{ metric.MadMultiplier }} <abbr title="Median Absolute Deviation">MAD</abbr> {% if !metric.HideMAD %}
above the Median ({{ metric.Median }}) {{ metric.MadMultiplier }} <abbr title="Median Absolute Deviation">MAD</abbr>
</span> above the Median ({{ metric.Median }})
<div class="ct-chart {{metric.MetricID}} .ct-double-octave"></div> {% endif %}
<script> </span>
var data = { {% if !metric.HideMAD %}
// A labels array that can contain any sort of values <div class="ct-chart {{metric.MetricID}} .ct-double-octave"></div>
labels: [{{ metric.LabelHistory|lastNItems:"60"|join:"," }}], <script>
// Our series array that contains series objects or in this case series data arrays var data = {
series: [[{{ metric.DataHistory|lastNItems:"60"|join:"," }}]] // A labels array that can contain any sort of values
}; labels: [{{ metric.LabelHistory|lastNItems:"60"|join:"," }}],
// Our series array that contains series objects or in this case series data arrays
series: [[{{ metric.DataHistory|lastNItems:"60"|join:"," }}]]
};
for (var i = 0; i < data.labels.length; i++) { for (var i = 0; i < data.labels.length; i++) {
data.labels[i] = timeConverter(data.labels[i]); data.labels[i] = timeConverter(data.labels[i]);
} }
new Chartist.Line('.{{metric.MetricID}}', data); new Chartist.Line('.{{metric.MetricID}}', data);
</script> </script>
{% endif %}
<small> <small>
Updated {{ metric.Meta.LastUpdate|naturaltime}} Updated {{ metric.Meta.LastUpdate|naturaltime}}
{% if metric.Status != "OK" %} {% if metric.Status != "OK" %}