2013-02-22 20:07:35 +00:00
|
|
|
// 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.
|
|
|
|
|
2013-01-11 01:27:03 +00:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
2013-10-22 18:31:52 +00:00
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/prometheus/client_golang/prometheus/exp"
|
|
|
|
|
2013-05-05 17:32:04 +00:00
|
|
|
"github.com/prometheus/prometheus/config"
|
|
|
|
"github.com/prometheus/prometheus/retrieval"
|
|
|
|
"github.com/prometheus/prometheus/storage/metric"
|
2013-01-27 18:59:20 +00:00
|
|
|
"github.com/prometheus/prometheus/utility"
|
2013-10-22 18:31:52 +00:00
|
|
|
"github.com/prometheus/prometheus/web/http_utils"
|
2013-01-11 01:27:03 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type MetricsService struct {
|
2013-10-22 18:31:52 +00:00
|
|
|
time utility.Time
|
2013-05-05 17:32:04 +00:00
|
|
|
Config *config.Config
|
|
|
|
TargetManager retrieval.TargetManager
|
2014-04-11 07:27:05 +00:00
|
|
|
Storage metric.PreloadingPersistence
|
2013-01-11 01:27:03 +00:00
|
|
|
}
|
2013-10-22 18:31:52 +00:00
|
|
|
|
|
|
|
func (msrv *MetricsService) RegisterHandler() {
|
|
|
|
handler := func(h func(http.ResponseWriter, *http.Request)) http.Handler {
|
|
|
|
return http_utils.CompressionHandler{
|
|
|
|
Handler: http.HandlerFunc(h),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
exp.Handle("/api/query", handler(msrv.Query))
|
|
|
|
exp.Handle("/api/query_range", handler(msrv.QueryRange))
|
|
|
|
exp.Handle("/api/metrics", handler(msrv.Metrics))
|
|
|
|
exp.Handle("/api/targets", handler(msrv.SetTargets))
|
|
|
|
}
|