mirror of
https://github.com/prometheus/alertmanager
synced 2025-01-09 07:19:42 +00:00
8e4c29f5b8
* Clicks update alerts filter text - Normal click replaces filter with selected label - Modifier (ctrl, cmd) + click appends to filter * Auto-filter when clicking labels * ctrl+click removes already present matcher * Match arbitrary whitespace before/after comma * Run elm make with --yes * Always add labels to the filter * Updating filter currently sends Noop msg For now we are still going to require the user to explicitly click "filter" before we send an API request to update the list.
64 lines
1.4 KiB
Go
64 lines
1.4 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"flag"
|
|
"log"
|
|
"net/http"
|
|
"os"
|
|
"os/exec"
|
|
"time"
|
|
|
|
"github.com/stuartnelson3/guac"
|
|
)
|
|
|
|
func main() {
|
|
var (
|
|
port = flag.String("port", "8080", "port to listen on")
|
|
dev = flag.Bool("dev", true, "enable code rebuilding")
|
|
debug = flag.Bool("debug", false, "enable elm debugger")
|
|
)
|
|
flag.Parse()
|
|
|
|
http.HandleFunc("/script.js", func(w http.ResponseWriter, r *http.Request) {
|
|
http.ServeFile(w, r, "script.js")
|
|
})
|
|
|
|
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
|
http.ServeFile(w, r, "index.html")
|
|
})
|
|
|
|
http.HandleFunc("/api/v1/silences", func(w http.ResponseWriter, r *http.Request) {
|
|
http.ServeFile(w, r, "silences.json")
|
|
})
|
|
|
|
if *dev {
|
|
// Recompile the elm code whenever a change is detected.
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
defer cancel()
|
|
|
|
elmMakeArgs := []string{"make", "src/Main.elm", "--yes", "--output", "script.js"}
|
|
|
|
if *debug {
|
|
elmMakeArgs = append(elmMakeArgs, "--debug")
|
|
}
|
|
|
|
recompileFn := func() error {
|
|
cmd := exec.Command("elm", elmMakeArgs...)
|
|
cmd.Stdout = os.Stdout
|
|
cmd.Stderr = os.Stderr
|
|
return cmd.Run()
|
|
}
|
|
|
|
_, err := guac.NewWatcher(ctx, "./src", 50*time.Millisecond, recompileFn)
|
|
if err != nil {
|
|
log.Fatalf("error watching: %v", err)
|
|
}
|
|
}
|
|
|
|
log.Printf("starting listener on port %s", *port)
|
|
if err := http.ListenAndServe(":"+*port, nil); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|