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:
parent
593f0f9b17
commit
b63007d8b1
3 changed files with 33 additions and 26 deletions
|
@ -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)
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -93,34 +93,38 @@
|
|||
<div class="col-md-9">
|
||||
<h4>{{ metric.Title }}</h4>
|
||||
<p>{{ metric.Description }}</p>
|
||||
<span>
|
||||
{% if metric.Status == "OK" %}
|
||||
<span class="label label-success">Current Value: {{ metric.Value }}</span>
|
||||
{% elif metric.Status == "Warning" %}
|
||||
<span class="label label-warning">Current Value: {{ metric.Value }}</span>
|
||||
{% elif metric.Status == "Critical" %}
|
||||
<span class="label label-danger">Current Value: {{ metric.Value }}</span>
|
||||
{% else %}
|
||||
<span class="label label-info">Current Value: {{ metric.Value }}</span>
|
||||
{% endif %}
|
||||
{{ metric.MadMultiplier }} <abbr title="Median Absolute Deviation">MAD</abbr>
|
||||
above the Median ({{ metric.Median }})
|
||||
</span>
|
||||
<div class="ct-chart {{metric.MetricID}} .ct-double-octave"></div>
|
||||
<script>
|
||||
var data = {
|
||||
// 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:"," }}]]
|
||||
};
|
||||
<span>
|
||||
{% if metric.Status == "OK" %}
|
||||
<span class="label label-success">Current Value: {{ metric.Value }}</span>
|
||||
{% elif metric.Status == "Warning" %}
|
||||
<span class="label label-warning">Current Value: {{ metric.Value }}</span>
|
||||
{% elif metric.Status == "Critical" %}
|
||||
<span class="label label-danger">Current Value: {{ metric.Value }}</span>
|
||||
{% else %}
|
||||
<span class="label label-info">Current Value: {{ metric.Value }}</span>
|
||||
{% endif %}
|
||||
{% if !metric.HideMAD %}
|
||||
{{ metric.MadMultiplier }} <abbr title="Median Absolute Deviation">MAD</abbr>
|
||||
above the Median ({{ metric.Median }})
|
||||
{% endif %}
|
||||
</span>
|
||||
{% if !metric.HideMAD %}
|
||||
<div class="ct-chart {{metric.MetricID}} .ct-double-octave"></div>
|
||||
<script>
|
||||
var data = {
|
||||
// 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++) {
|
||||
data.labels[i] = timeConverter(data.labels[i]);
|
||||
}
|
||||
for (var i = 0; i < data.labels.length; i++) {
|
||||
data.labels[i] = timeConverter(data.labels[i]);
|
||||
}
|
||||
|
||||
new Chartist.Line('.{{metric.MetricID}}', data);
|
||||
</script>
|
||||
new Chartist.Line('.{{metric.MetricID}}', data);
|
||||
</script>
|
||||
{% endif %}
|
||||
<small>
|
||||
Updated {{ metric.Meta.LastUpdate|naturaltime}}
|
||||
{% if metric.Status != "OK" %}
|
||||
|
|
Loading…
Reference in a new issue