1
0
mirror of https://github.com/Luzifer/mondash.git synced 2024-09-19 08:52:58 +00:00

Introduce DetailURL

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2019-08-16 23:29:01 +02:00
parent f0fcbe98a7
commit e566299571
Signed by: luzifer
GPG Key ID: DC2729FDD34BE99E
4 changed files with 11 additions and 0 deletions

View File

@ -69,6 +69,7 @@ This API controls the metrics on your dashboard
+ Attributes (object)
+ title (required, string) - The title of the metric to display on the dashboard
+ description (required, string) - A descriptive text for the current state of the metric
+ detail_url (optional, string) - An URL with further information of the status
+ 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`)
+ freshness: 3600 (optional, number) - Time in seconds when to switch to stale state of there is no update (Valid: `0 < x < 604800`)

View File

@ -97,6 +97,9 @@ type PostMetricInput struct {
// A descriptive text for the current state of the metric
Description string `json:"description"`
// An URL with further information of the status
DetailURL string `json:"detail_url"`
// One of: OK, Warning, Critical, Unknown
Status Status `json:"status"`

View File

@ -112,6 +112,7 @@ type dashboardMetric struct {
MetricID string `json:"id"`
Title string `json:"title"`
Description string `json:"description"`
DetailURL string `json:"detail_url"`
Status string `json:"status"`
Value float64 `json:"value,omitempty"`
Expires int64 `json:"expires,omitempty"`
@ -267,6 +268,10 @@ func (dm *dashboardMetric) Update(m *dashboardMetric) {
dm.HideValue = m.HideValue
dm.StalenessStatus = m.StalenessStatus
if m.DetailURL != "" {
dm.DetailURL = m.DetailURL
}
if m.Expires != 0 {
dm.Expires = m.Expires
}

View File

@ -30,6 +30,7 @@ type outputMetric struct {
ID string `json:"id"`
Config outputMetricConfig `json:"config"`
Description string `json:"description"`
DetailURL string `json:"detail_url"`
HistoryBar []historyBarSegment `json:"history_bar,omitempty"`
LastOK time.Time `json:"last_ok"`
LastUpdate time.Time `json:"last_update"`
@ -51,6 +52,7 @@ func outputMetricFromMetric(opts outputMetricFromMetricOpts) outputMetric {
out := outputMetric{
ID: opts.Metric.MetricID,
Description: opts.Metric.Description,
DetailURL: opts.Metric.DetailURL,
LastOK: opts.Metric.Meta.LastOK,
LastUpdate: opts.Metric.Meta.LastUpdate,
Median: opts.Metric.Median(),