api

package
v0.0.0-...-42b049c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 12, 2021 License: Apache-2.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultMergeBatchSize = int64(1024 * 1024 * 64) // 64Mb
)
View Source
var (
	LocalhostRepresentations = []string{"127.0.0.1", "localhost"}
)
View Source
var NoTargets = func(_ context.Context) TargetRetriever { return NoTargetRetriever{} }

NoTargets is passed to the API when only the API is served and no scraping is happening.

Functions

func Instr

func Instr(
	logger log.Logger,
	ins extpromhttp.InstrumentationMiddleware,
) func(name string, f ApiFunc) httprouter.Handle

TODO: add tracer Instr returns a http HandlerFunc with the instrumentation middleware.

Types

type API

type API struct {
	// contains filtered or unexported fields
}

func New

func New(
	logger log.Logger,
	registry *prometheus.Registry,

	opts ...Option,
) *API

func (*API) ApplyConfig

func (a *API) ApplyConfig(c *config.Config) error

func (*API) Config

func (a *API) Config(_ *http.Request) (interface{}, []error, *ApiError)

func (*API) DiffProfiles

func (a *API) DiffProfiles(r *http.Request) (*profile.Profile, storage.Warnings, *ApiError)

func (*API) LabelNames

func (a *API) LabelNames(r *http.Request) (interface{}, []error, *ApiError)

func (*API) LabelValues

func (a *API) LabelValues(r *http.Request) (interface{}, []error, *ApiError)

func (*API) MergeProfiles

func (a *API) MergeProfiles(r *http.Request) (*profile.Profile, storage.Warnings, *ApiError)

func (*API) Query

func (a *API) Query(r *http.Request) (interface{}, []error, *ApiError)

func (*API) QueryRange

func (a *API) QueryRange(r *http.Request) (interface{}, []error, *ApiError)

func (*API) Reload

func (a *API) Reload(w http.ResponseWriter, r *http.Request, _ httprouter.Params)

func (*API) Routes

func (a *API) Routes() http.Handler

Routes returns a http.Handler containing all routes of the API so that it can be mounted into a mux.

func (*API) Series

func (a *API) Series(r *http.Request) (interface{}, []error, *ApiError)

func (*API) SingleProfileQuery

func (a *API) SingleProfileQuery(r *http.Request) (*profile.Profile, storage.Warnings, *ApiError)

func (*API) Targets

func (a *API) Targets(r *http.Request) (interface{}, []error, *ApiError)

type ApiError

type ApiError struct {
	Typ ErrorType
	Err error
}

func (*ApiError) Error

func (e *ApiError) Error() string

type ApiFunc

type ApiFunc func(r *http.Request) (interface{}, []error, *ApiError)

type DroppedTarget

type DroppedTarget struct {
	// Labels before any processing.
	DiscoveredLabels map[string]string `json:"discoveredLabels"`
}

DroppedTarget has the information for one target that was dropped during relabelling.

type EmptyResponse

type EmptyResponse struct{}

func (*EmptyResponse) Render

func (r *EmptyResponse) Render(w http.ResponseWriter) error

type ErrorResponse

type ErrorResponse struct {
	Data   interface{}
	ApiErr *ApiError
}

func (*ErrorResponse) Render

func (r *ErrorResponse) Render(w http.ResponseWriter) error

type ErrorType

type ErrorType string
const (
	ErrorNone     ErrorType = ""
	ErrorTimeout  ErrorType = "timeout"
	ErrorCanceled ErrorType = "canceled"
	ErrorExec     ErrorType = "execution"
	ErrorBadData  ErrorType = "bad_data"
	ErrorInternal ErrorType = "internal"
	ErrorNotFound ErrorType = "not_found"
)

type GlobalURLOptions

type GlobalURLOptions struct {
	ListenAddress string
	Host          string
	Scheme        string
}

GlobalURLOptions contains fields used for deriving the global URL for local targets.

type HttpResponseRenderer

type HttpResponseRenderer interface {
	Render(w http.ResponseWriter) error
}

type MergeTimeoutError

type MergeTimeoutError struct {
	// contains filtered or unexported fields
}

func NewMergeTimeoutError

func NewMergeTimeoutError(count int) *MergeTimeoutError

func (*MergeTimeoutError) Error

func (e *MergeTimeoutError) Error() string

type MetaReport

type MetaReport struct {
	SampleTypes       []ValueType `json:"sampleTypes"`
	DefaultSampleType string      `json:"defaultSampleType"`
}

func GenerateMetaReport

func GenerateMetaReport(profile *profile.Profile) (*MetaReport, error)

type NoTargetRetriever

type NoTargetRetriever struct{}

NoTargetRetriever is passed to the API when only the API is served and no scraping is happening.

func (NoTargetRetriever) TargetsActive

func (t NoTargetRetriever) TargetsActive() map[string][]*scrape.Target

func (NoTargetRetriever) TargetsDropped

func (t NoTargetRetriever) TargetsDropped() map[string][]*scrape.Target

type Option

type Option func(*API)

func WithDB

func WithDB(db storage.Queryable) Option

func WithMaxMergeBatchSize

func WithMaxMergeBatchSize(max int64) Option

func WithPrefix

func WithPrefix(prefix string) Option

func WithQueryTimeout

func WithQueryTimeout(t time.Duration) Option

func WithReloadChannel

func WithReloadChannel(reloadCh chan struct{}) Option

func WithSymbolizer

func WithSymbolizer(s Symbolizer) Option

func WithTargets

func WithTargets(targets func(ctx context.Context) TargetRetriever) Option

type ProfileResponseRenderer

type ProfileResponseRenderer struct {
	// contains filtered or unexported fields
}

func NewProfileResponseRenderer

func NewProfileResponseRenderer(
	logger log.Logger,
	profile *profile.Profile,
	warnings []error,
	req *http.Request,
) *ProfileResponseRenderer

func (*ProfileResponseRenderer) Render

type ProtoRenderer

type ProtoRenderer struct {
	// contains filtered or unexported fields
}

func NewProtoRenderer

func NewProtoRenderer(profile *profile.Profile) *ProtoRenderer

func (*ProtoRenderer) Render

func (r *ProtoRenderer) Render(w http.ResponseWriter) error

type Response

type Response struct {
	Status    Status      `json:"status"`
	Data      interface{} `json:"data,omitempty"`
	ErrorType ErrorType   `json:"errorType,omitempty"`
	Error     string      `json:"error,omitempty"`
	Warnings  []string    `json:"warnings,omitempty"`
}

type SVGRenderer

type SVGRenderer struct {
	// contains filtered or unexported fields
}

func NewSVGRenderer

func NewSVGRenderer(logger log.Logger, profile *profile.Profile, sampleIndex string) *SVGRenderer

func (*SVGRenderer) Render

func (r *SVGRenderer) Render(w http.ResponseWriter) error

type Series

type Series struct {
	Labels     map[string]string `json:"labels"`
	Timestamps []int64           `json:"timestamps"`
}

type Status

type Status string
const (
	StatusSuccess Status = "success"
	StatusError   Status = "error"
)

type SuccessResponse

type SuccessResponse struct {
	Data     interface{}
	Warnings []error
}

func NewSuccessResponse

func NewSuccessResponse(data interface{}, warnings []error) *SuccessResponse

func (*SuccessResponse) Render

type Symbolizer

type Symbolizer interface {
	Symbolize(context.Context, *profile.Profile) error
}

type Target

type Target struct {
	// Labels before any processing.
	DiscoveredLabels map[string]string `json:"discoveredLabels"`
	// Any labels that are added to this target and its metrics.
	Labels map[string]string `json:"labels"`

	ScrapePool string `json:"scrapePool"`
	ScrapeURL  string `json:"scrapeUrl"`
	GlobalURL  string `json:"globalUrl"`

	LastError          string              `json:"lastError"`
	LastScrape         time.Time           `json:"lastScrape"`
	LastScrapeDuration float64             `json:"lastScrapeDuration"`
	Health             scrape.TargetHealth `json:"health"`
}

Target has the information for one target.

type TargetDiscovery

type TargetDiscovery struct {
	ActiveTargets  []*Target        `json:"activeTargets"`
	DroppedTargets []*DroppedTarget `json:"droppedTargets"`
}

TargetDiscovery has all the active targets.

type TargetRetriever

type TargetRetriever interface {
	TargetsActive() map[string][]*scrape.Target
	TargetsDropped() map[string][]*scrape.Target
}

type TreeNode

type TreeNode struct {
	Name      string      `json:"n"`
	FullName  string      `json:"f"`
	Cum       int64       `json:"v"`
	CumFormat string      `json:"l"`
	Percent   string      `json:"p"`
	Children  []*TreeNode `json:"c"`
}

type ValueType

type ValueType struct {
	Type string `json:"type,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL