diff --git a/Makefile b/Makefile
new file mode 100644
index 00000000..73fb5037
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,36 @@
+# -*- Mode: makefile -*-
+
+# Copyright 2013 Prometheus Team
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+include Makefile.INCLUDE
+
+all: build test
+
+build: config web
+ $(GO) build $(BUILDFLAGS)
+
+config:
+ $(MAKE) -C config
+
+web:
+ $(MAKE) -C web
+
+test: build
+ $(GO) test -v ./...
+
+clean:
+ $(MAKE) -C web clean
+ -rm alertmanager
+
+.PHONY: clean config web
diff --git a/Makefile.INCLUDE b/Makefile.INCLUDE
new file mode 100644
index 00000000..7b1374b9
--- /dev/null
+++ b/Makefile.INCLUDE
@@ -0,0 +1,31 @@
+# -*- Mode: makefile -*-
+
+# Copyright 2013 Prometheus Team
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+.SUFFIXES:
+
+GO := $(GOROOT)/bin/go
+GOFMT := $(GOROOT)/bin/gofmt
+GO_VERSION := 1.1
+
+REV := $(shell git rev-parse --short HEAD)
+BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
+HOSTNAME := $(shell hostname -f)
+BUILD_DATE := $(shell date +%Y%m%d-%H:%M:%S)
+BUILDFLAGS := -ldflags \
+ "-X main.buildVersion $(REV)\
+ -X main.buildBranch $(BRANCH)\
+ -X main.buildUser $(USER)@$(HOSTNAME)\
+ -X main.buildDate $(BUILD_DATE)\
+ -X main.goVersion $(GO_VERSION)"
diff --git a/main.go b/main.go
index c7930efa..1daa4a81 100644
--- a/main.go
+++ b/main.go
@@ -16,6 +16,7 @@ package main
import (
"flag"
"log"
+ "os"
"time"
"github.com/prometheus/alertmanager/config"
@@ -32,6 +33,8 @@ var (
func main() {
flag.Parse()
+ versionInfoTmpl.Execute(os.Stdout, BuildInfo)
+
conf := config.MustLoadFromFile(*configFile)
silencer := manager.NewSilencer()
@@ -57,6 +60,18 @@ func main() {
aggregator := manager.NewAggregator(notifier)
defer aggregator.Close()
+ flags := map[string]string{}
+ flag.VisitAll(func(f *flag.Flag) {
+ flags[f.Name] = f.Value.String()
+ })
+
+ statusHandler := &web.StatusHandler{
+ Config: conf.String(),
+ Flags: flags,
+ BuildInfo: BuildInfo,
+ Birth: time.Now(),
+ }
+
webService := &web.WebService{
// REST API Service.
AlertManagerService: &api.AlertManagerService{
@@ -72,6 +87,7 @@ func main() {
SilencesHandler: &web.SilencesHandler{
Silencer: silencer,
},
+ StatusHandler: statusHandler,
}
go webService.ServeForever()
@@ -81,6 +97,7 @@ func main() {
go watcher.Watch(func(conf *config.Config) {
notifier.SetNotificationConfigs(conf.NotificationConfig)
aggregator.SetRules(conf.AggregationRules())
+ statusHandler.UpdateConfig(conf.String())
})
log.Println("Running summary dispatcher...")
diff --git a/web/status.go b/web/status.go
index 6ed058db..8c939a32 100644
--- a/web/status.go
+++ b/web/status.go
@@ -15,10 +15,29 @@ package web
import (
"net/http"
+ "sync"
+ "time"
)
-type StatusHandler struct{}
+type StatusHandler struct {
+ mu sync.Mutex
+
+ BuildInfo map[string]string
+ Config string
+ Flags map[string]string
+ Birth time.Time
+}
+
+func (h *StatusHandler) UpdateConfig(c string) {
+ h.mu.Lock()
+ defer h.mu.Unlock()
+
+ h.Config = c
+}
func (h *StatusHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
- executeTemplate(w, "status", nil)
+ h.mu.Lock()
+ defer h.mu.Unlock()
+
+ executeTemplate(w, "status", h)
}
diff --git a/web/templates/status.html b/web/templates/status.html
index fa62484a..5a483f9f 100644
--- a/web/templates/status.html
+++ b/web/templates/status.html
@@ -3,6 +3,42 @@
{{define "head"}}{{end}}
{{define "content"}}
-
Status
- Everything is going according to plan. Excellent. Move on.
+
+
Runtime Information
+
+
+
+ Uptime |
+ {{.Birth}} |
+
+
+
+
+
Build Information
+
+
+ {{range $key, $value := .BuildInfo}}
+
+ {{$key}} |
+ {{$value}} |
+
+ {{end}}
+
+
+
+
Configuration
+
{{.Config}}
+
+
Startup Flags
+
+
+ {{range $key, $value := .Flags}}
+
+ {{$key}} |
+ {{$value}} |
+
+ {{end}}
+
+
+
{{end}}