Esempio n. 1
0
// New prometheus handler, returns a command and a webhook handler
func New() hugot.CommandHandler {
	return hugot.NewCommandHandler(
		"ivy",
		"the ivy APL-like calculator",
		ivyHandler,
		nil)
}
Esempio n. 2
0
// New prometheus handler, returns a command and a webhook handler
func New() hugot.CommandHandler {
	return hugot.NewCommandHandler(
		"brainfuck",
		"Needs no introduction",
		brainFuckHandler,
		nil)
}
Esempio n. 3
0
// New prometheus handler, returns a command and a webhook handler
func New(c *prom.Client, amc am.Client, achan string) *promH {
	h := &promH{c, amc, achan, nil, nil, http.NewServeMux()}

	cs := hugot.NewCommandSet()
	cs.AddCommandHandler(hugot.NewCommandHandler("alerts", "list alerts", hugot.CommandFunc(h.alertsCmd), nil))
	cs.AddCommandHandler(hugot.NewCommandHandler("silences", "list silences", hugot.CommandFunc(h.silencesCmd), nil))
	cs.AddCommandHandler(hugot.NewCommandHandler("graph", "graph a query", hugot.CommandFunc(h.graphCmd), nil))
	cs.AddCommandHandler(hugot.NewCommandHandler("explain", "explains the meaning of an alert rule name", h.explainCmd, nil))

	h.CommandHandler = hugot.NewCommandHandler("prometheus", "manage the prometheus monitoring tool", nil, cs)

	h.hmux.HandleFunc("/", http.NotFound)
	h.hmux.HandleFunc("/alerts", h.alertsHook)
	h.hmux.HandleFunc("/alerts/", h.alertsHook)
	h.hmux.HandleFunc("/graph", h.graphHook)
	h.hmux.HandleFunc("/graph/", h.graphHook)

	h.WebHookHandler = hugot.NewWebHookHandler("prometheus", "", h.webHook)

	return h
}