这是indexloc提供的服务,不要输入任何密码
Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.
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