2015-01-21 19:07:45 +00:00
|
|
|
// Copyright 2013 The Prometheus Authors
|
2013-02-12 12:15:40 +00:00
|
|
|
// 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 web
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
2013-05-05 17:32:04 +00:00
|
|
|
"sync"
|
2013-05-24 08:44:34 +00:00
|
|
|
"time"
|
2013-08-13 15:19:13 +00:00
|
|
|
|
|
|
|
"github.com/prometheus/prometheus/retrieval"
|
2015-03-30 17:43:19 +00:00
|
|
|
"github.com/prometheus/prometheus/rules"
|
2013-02-12 12:15:40 +00:00
|
|
|
)
|
|
|
|
|
2014-12-10 15:16:49 +00:00
|
|
|
// PrometheusStatusHandler implements http.Handler.
|
2013-08-13 15:19:13 +00:00
|
|
|
type PrometheusStatusHandler struct {
|
|
|
|
mu sync.RWMutex
|
|
|
|
|
2013-05-05 17:32:04 +00:00
|
|
|
BuildInfo map[string]string
|
2013-02-22 20:07:35 +00:00
|
|
|
Config string
|
2013-05-05 17:32:04 +00:00
|
|
|
Flags map[string]string
|
2015-04-29 08:26:49 +00:00
|
|
|
RuleManager *rules.Manager
|
2013-02-22 20:07:35 +00:00
|
|
|
TargetPools map[string]*retrieval.TargetPool
|
2013-05-24 08:44:34 +00:00
|
|
|
|
2015-04-29 08:26:49 +00:00
|
|
|
Birth time.Time
|
2015-03-24 21:04:38 +00:00
|
|
|
PathPrefix string
|
2013-02-12 12:15:40 +00:00
|
|
|
}
|
|
|
|
|
2015-03-18 17:53:43 +00:00
|
|
|
// TargetStateToClass returns a map of TargetState to the name of a Bootstrap CSS class.
|
2015-03-07 21:27:39 +00:00
|
|
|
func (h *PrometheusStatusHandler) TargetStateToClass() map[retrieval.TargetState]string {
|
|
|
|
return map[retrieval.TargetState]string{
|
|
|
|
retrieval.Unknown: "warning",
|
|
|
|
retrieval.Healthy: "success",
|
|
|
|
retrieval.Unhealthy: "danger",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-13 15:19:13 +00:00
|
|
|
func (h *PrometheusStatusHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
2015-03-24 21:04:38 +00:00
|
|
|
executeTemplate(w, "status", h, h.PathPrefix)
|
2013-02-12 12:15:40 +00:00
|
|
|
}
|