Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/bosun: Add last API route returns most recent datapoint for metri… #1330

Merged
merged 1 commit into from
Sep 17, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions cmd/bosun/web/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ func Listen(listenAddr string, devMode bool, tsdbHost string) error {
router.Handle("/api/graph", JSON(Graph))
router.Handle("/api/health", JSON(HealthCheck))
router.Handle("/api/host", JSON(Host))
router.Handle("/api/last", JSON(Last))
router.Handle("/api/incidents", JSON(Incidents))
router.Handle("/api/incidents/events", JSON(IncidentEvents))
router.Handle("/api/metadata/get", JSON(GetMetadata))
Expand Down Expand Up @@ -569,6 +570,17 @@ func Host(t miniprofiler.Timer, w http.ResponseWriter, r *http.Request) (interfa
return schedule.Host(r.FormValue("filter")), nil
}

// Last returns the most recent datapoint for a metric+tagset. The metric+tagset
// string should be formated like os.cpu{host=foo}. The tag porition expects the
// that the keys will be in alphabetical order.
func Last(t miniprofiler.Timer, w http.ResponseWriter, r *http.Request) (interface{}, error) {
var counter bool
if r.FormValue("counter") != "" {
counter = true
}
return schedule.Search.GetLast(r.FormValue("metric"), r.FormValue("tagset"), counter)
}

func Version(w http.ResponseWriter, r *http.Request) {
io.WriteString(w, version.GetVersionInfo("bosun"))
}
Expand Down