mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-10 15:44:05 -08:00
Merge pull request #811 from prometheus/fabxc/version
Move version info to its own package and add version endpoint.
This commit is contained in:
commit
2bf7e1ac98
|
@ -17,7 +17,7 @@
|
|||
|
||||
current_dir := $(patsubst %/,%, $(dir $(abspath $(lastword $(MAKEFILE_LIST)))))
|
||||
|
||||
VERSION=$(shell cat $(current_dir)/VERSION)
|
||||
VERSION=$(shell cat $(current_dir)/version/VERSION)
|
||||
|
||||
OS=$(shell uname)
|
||||
ARCH=$(shell uname -m)
|
||||
|
@ -54,7 +54,8 @@ GO = $(GOENV) $(GOCC)
|
|||
GOFMT = $(GOROOT)/bin/gofmt
|
||||
|
||||
UNAME := $(shell uname)
|
||||
SELFLINK = $(GOPATH)/src/github.com/prometheus/prometheus
|
||||
REPO_PATH = github.com/prometheus/prometheus
|
||||
SELFLINK = $(GOPATH)/src/$(REPO_PATH)
|
||||
|
||||
export PREFIX=$(BUILD_PATH)/root
|
||||
|
||||
|
@ -69,12 +70,12 @@ BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2> /dev/null || echo 'unk
|
|||
HOSTNAME := $(shell hostname -f)
|
||||
BUILD_DATE := $(shell date +%Y%m%d-%H:%M:%S)
|
||||
BUILDFLAGS := -ldflags \
|
||||
" -X main.buildVersion $(VERSION)\
|
||||
-X main.buildRevision $(REV)\
|
||||
-X main.buildBranch $(BRANCH)\
|
||||
-X main.buildUser $(USER)@$(HOSTNAME)\
|
||||
-X main.buildDate $(BUILD_DATE)\
|
||||
-X main.goVersion $(GO_VERSION)"
|
||||
" -X $(REPO_PATH)/version.Version $(VERSION)\
|
||||
-X $(REPO_PATH)/version.Revision $(REV)\
|
||||
-X $(REPO_PATH)/version.Branch $(BRANCH)\
|
||||
-X $(REPO_PATH)/version.BuildUser $(USER)@$(HOSTNAME)\
|
||||
-X $(REPO_PATH)/version.BuildDate $(BUILD_DATE)\
|
||||
-X $(REPO_PATH)/version.GoVersion $(GO_VERSION)"
|
||||
PROTOC := protoc
|
||||
CURL := curl
|
||||
|
||||
|
|
|
@ -1,46 +0,0 @@
|
|||
// Copyright 2013 The Prometheus Authors
|
||||
// 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.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"text/template"
|
||||
)
|
||||
|
||||
// Build information. Populated by Makefile.
|
||||
var (
|
||||
buildVersion string
|
||||
buildRevision string
|
||||
buildBranch string
|
||||
buildUser string
|
||||
buildDate string
|
||||
goVersion string
|
||||
)
|
||||
|
||||
// BuildInfo encapsulates compile-time metadata about Prometheus made available
|
||||
// via go tool ld such that this can be reported on-demand.
|
||||
var BuildInfo = map[string]string{
|
||||
"version": buildVersion,
|
||||
"revision": buildRevision,
|
||||
"branch": buildBranch,
|
||||
"user": buildUser,
|
||||
"date": buildDate,
|
||||
"go_version": goVersion,
|
||||
}
|
||||
|
||||
var versionInfoTmpl = template.Must(template.New("version").Parse(
|
||||
`prometheus, version {{.version}} (branch: {{.branch}}, revision: {{.revision}})
|
||||
build user: {{.user}}
|
||||
build date: {{.date}}
|
||||
go version: {{.go_version}}
|
||||
`))
|
|
@ -15,11 +15,14 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"flag"
|
||||
"fmt"
|
||||
_ "net/http/pprof" // Comment this line to disable pprof endpoint.
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
"text/template"
|
||||
"time"
|
||||
|
||||
"github.com/prometheus/log"
|
||||
|
@ -36,6 +39,7 @@ import (
|
|||
"github.com/prometheus/prometheus/storage/remote"
|
||||
"github.com/prometheus/prometheus/storage/remote/influxdb"
|
||||
"github.com/prometheus/prometheus/storage/remote/opentsdb"
|
||||
"github.com/prometheus/prometheus/version"
|
||||
"github.com/prometheus/prometheus/web"
|
||||
)
|
||||
|
||||
|
@ -48,7 +52,7 @@ func Main() int {
|
|||
return 2
|
||||
}
|
||||
|
||||
versionInfoTmpl.Execute(os.Stdout, BuildInfo)
|
||||
printVersion()
|
||||
if cfg.printVersion {
|
||||
return 0
|
||||
}
|
||||
|
@ -101,7 +105,6 @@ func Main() int {
|
|||
})
|
||||
|
||||
status := &web.PrometheusStatus{
|
||||
BuildInfo: BuildInfo,
|
||||
TargetPools: targetManager.Pools,
|
||||
Rules: ruleManager.Rules,
|
||||
Flags: flags,
|
||||
|
@ -202,3 +205,19 @@ func reloadConfig(filename string, rls ...Reloadable) bool {
|
|||
}
|
||||
return success
|
||||
}
|
||||
|
||||
var versionInfoTmpl = `prometheus, version {{.version}} (branch: {{.branch}}, revision: {{.revision}})
|
||||
build user: {{.buildUser}}
|
||||
build date: {{.builDate}}
|
||||
go version: {{.goVersion}}
|
||||
`
|
||||
|
||||
func printVersion() {
|
||||
t := template.Must(template.New("version").Parse(versionInfoTmpl))
|
||||
|
||||
var buf bytes.Buffer
|
||||
if err := t.ExecuteTemplate(&buf, "version", version.Map); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Fprint(os.Stdout, buf.String())
|
||||
}
|
||||
|
|
34
version/info.go
Normal file
34
version/info.go
Normal file
|
@ -0,0 +1,34 @@
|
|||
// Copyright 2015 The Prometheus Authors
|
||||
// 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.
|
||||
|
||||
package version
|
||||
|
||||
// Build information. Populated at build-time.
|
||||
var (
|
||||
Version string
|
||||
Revision string
|
||||
Branch string
|
||||
BuildUser string
|
||||
BuildDate string
|
||||
GoVersion string
|
||||
)
|
||||
|
||||
// Map provides the iterable version information.
|
||||
var Map = map[string]string{
|
||||
"version": Version,
|
||||
"revision": Revision,
|
||||
"branch": Branch,
|
||||
"buildUser": BuildUser,
|
||||
"buildDate": BuildDate,
|
||||
"goVersion": GoVersion,
|
||||
}
|
|
@ -165,7 +165,7 @@ func templatesGraphHtml() (*asset, error) {
|
|||
return a, nil
|
||||
}
|
||||
|
||||
var _templatesStatusHtml = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\xcc\x56\x4b\x6f\xdb\x30\x0c\xbe\xe7\x57\x68\x46\x8f\xb3\x03\x0c\xd8\xa5\x48\x72\x48\xd1\xa1\x05\xd2\xa1\xe8\xe3\xb2\x4b\x21\xdb\x8c\xad\x4d\x95\x0c\x49\xee\x5a\xb8\xfe\xef\x23\xe5\xb8\x71\xfc\xd8\x8a\x3d\xb0\x5e\x0c\x51\xa2\x29\xf2\xfb\x3e\xd2\xae\xaa\x14\xb6\x42\x01\x0b\x72\xe0\x69\x50\xd7\x8b\x77\x61\xc8\x94\x78\x64\x61\xb8\xaa\x2a\x50\x69\x5d\xcf\x66\x7b\xaf\x44\x2b\x07\xca\xa1\xe3\x8c\xb1\x45\x2a\x1e\x58\x22\xb9\xb5\x4b\x7f\xc0\xd1\xc5\x84\x5b\x59\x8a\x34\x58\xe1\x39\x7a\xe4\x1f\x56\x57\xa5\x72\xe2\x1e\xd8\xb9\xda\x6a\x73\xcf\x9d\xd0\x6a\x31\xc7\xfd\xc6\xc1\xf1\x58\x42\x1b\xa4\x31\xfc\x33\xc4\x80\x29\x28\x0b\xe9\xce\x8e\xb5\x49\xc1\xbc\x98\xd6\x19\x51\xbc\x58\xb9\x7e\x00\xb3\xbb\x93\x82\xc6\x3a\x7d\x6a\x2d\xb2\xcd\xde\x20\x33\x5f\xdd\x16\x94\xd3\x62\x8e\xcb\x83\x93\x14\x8b\x8e\xd6\xc2\xb8\x1c\xa1\x98\xa3\xb9\x0f\x32\xdf\x47\xc1\xf5\xfe\x06\x34\x28\x87\xd5\xec\xa5\xe2\x75\x29\x64\xfa\x1f\xeb\xad\x2a\xc3\x55\x06\xec\xe8\x1b\x3c\xbd\x67\x47\x0f\x5c\x96\xc0\x8e\x97\x2c\xf2\x89\x51\x5e\x9e\xbe\x29\x70\x98\x4d\x74\x01\xcb\xc0\xe8\xef\x01\xc2\x41\x51\x3c\x18\x23\x50\x35\xb1\x7f\x06\x15\x65\xd3\xa8\xe8\x55\xd0\x9d\x68\xb5\x15\x59\x69\xfa\xb0\x15\x06\x88\x99\xe6\x98\xee\xa3\x8d\x59\x47\x63\x12\xec\xc0\xbd\x41\x21\xe1\x52\xb2\xc8\x7b\xd4\x35\xc6\x38\xbb\xb9\xd8\x5c\x2b\x51\x14\xe0\x58\xc1\x5d\x7e\x69\x50\xdb\x8f\x18\x33\x36\xf3\x56\xf2\xfd\xf8\x37\xdc\x64\xe0\x3a\x37\xfc\x23\x26\x3b\xdc\x7d\xd5\x31\x72\x57\x68\x2d\x89\xba\xa6\x88\x26\x8d\x4b\xdc\xb3\x1d\x06\x3d\x69\xd8\xbd\x5d\x7a\x1a\x5e\x89\xcc\x04\x9d\x0b\xae\x96\xc1\xc7\xa0\x4d\x16\x43\xdf\xd1\x0b\x74\x31\x72\x88\xe6\x8e\xdf\x43\xe2\x46\xd4\xb1\xbb\x6c\x75\xaa\xd2\x42\x0b\xe5\xfa\xaa\x68\xcf\xaf\x1d\x77\x83\xee\x6a\x0f\xd7\xdc\x02\xdb\xf0\x18\xa4\x9d\x72\xd9\x70\xeb\xd8\x75\x62\x78\x31\x19\xe5\xd4\x18\x6d\x86\x87\xfd\x12\xc8\xa3\x87\x4d\xbf\x5d\x3a\xa0\x13\xdc\x07\xc8\x4e\x20\x90\xf6\xb7\x70\x93\xb3\x1c\x95\xb4\x0c\x50\x62\xb7\x57\x1b\xf6\xcc\x32\xa9\x63\x2e\x71\x5d\xd7\x84\x73\xe4\x57\x8b\x39\x1f\x84\x9b\x0f\xe3\x8d\x5f\x41\x44\xb6\x24\x72\x09\xc6\x31\xff\x0c\xab\x8a\x45\x04\x79\x69\xa3\x33\xe0\x12\x59\x7f\x66\xb9\x5f\xdc\xe8\x13\x72\x67\x75\x8d\x7a\x23\xf1\xdc\x59\xef\x77\xe7\x5f\x0c\x86\x77\x10\x18\x87\xb1\x7a\x78\x34\x19\x53\x26\x7f\xa7\x8e\xa4\x34\x56\x9b\xd0\xcb\x09\x05\xc9\x52\xee\x78\xe8\x74\x96\x49\x1c\x41\x0e\xf9\x70\xa2\x08\x98\x13\x8e\xec\xdd\xb1\x36\x22\x13\x8a\xcb\x70\xb7\xbd\x06\x1c\xb5\xc0\x0c\x48\x52\x95\x50\xd9\x31\x55\x71\x01\x8e\x37\x32\x23\x02\x46\x2b\x3d\x8a\x51\x8b\x8d\x0f\x75\x99\x6f\xcd\x9d\x19\xad\xf7\x47\xd4\x31\x01\x0b\x84\x42\xf0\x54\x02\xc1\x08\x24\x14\x4d\x6c\x59\x27\xe0\xa8\x53\x47\x6b\x3e\xd7\xee\x78\xfe\xf5\xbb\x3d\xe8\x7c\x04\xe6\x9f\x61\x61\xc4\x3d\x37\x4f\xbe\xa1\xfd\x4e\x5d\x93\x14\xdb\x01\x1d\x8c\x53\xd6\xa6\xd4\x9d\xd0\xbd\x13\x69\x61\x22\x9b\xc9\x5c\xf0\x67\x81\x97\x12\xd5\xa5\xb4\x82\xe9\x8b\xa7\xae\xfd\x43\x75\x79\x1e\x5a\x09\xd3\x20\x69\xe6\x48\x74\x6e\xbf\x80\xc1\x2f\xdf\x67\xc0\x89\xdb\x16\x56\x55\x56\x20\xa3\x23\xfe\xd8\x31\x3c\xd3\xe3\x39\xfe\x7e\x2e\x7e\x6a\x8d\xd5\x3c\xd5\xda\x29\x89\xc5\x8c\x37\xef\xbe\x53\x3b\xa1\xa7\xf0\x7e\x6d\x25\xfd\x01\x3a\x7c\xef\xe0\x13\x3e\x74\x19\x7e\xd4\x31\x49\xe3\xca\x82\x7d\x92\x3c\xb3\x6f\xe5\x5f\xc8\x27\xf3\xd6\xfe\x83\x68\x89\x3f\xd5\xab\x59\xeb\xfc\x23\x00\x00\xff\xff\x6d\x4a\x14\xff\xa0\x0b\x00\x00")
|
||||
var _templatesStatusHtml = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\xcc\x56\xcb\x6e\xdb\x3a\x10\xdd\xfb\x2b\x78\x85\x2c\xaf\x6c\xe0\x02\x77\x13\xd8\x5e\x38\x48\x91\x00\x4e\x11\xe4\xb1\xe9\x26\xa0\xa4\xb1\xc4\x96\x21\x05\x92\x4a\x13\x28\xfa\xf7\xce\x50\x92\x2d\xeb\xd1\x06\x7d\xa0\xd9\x08\x1c\x72\x34\x8f\x73\xce\x50\x2a\xcb\x04\x76\x42\x01\x0b\x32\xe0\x49\x50\x55\xcb\x7f\xc2\x90\x29\xf1\xcc\xc2\x70\x5d\x96\xa0\x92\xaa\x9a\xcd\x0e\x5e\xb1\x56\x0e\x94\x43\xc7\x19\x63\xcb\x44\x3c\xb1\x58\x72\x6b\x57\xfe\x80\xa3\x8b\x09\x77\xb2\x10\x49\xb0\xc6\x73\xf4\xc8\xfe\x5b\xdf\x14\xca\x89\x47\x60\x97\x6a\xa7\xcd\x23\x77\x42\xab\xe5\x02\xf7\x6b\x07\xc7\x23\x09\x6d\x90\xda\xf0\xcf\x10\x03\x26\xa0\x2c\x24\x8d\x1d\x69\x93\x80\xd9\x9b\xd6\x19\x91\xef\xad\x4c\x3f\x81\x69\x72\x52\xd0\x48\x27\x2f\xad\x45\xb6\x39\x18\x64\x66\xeb\xfb\x9c\x6a\x5a\x2e\x70\x79\x74\x92\x60\xd3\xf3\x5b\xc7\x5d\x61\xe7\x1b\x61\x5c\x86\x88\x2c\x70\xf7\x10\x6b\x71\x08\x86\xeb\x43\x22\x34\xa8\x94\xf5\x6c\xdf\xf8\xa6\x10\x32\xf9\x8b\x6d\x97\xa5\xe1\x2a\x05\x76\xf2\x05\x5e\xfe\x65\x27\x4f\x5c\x16\xc0\x4e\x57\x6c\x4e\x25\x79\x02\xa7\xe0\x61\x36\xd6\x39\xac\x02\xa3\xbf\x06\x08\x08\x05\xf0\x38\x8c\x80\x55\x87\xfd\x1e\x4a\x54\x48\xad\xa3\x37\xa1\x76\xa6\xd5\x4e\xa4\x85\xe9\x23\x96\x1b\xe8\x70\x53\x7b\x51\x5a\xda\x9f\x75\xc4\x26\xc1\x0e\xde\xaa\x71\x88\xb9\x94\xac\x0d\xe0\x1d\xab\x0a\x23\x5e\xdc\x5d\x6d\x6f\x95\xc8\x73\x70\x2c\xe7\x2e\xbb\x36\xa8\xf5\x67\x0c\x1d\x99\x45\x3b\x02\xfd\x34\x77\xdc\xa4\xe0\x3a\x89\xfe\x10\xa5\x1d\x12\x3f\xeb\x08\x49\xcc\xb5\x96\xc4\xe1\x51\x2f\x75\x35\xd7\x78\x64\x3b\xb4\x7a\x26\x71\xa8\xbb\x9c\xd5\x64\x13\xc3\x31\x3a\xe7\x5c\xad\x82\xff\x83\xb6\x66\xcc\xf0\x40\x2f\x50\x7e\x24\x16\xcd\x86\xf4\x63\x36\x47\x24\xd3\x24\x5b\x9f\xab\x24\xd7\x42\xb9\xbe\x54\xda\x73\xaa\x77\x30\x74\xed\xe1\x86\x5b\x60\x5b\x1e\x81\xb4\x53\x2e\x5b\x6e\x1d\xbb\x8d\x0d\xcf\x27\xa3\x9c\x1b\xa3\xcd\xf0\xb0\xdf\x02\x79\xf4\xb0\xe9\x8f\x4f\x07\x7b\x42\xfd\x08\xd9\x09\x04\x92\xfe\x16\x6e\x72\x96\xa1\xa0\x56\x01\x2a\xed\xfe\x66\xcb\x5e\x59\x2a\x75\xc4\x25\xae\xab\x8a\x70\x9e\xfb\xd5\x72\xc1\x07\xe1\x16\xc3\x78\xe3\x29\x88\xc8\x96\x44\x2e\xc1\x38\xe6\x9f\x61\x59\xee\x25\x72\x01\x5c\x22\xeb\xaf\x2c\xf3\x8b\x3b\x7d\x46\xee\xac\xaa\x50\x76\x24\x9e\x07\xeb\xfd\x1e\xfc\x8b\xc1\x30\x07\x81\x71\x1c\xab\x87\x47\x5d\x31\x55\xf2\x7b\xfa\x88\x0b\x63\xb5\x09\xbd\x9c\x50\x90\x2c\xe1\x8e\x87\x4e\xa7\xa9\xc4\x7b\xc9\x21\x1f\x4e\xe4\x01\x73\xc2\x91\xdd\x1c\x6b\x23\x52\xa1\xb8\x0c\x9b\xed\x0d\xe0\xd5\x0b\xcc\x80\x24\x55\x09\x95\x9e\x52\x17\x57\xe0\x78\x2d\x33\x22\x60\xb4\xd3\x93\x08\xb5\x58\xfb\xd0\xb0\xf9\x09\x6d\xcc\xf9\xe6\x70\x44\x13\x13\xb0\x40\x28\x04\x4f\xc5\x10\x8c\x40\x42\xd1\xc4\x8e\x75\x02\x8e\x3a\x75\xb4\xe6\x6b\xed\x5e\xd7\x3f\x7e\xb7\x07\x9d\x8f\xc0\xfc\x33\xcc\x8d\x78\xe4\xe6\xc5\x0f\xb4\xdf\xa9\x2a\x92\x62\x7b\x6b\x07\xe3\x94\xb5\x25\x75\xaf\xed\xde\x89\xb4\x30\x51\xcd\x64\x2d\xf8\x0f\xc1\x0b\x89\xea\x52\x5a\xc1\x74\xe2\xa9\xb4\xbf\xa8\x2e\xcf\x43\x2b\x61\xba\x48\xea\x7b\x64\x7e\x69\x3f\x81\xc1\xcf\xe1\x47\xc0\x8b\xb7\x6d\xac\x2c\xad\x40\x46\x47\xfc\x71\x62\x78\xaa\xc7\x6b\xfc\xf9\x5a\xfc\xad\x35\xd6\xf3\xd4\x68\x27\x24\x16\x33\x3e\xbc\x87\x49\xed\x84\x9e\xc2\xfb\xad\x9d\xf4\x2f\xd0\xe1\x7b\x47\xdf\xf5\xa1\xcb\xf0\x4b\x8f\x45\x1a\x57\xe4\xec\x83\xe4\xa9\x7d\x2f\xff\x46\x0d\x72\xbe\xa6\xf7\xf6\x8f\x44\x4b\xfc\xe5\x5e\xcf\x5a\xe7\x6f\x01\x00\x00\xff\xff\x50\x97\xbd\xdc\xbe\x0b\x00\x00")
|
||||
|
||||
func templatesStatusHtmlBytes() ([]byte, error) {
|
||||
return bindataRead(
|
||||
|
@ -180,7 +180,7 @@ func templatesStatusHtml() (*asset, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
info := bindataFileInfo{name: "templates/status.html", size: 2976, mode: os.FileMode(420), modTime: time.Unix(1434365394, 0)}
|
||||
info := bindataFileInfo{name: "templates/status.html", size: 3006, mode: os.FileMode(420), modTime: time.Unix(1434457438, 0)}
|
||||
a := &asset{bytes: bytes, info: info}
|
||||
return a, nil
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<tbody>
|
||||
<tr>
|
||||
<th>Uptime</th>
|
||||
<td>{{.Birth}}</td>
|
||||
<td>{{.Status.Birth}}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
@ -15,7 +15,7 @@
|
|||
<h2>Build Information</h2>
|
||||
<table class="table table-condensed table-bordered table-striped table-hover">
|
||||
<tbody>
|
||||
{{range $key, $value := .BuildInfo}}
|
||||
{{range $key, $value := .Info}}
|
||||
<tr>
|
||||
<th scope="row">{{$key}}</th>
|
||||
<td>{{$value}}</td>
|
||||
|
@ -25,14 +25,14 @@
|
|||
</table>
|
||||
|
||||
<h2>Configuration</h2>
|
||||
<pre>{{.Config}}</pre>
|
||||
<pre>{{.Status.Config}}</pre>
|
||||
|
||||
<h2>Rules</h2>
|
||||
<pre>{{range call .Rules}}{{.HTMLSnippet pathPrefix}}<br/>{{end}}</pre>
|
||||
<pre>{{range call .Status.Rules}}{{.HTMLSnippet pathPrefix}}<br/>{{end}}</pre>
|
||||
|
||||
<h2>Targets</h2>
|
||||
<table class="table table-condensed table-bordered table-striped table-hover">
|
||||
{{range $job, $pool := call .TargetPools}}
|
||||
{{range $job, $pool := call .Status.TargetPools}}
|
||||
<thead>
|
||||
<tr><th colspan="5" class="job_header">{{$job}}</th></tr>
|
||||
<tr>
|
||||
|
@ -83,7 +83,7 @@
|
|||
<h2>Startup Flags</h2>
|
||||
<table class="table table-condensed table-bordered table-striped table-hover">
|
||||
<tbody>
|
||||
{{range $key, $value := .Flags}}
|
||||
{{range $key, $value := .Status.Flags}}
|
||||
<tr>
|
||||
<th scope="row">{{$key}}</th>
|
||||
<td>{{$value}}</td>
|
||||
|
|
49
web/web.go
49
web/web.go
|
@ -14,6 +14,7 @@
|
|||
package web
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
|
@ -40,6 +41,7 @@ import (
|
|||
"github.com/prometheus/prometheus/storage/local"
|
||||
"github.com/prometheus/prometheus/template"
|
||||
"github.com/prometheus/prometheus/util/route"
|
||||
"github.com/prometheus/prometheus/version"
|
||||
"github.com/prometheus/prometheus/web/api/legacy"
|
||||
"github.com/prometheus/prometheus/web/api/v1"
|
||||
"github.com/prometheus/prometheus/web/blob"
|
||||
|
@ -55,10 +57,10 @@ type Handler struct {
|
|||
apiV1 *v1.API
|
||||
apiLegacy *legacy.API
|
||||
|
||||
router *route.Router
|
||||
quitCh chan struct{}
|
||||
options *Options
|
||||
status *PrometheusStatus
|
||||
router *route.Router
|
||||
quitCh chan struct{}
|
||||
options *Options
|
||||
statusInfo *PrometheusStatus
|
||||
|
||||
muAlerts sync.Mutex
|
||||
}
|
||||
|
@ -66,10 +68,9 @@ type Handler struct {
|
|||
// PrometheusStatus contains various information about the status
|
||||
// of the running Prometheus process.
|
||||
type PrometheusStatus struct {
|
||||
Birth time.Time
|
||||
BuildInfo map[string]string
|
||||
Flags map[string]string
|
||||
Config string
|
||||
Birth time.Time
|
||||
Flags map[string]string
|
||||
Config string
|
||||
|
||||
// A function that returns the current scrape targets pooled
|
||||
// by their job name.
|
||||
|
@ -107,10 +108,10 @@ func New(st local.Storage, qe *promql.Engine, rm *rules.Manager, status *Prometh
|
|||
router := route.New()
|
||||
|
||||
h := &Handler{
|
||||
router: router,
|
||||
quitCh: make(chan struct{}),
|
||||
options: o,
|
||||
status: status,
|
||||
router: router,
|
||||
quitCh: make(chan struct{}),
|
||||
options: o,
|
||||
statusInfo: status,
|
||||
|
||||
ruleManager: rm,
|
||||
queryEngine: qe,
|
||||
|
@ -137,9 +138,10 @@ func New(st local.Storage, qe *promql.Engine, rm *rules.Manager, status *Prometh
|
|||
instrf := prometheus.InstrumentHandlerFunc
|
||||
instrh := prometheus.InstrumentHandler
|
||||
|
||||
router.Get("/", instrf("status", h.statush))
|
||||
router.Get("/", instrf("status", h.status))
|
||||
router.Get("/alerts", instrf("alerts", h.alerts))
|
||||
router.Get("/graph", instrf("graph", h.graph))
|
||||
router.Get("/version", instrf("version", h.version))
|
||||
|
||||
router.Get("/heap", instrf("heap", dumpHeap))
|
||||
|
||||
|
@ -259,11 +261,24 @@ func (h *Handler) graph(w http.ResponseWriter, r *http.Request) {
|
|||
h.executeTemplate(w, "graph", nil)
|
||||
}
|
||||
|
||||
func (h *Handler) statush(w http.ResponseWriter, r *http.Request) {
|
||||
h.status.mu.RLock()
|
||||
defer h.status.mu.RUnlock()
|
||||
func (h *Handler) status(w http.ResponseWriter, r *http.Request) {
|
||||
h.statusInfo.mu.RLock()
|
||||
defer h.statusInfo.mu.RUnlock()
|
||||
|
||||
h.executeTemplate(w, "status", h.status)
|
||||
h.executeTemplate(w, "status", struct {
|
||||
Status *PrometheusStatus
|
||||
Info map[string]string
|
||||
}{
|
||||
Status: h.statusInfo,
|
||||
Info: version.Map,
|
||||
})
|
||||
}
|
||||
|
||||
func (h *Handler) version(w http.ResponseWriter, r *http.Request) {
|
||||
dec := json.NewEncoder(w)
|
||||
if err := dec.Encode(version.Map); err != nil {
|
||||
http.Error(w, fmt.Sprintf("error encoding JSON: %s", err), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
func (h *Handler) quit(w http.ResponseWriter, r *http.Request) {
|
||||
|
|
Loading…
Reference in a new issue