diff --git a/apiary.apib b/apiary.apib index 7b8d439..92f7a67 100644 --- a/apiary.apib +++ b/apiary.apib @@ -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`) diff --git a/client/client.go b/client/client.go index 11e80a9..56339ad 100644 --- a/client/client.go +++ b/client/client.go @@ -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"` diff --git a/structs.go b/structs.go index f3da364..aaadc53 100644 --- a/structs.go +++ b/structs.go @@ -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 } diff --git a/web_handlers.go b/web_handlers.go index 63e1ef8..ef6ca2e 100644 --- a/web_handlers.go +++ b/web_handlers.go @@ -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(),