mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-25 05:34:05 -08:00
Use only local tsdb for federation (#7096)
Signed-off-by: yeya24 <yb532204897@gmail.com>
This commit is contained in:
parent
34c7f6e3c4
commit
ecda6013ed
|
@ -75,7 +75,7 @@ func (h *Handler) federation(w http.ResponseWriter, req *http.Request) {
|
|||
)
|
||||
w.Header().Set("Content-Type", string(format))
|
||||
|
||||
q, err := h.storage.Querier(req.Context(), mint, maxt)
|
||||
q, err := h.localStorage.Querier(req.Context(), mint, maxt)
|
||||
if err != nil {
|
||||
federationErrors.Inc()
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
|
@ -209,10 +209,10 @@ func (h *Handler) federation(w http.ResponseWriter, req *http.Request) {
|
|||
// Attach global labels if they do not exist yet.
|
||||
for _, ln := range externalLabelNames {
|
||||
lv := externalLabels[ln]
|
||||
if _, ok := globalUsed[string(ln)]; !ok {
|
||||
if _, ok := globalUsed[ln]; !ok {
|
||||
protMetric.Label = append(protMetric.Label, &dto.LabelPair{
|
||||
Name: proto.String(string(ln)),
|
||||
Value: proto.String(string(lv)),
|
||||
Name: proto.String(ln),
|
||||
Value: proto.String(lv),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -199,8 +199,7 @@ func TestFederation(t *testing.T) {
|
|||
}
|
||||
|
||||
h := &Handler{
|
||||
storage: suite.Storage(),
|
||||
queryEngine: suite.QueryEngine(),
|
||||
localStorage: suite.Storage(),
|
||||
lookbackDelta: 5 * time.Minute,
|
||||
now: func() model.Time { return 101 * 60 * 1000 }, // 101min after epoch.
|
||||
config: &config.Config{
|
||||
|
|
|
@ -180,6 +180,7 @@ type Handler struct {
|
|||
context context.Context
|
||||
tsdb func() *tsdb.DB
|
||||
storage storage.Storage
|
||||
localStorage storage.Storage
|
||||
notifier *notifier.Manager
|
||||
|
||||
apiV1 *api_v1.API
|
||||
|
@ -284,6 +285,7 @@ func New(logger log.Logger, o *Options) *Handler {
|
|||
lookbackDelta: o.LookbackDelta,
|
||||
tsdb: o.TSDB,
|
||||
storage: o.Storage,
|
||||
localStorage: o.TSDB(),
|
||||
notifier: o.Notifier,
|
||||
|
||||
now: model.Now,
|
||||
|
|
|
@ -399,6 +399,7 @@ func TestDebugHandler(t *testing.T) {
|
|||
Host: "localhost.localdomain:9090",
|
||||
Scheme: "http",
|
||||
},
|
||||
TSDB: func() *tsdb.DB { return nil },
|
||||
}
|
||||
handler := New(nil, opts)
|
||||
handler.Ready()
|
||||
|
@ -425,6 +426,7 @@ func TestHTTPMetrics(t *testing.T) {
|
|||
Host: "localhost.localdomain:9090",
|
||||
Scheme: "http",
|
||||
},
|
||||
TSDB: func() *tsdb.DB { return nil },
|
||||
})
|
||||
getReady := func() int {
|
||||
t.Helper()
|
||||
|
|
Loading…
Reference in a new issue