|
|
@ -19,7 +19,6 @@ import (
|
|
|
|
"math"
|
|
|
|
"math"
|
|
|
|
"math/rand"
|
|
|
|
"math/rand"
|
|
|
|
"net/http"
|
|
|
|
"net/http"
|
|
|
|
"net/url"
|
|
|
|
|
|
|
|
"os"
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
"path/filepath"
|
|
|
|
"time"
|
|
|
|
"time"
|
|
|
@ -39,37 +38,21 @@ import (
|
|
|
|
"github.com/prometheus/prometheus/pkg/labels"
|
|
|
|
"github.com/prometheus/prometheus/pkg/labels"
|
|
|
|
"github.com/prometheus/prometheus/pkg/timestamp"
|
|
|
|
"github.com/prometheus/prometheus/pkg/timestamp"
|
|
|
|
pb "github.com/prometheus/prometheus/prompb"
|
|
|
|
pb "github.com/prometheus/prometheus/prompb"
|
|
|
|
"github.com/prometheus/prometheus/promql"
|
|
|
|
|
|
|
|
"github.com/prometheus/prometheus/scrape"
|
|
|
|
|
|
|
|
"github.com/prometheus/prometheus/storage"
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// API encapsulates all API services.
|
|
|
|
// API encapsulates all API services.
|
|
|
|
type API struct {
|
|
|
|
type API struct {
|
|
|
|
enableAdmin bool
|
|
|
|
enableAdmin bool
|
|
|
|
now func() time.Time
|
|
|
|
|
|
|
|
db func() *tsdb.DB
|
|
|
|
db func() *tsdb.DB
|
|
|
|
q func(ctx context.Context, mint, maxt int64) (storage.Querier, error)
|
|
|
|
|
|
|
|
targets func() []*scrape.Target
|
|
|
|
|
|
|
|
alertmanagers func() []*url.URL
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// New returns a new API object.
|
|
|
|
// New returns a new API object.
|
|
|
|
func New(
|
|
|
|
func New(
|
|
|
|
now func() time.Time,
|
|
|
|
|
|
|
|
db func() *tsdb.DB,
|
|
|
|
db func() *tsdb.DB,
|
|
|
|
qe *promql.Engine,
|
|
|
|
|
|
|
|
q func(ctx context.Context, mint, maxt int64) (storage.Querier, error),
|
|
|
|
|
|
|
|
targets func() []*scrape.Target,
|
|
|
|
|
|
|
|
alertmanagers func() []*url.URL,
|
|
|
|
|
|
|
|
enableAdmin bool,
|
|
|
|
enableAdmin bool,
|
|
|
|
) *API {
|
|
|
|
) *API {
|
|
|
|
return &API{
|
|
|
|
return &API{
|
|
|
|
now: now,
|
|
|
|
|
|
|
|
db: db,
|
|
|
|
db: db,
|
|
|
|
q: q,
|
|
|
|
|
|
|
|
targets: targets,
|
|
|
|
|
|
|
|
alertmanagers: alertmanagers,
|
|
|
|
|
|
|
|
enableAdmin: enableAdmin,
|
|
|
|
enableAdmin: enableAdmin,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|