diff -Nru prometheus-alertmanager-0.15.3+ds/debian/changelog prometheus-alertmanager-0.15.3+ds/debian/changelog --- prometheus-alertmanager-0.15.3+ds/debian/changelog 2019-01-14 22:40:29.000000000 +0000 +++ prometheus-alertmanager-0.15.3+ds/debian/changelog 2019-02-21 19:36:45.000000000 +0000 @@ -1,3 +1,12 @@ +prometheus-alertmanager (0.15.3+ds-3) unstable; urgency=medium + + * Fix webserver patch to serve properly a UI compiled manually. + * Create a separate cmdline argument for the default notification + template. + * Rename cmdline argument for local UI. + + -- Martín Ferrari Thu, 21 Feb 2019 19:36:45 +0000 + prometheus-alertmanager (0.15.3+ds-2) unstable; urgency=medium * Replace custom patch with backporting of upstream fix for common lib diff -Nru prometheus-alertmanager-0.15.3+ds/debian/default prometheus-alertmanager-0.15.3+ds/debian/default --- prometheus-alertmanager-0.15.3+ds/debian/default 2019-01-14 22:40:29.000000000 +0000 +++ prometheus-alertmanager-0.15.3+ds/debian/default 2019-02-21 19:36:45.000000000 +0000 @@ -25,8 +25,10 @@ # --web.external-url. # --web.listen-address=":9093" # Address to listen on for the web interface and API. -# --web.local-assets="/usr/share/prometheus/alertmanager/" -# Path to static assets/templates directory. +# --web.ui-path="/usr/share/prometheus/alertmanager/ui/" +# Path to static UI directory. +# --template.default="/usr/share/prometheus/alertmanager/default.tmpl" +# Path to default notification template. # --cluster.listen-address="0.0.0.0:9094" # Listen address for cluster. # --cluster.advertise-address=CLUSTER.ADVERTISE-ADDRESS diff -Nru prometheus-alertmanager-0.15.3+ds/debian/dirs prometheus-alertmanager-0.15.3+ds/debian/dirs --- prometheus-alertmanager-0.15.3+ds/debian/dirs 2019-01-14 22:40:29.000000000 +0000 +++ prometheus-alertmanager-0.15.3+ds/debian/dirs 2019-02-21 19:36:45.000000000 +0000 @@ -1,7 +1,6 @@ etc/prometheus etc/prometheus/alertmanager_templates usr/bin -usr/share/prometheus/alertmanager/ui/app -usr/share/prometheus/alertmanager/ui/lib +usr/share/prometheus/alertmanager/ui var/lib/prometheus/alertmanager var/log/prometheus diff -Nru prometheus-alertmanager-0.15.3+ds/debian/index.html prometheus-alertmanager-0.15.3+ds/debian/index.html --- prometheus-alertmanager-0.15.3+ds/debian/index.html 2019-01-14 22:40:29.000000000 +0000 +++ prometheus-alertmanager-0.15.3+ds/debian/index.html 2019-02-21 19:36:45.000000000 +0000 @@ -17,9 +17,11 @@

Alternatively, you can deploy your own files to be served by the embedded web server, by placing them in /usr/share/prometheus/alertmanager/ui/, or by using the - --web.local-assets option to point to a different path. Note + --web.ui-path option to point to a different path. Note that the web server will only serve files in the lib and - app sub-directories.

+ app sub-directories, plus the fixed + /index.html, /script.js, and + /favicon.ico locations.

You can still use the HTTP API, and the special handlers:

diff -Nru prometheus-alertmanager-0.15.3+ds/debian/patches/02-Do_not_embed_blobs.patch prometheus-alertmanager-0.15.3+ds/debian/patches/02-Do_not_embed_blobs.patch --- prometheus-alertmanager-0.15.3+ds/debian/patches/02-Do_not_embed_blobs.patch 2019-01-14 22:40:29.000000000 +0000 +++ prometheus-alertmanager-0.15.3+ds/debian/patches/02-Do_not_embed_blobs.patch 2019-02-21 19:36:45.000000000 +0000 @@ -5,9 +5,11 @@ Author: Martín Ferrari Last-Update: 2016-07-12 ---- a/ui/web.go -+++ b/ui/web.go -@@ -14,59 +14,36 @@ +Index: prometheus-alertmanager/ui/web.go +=================================================================== +--- prometheus-alertmanager.orig/ui/web.go ++++ prometheus-alertmanager/ui/web.go +@@ -14,61 +14,34 @@ package ui import ( @@ -46,40 +48,41 @@ - // Register registers handlers to serve files for the web interface. -func Register(r *route.Router, reloadCh chan<- chan error, logger log.Logger) { -+func Register(r *route.Router, reloadCh chan<- chan error, localAssets string) { ++func Register(r *route.Router, reloadCh chan<- chan error, uiPath string) { r.Get("/metrics", promhttp.Handler().ServeHTTP) r.Get("/", http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { - serveAsset(w, req, "ui/app/index.html", logger) -- })) -- -- r.Get("/script.js", http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { ++ http.ServeFile(w, req, filepath.Join(uiPath, "index.html")) + })) + + r.Get("/script.js", http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { - serveAsset(w, req, "ui/app/script.js", logger) -+ http.ServeFile(w, req, filepath.Join(localAssets, "ui/index.html")) ++ http.ServeFile(w, req, filepath.Join(uiPath, "script.js")) })) r.Get("/favicon.ico", http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { - serveAsset(w, req, "ui/app/favicon.ico", logger) -+ http.ServeFile(w, req, filepath.Join(localAssets, "ui/favicon.ico")) ++ http.ServeFile(w, req, filepath.Join(uiPath, "favicon.ico")) })) -+ r.Get("/app/*filepath", http.HandlerFunc( -+ func(w http.ResponseWriter, req *http.Request) { -+ route.FileServe(filepath.Join(localAssets, "ui/app")) -+ }, -+ )) -+ - r.Get("/lib/*filepath", http.HandlerFunc( - func(w http.ResponseWriter, req *http.Request) { +- r.Get("/lib/*filepath", http.HandlerFunc( +- func(w http.ResponseWriter, req *http.Request) { - fp := route.Param(req.Context(), "filepath") - serveAsset(w, req, filepath.Join("ui/app/lib", fp), logger) -+ route.FileServe(filepath.Join(localAssets, "ui/lib")) - }, - )) - ---- a/template/template.go -+++ b/template/template.go -@@ -15,6 +15,7 @@ +- }, +- )) ++ r.Get("/app/*filepath", route.FileServe(filepath.Join(uiPath, "app"))) ++ ++ r.Get("/lib/*filepath", route.FileServe(filepath.Join(uiPath, "lib"))) + + r.Post("/-/reload", http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { + errc := make(chan error) +Index: prometheus-alertmanager/template/template.go +=================================================================== +--- prometheus-alertmanager.orig/template/template.go ++++ prometheus-alertmanager/template/template.go +@@ -15,6 +15,7 @@ package template import ( "bytes" @@ -87,7 +90,7 @@ "net/url" "path/filepath" "regexp" -@@ -27,7 +28,6 @@ +@@ -27,7 +28,6 @@ import ( "github.com/prometheus/common/model" @@ -95,7 +98,7 @@ "github.com/prometheus/alertmanager/types" ) -@@ -41,25 +41,25 @@ +@@ -41,25 +41,25 @@ type Template struct { // FromGlobs calls ParseGlob on all path globs provided and returns the // resulting Template. @@ -133,37 +136,42 @@ } for _, tp := range paths { ---- a/cmd/alertmanager/main.go -+++ b/cmd/alertmanager/main.go -@@ -148,6 +148,7 @@ +Index: prometheus-alertmanager/cmd/alertmanager/main.go +=================================================================== +--- prometheus-alertmanager.orig/cmd/alertmanager/main.go ++++ prometheus-alertmanager/cmd/alertmanager/main.go +@@ -148,6 +148,8 @@ func main() { externalURL = kingpin.Flag("web.external-url", "The URL under which Alertmanager is externally reachable (for example, if Alertmanager is served via a reverse proxy). Used for generating relative and absolute links back to Alertmanager itself. If the URL has a path portion, it will be used to prefix all HTTP endpoints served by Alertmanager. If omitted, relevant URL components will be derived automatically.").String() routePrefix = kingpin.Flag("web.route-prefix", "Prefix for the internal routes of web endpoints. Defaults to path of --web.external-url.").String() listenAddress = kingpin.Flag("web.listen-address", "Address to listen on for the web interface and API.").Default(":9093").String() -+ localAssets = kingpin.Flag("web.local-assets", "Path to static assets/templates directory.").Default("/usr/share/prometheus/alertmanager/").String() ++ uiPath = kingpin.Flag("web.ui-path", "Path to static UI directory.").Default("/usr/share/prometheus/alertmanager/ui/").String() ++ defaultTemplate = kingpin.Flag("template.default", "Path to default notification template.").Default("/usr/share/prometheus/alertmanager/default.tmpl").String() clusterBindAddr = kingpin.Flag("cluster.listen-address", "Listen address for cluster."). Default(defaultClusterAddr).String() -@@ -343,7 +344,7 @@ +@@ -343,7 +345,7 @@ func main() { return err } - tmpl, err = template.FromGlobs(conf.Templates...) -+ tmpl, err = template.FromGlobs(filepath.Join(*localAssets, "default.tmpl"), conf.Templates...) ++ tmpl, err = template.FromGlobs(*defaultTemplate, conf.Templates...) if err != nil { return err } -@@ -391,7 +392,7 @@ +@@ -391,7 +393,7 @@ func main() { webReload := make(chan chan error) - ui.Register(router, webReload, logger) -+ ui.Register(router, webReload, *localAssets) ++ ui.Register(router, webReload, *uiPath) apiv.Register(router.WithPrefix("/api/v1")) ---- a/cli/check_config.go -+++ b/cli/check_config.go -@@ -83,7 +83,7 @@ +Index: prometheus-alertmanager/cli/check_config.go +=================================================================== +--- prometheus-alertmanager.orig/cli/check_config.go ++++ prometheus-alertmanager/cli/check_config.go +@@ -83,7 +83,7 @@ func CheckConfig(args []string) error { fmt.Printf(" - %d receivers\n", len(cfg.Receivers)) fmt.Printf(" - %d templates\n", len(cfg.Templates)) if len(cfg.Templates) > 0 { @@ -172,9 +180,11 @@ if err != nil { fmt.Printf(" FAILED: %s\n", err) failed++ ---- a/notify/impl_test.go -+++ b/notify/impl_test.go -@@ -205,7 +205,7 @@ +Index: prometheus-alertmanager/notify/impl_test.go +=================================================================== +--- prometheus-alertmanager.orig/notify/impl_test.go ++++ prometheus-alertmanager/notify/impl_test.go +@@ -205,7 +205,7 @@ func defaultRetryCodes() []int { } func createTmpl(t *testing.T) *template.Template { diff -Nru prometheus-alertmanager-0.15.3+ds/debian/patches/03-Fix_acceptance_test.patch prometheus-alertmanager-0.15.3+ds/debian/patches/03-Fix_acceptance_test.patch --- prometheus-alertmanager-0.15.3+ds/debian/patches/03-Fix_acceptance_test.patch 2019-01-14 22:40:29.000000000 +0000 +++ prometheus-alertmanager-0.15.3+ds/debian/patches/03-Fix_acceptance_test.patch 2019-02-21 19:36:45.000000000 +0000 @@ -17,7 +17,7 @@ "--config.file", am.confFile.Name(), "--log.level", "debug", "--web.listen-address", am.apiAddr, -+ "--web.local-assets", "../../template", ++ "--template.default", "../../template/default.tmpl", "--storage.path", am.dir, "--cluster.listen-address", am.clusterAddr, "--cluster.settle-timeout", "0s",