Skip to content

Commit

Permalink
Merge pull request thanos-io#2 from utilitywarehouse/rule
Browse files Browse the repository at this point in the history
Add Rule UI
  • Loading branch information
povilasv authored Aug 16, 2018
2 parents 422993c + 1d020af commit 444d2d8
Show file tree
Hide file tree
Showing 44 changed files with 13,813 additions and 35 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ assets:
@go get -u github.com/jteeuwen/go-bindata/...
@go-bindata $(bindata_flags) -pkg ui -o pkg/query/ui/bindata.go -ignore '(.*\.map|bootstrap\.js|bootstrap-theme\.css|bootstrap\.css)' pkg/query/ui/templates/... pkg/query/ui/static/...
@go fmt ./pkg/query/ui
@go-bindata $(bindata_flags) -pkg ui -o pkg/rule/ui/bindata.go -ignore '(.*\.map|bootstrap\.js|bootstrap-theme\.css|bootstrap\.css)' pkg/rule/ui/templates/... pkg/rule/ui/static/...
@go fmt ./pkg/rule/ui


# build builds Thanos binary using `promu`.
.PHONY: build
Expand Down
28 changes: 25 additions & 3 deletions cmd/thanos/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/improbable-eng/thanos/pkg/cluster"
"github.com/improbable-eng/thanos/pkg/objstore/client"
"github.com/improbable-eng/thanos/pkg/objstore/s3"
"github.com/improbable-eng/thanos/pkg/rule/ui"
"github.com/improbable-eng/thanos/pkg/runutil"
"github.com/improbable-eng/thanos/pkg/shipper"
"github.com/improbable-eng/thanos/pkg/store"
Expand All @@ -36,6 +37,7 @@ import (
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model"
"github.com/prometheus/common/route"
promlabels "github.com/prometheus/prometheus/pkg/labels"
"github.com/prometheus/prometheus/promql"
"github.com/prometheus/prometheus/rules"
Expand Down Expand Up @@ -197,6 +199,7 @@ func runRule(
NotifyFunc: notify,
Logger: log.With(logger, "component", "rules"),
Appendable: tsdb.Adapter(db, 0),
Registerer: reg,
ExternalURL: nil,
})
g.Add(func() error {
Expand Down Expand Up @@ -327,7 +330,7 @@ func runRule(
})
}

// Start HTTP and gRPC servers.
// Start gRPC server.
{
l, err := net.Listen("tcp", grpcBindAddr)
if err != nil {
Expand All @@ -347,8 +350,27 @@ func runRule(
runutil.CloseWithLogOnErr(logger, l, "store gRPC listener")
})
}
if err := metricHTTPListenGroup(g, logger, reg, httpBindAddr); err != nil {
return err
// Start UI & metrics HTTP server.
{
router := route.New()
ui.New(logger, mgr, alertQueryURL.String()).Register(router)

mux := http.NewServeMux()
registerMetrics(mux, reg)
registerProfile(mux)
mux.Handle("/", router)

l, err := net.Listen("tcp", httpBindAddr)
if err != nil {
return errors.Wrapf(err, "listen HTTP on address %s", httpBindAddr)
}

g.Add(func() error {
level.Info(logger).Log("msg", "Listening for ui requests", "address", httpBindAddr)
return errors.Wrap(http.Serve(l, mux), "serve query")
}, func(error) {
runutil.CloseWithLogOnErr(logger, l, "query and metric listener")
})
}

var uploads = true
Expand Down
64 changes: 32 additions & 32 deletions pkg/query/ui/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 444d2d8

Please sign in to comment.