mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-09 23:24:05 -08:00
Show loaded rules in Status dashboard.
This commit is contained in:
parent
fc97e688c6
commit
ba29d07901
18
main.go
18
main.go
|
@ -212,6 +212,14 @@ func main() {
|
||||||
targetManager := retrieval.NewTargetManager(scrapeResults, *concurrentRetrievalAllowance)
|
targetManager := retrieval.NewTargetManager(scrapeResults, *concurrentRetrievalAllowance)
|
||||||
targetManager.AddTargetsFromConfig(conf)
|
targetManager.AddTargetsFromConfig(conf)
|
||||||
|
|
||||||
|
// Queue depth will need to be exposed
|
||||||
|
ruleManager := rules.NewRuleManager(ruleResults, conf.EvaluationInterval(), ts)
|
||||||
|
err = ruleManager.AddRulesFromConfig(conf)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Error loading rule files: %v", err)
|
||||||
|
}
|
||||||
|
go ruleManager.Run()
|
||||||
|
|
||||||
flags := map[string]string{}
|
flags := map[string]string{}
|
||||||
|
|
||||||
flag.VisitAll(func(f *flag.Flag) {
|
flag.VisitAll(func(f *flag.Flag) {
|
||||||
|
@ -222,6 +230,7 @@ func main() {
|
||||||
PrometheusStatus: &web.PrometheusStatus{
|
PrometheusStatus: &web.PrometheusStatus{
|
||||||
BuildInfo: BuildInfo,
|
BuildInfo: BuildInfo,
|
||||||
Config: conf.String(),
|
Config: conf.String(),
|
||||||
|
Rules: ruleManager.Rules(),
|
||||||
TargetPools: targetManager.Pools(),
|
TargetPools: targetManager.Pools(),
|
||||||
Flags: flags,
|
Flags: flags,
|
||||||
Birth: time.Now(),
|
Birth: time.Now(),
|
||||||
|
@ -321,15 +330,6 @@ func main() {
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// Queue depth will need to be exposed
|
|
||||||
|
|
||||||
ruleManager := rules.NewRuleManager(ruleResults, conf.EvaluationInterval(), ts)
|
|
||||||
err = ruleManager.AddRulesFromConfig(conf)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("Error loading rule files: %v", err)
|
|
||||||
}
|
|
||||||
go ruleManager.Run()
|
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
err := webService.ServeForever()
|
err := webService.ServeForever()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -30,6 +30,7 @@ type Result struct {
|
||||||
type RuleManager interface {
|
type RuleManager interface {
|
||||||
AddRulesFromConfig(config config.Config) error
|
AddRulesFromConfig(config config.Config) error
|
||||||
Run()
|
Run()
|
||||||
|
Rules() []Rule
|
||||||
}
|
}
|
||||||
|
|
||||||
type ruleManager struct {
|
type ruleManager struct {
|
||||||
|
@ -117,3 +118,12 @@ func (m *ruleManager) AddRulesFromConfig(config config.Config) error {
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *ruleManager) Rules() []Rule {
|
||||||
|
m.Lock()
|
||||||
|
defer m.Unlock()
|
||||||
|
|
||||||
|
rules := make([]Rule, len(m.rules))
|
||||||
|
copy(rules, m.rules)
|
||||||
|
return rules
|
||||||
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ package web
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/prometheus/prometheus/retrieval"
|
"github.com/prometheus/prometheus/retrieval"
|
||||||
|
"github.com/prometheus/prometheus/rules"
|
||||||
"github.com/prometheus/prometheus/storage/metric"
|
"github.com/prometheus/prometheus/storage/metric"
|
||||||
"net/http"
|
"net/http"
|
||||||
"sync"
|
"sync"
|
||||||
|
@ -26,7 +27,7 @@ type PrometheusStatus struct {
|
||||||
Config string
|
Config string
|
||||||
Curation metric.CurationState
|
Curation metric.CurationState
|
||||||
Flags map[string]string
|
Flags map[string]string
|
||||||
Rules string
|
Rules []rules.Rule
|
||||||
TargetPools map[string]*retrieval.TargetPool
|
TargetPools map[string]*retrieval.TargetPool
|
||||||
|
|
||||||
Birth time.Time
|
Birth time.Time
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
|
|
||||||
<h2>Rules</h2>
|
<h2>Rules</h2>
|
||||||
<div class="grouping_box">
|
<div class="grouping_box">
|
||||||
{{.Rules}}
|
<pre>{{range .Rules}}{{.String}}{{end}}</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h2>Targets</h2>
|
<h2>Targets</h2>
|
||||||
|
|
Loading…
Reference in a new issue