Documentation ¶
Index ¶
- Constants
- Variables
- func IsWALDirAccessible(dir string) error
- type Client
- func (c *Client) AlertmanagerAlerts(ctx context.Context, base *url.URL) ([]*model.Alert, error)
- func (c *Client) AlertsInGRPC(ctx context.Context, base *url.URL) ([]*rulespb.AlertInstance, error)
- func (c *Client) BuildVersion(ctx context.Context, base *url.URL) (string, error)
- func (c *Client) ConfiguredFlags(ctx context.Context, base *url.URL) (Flags, error)
- func (c *Client) ExemplarsInGRPC(ctx context.Context, base *url.URL, query string, startTime, endTime int64) ([]*exemplarspb.ExemplarData, error)
- func (c *Client) ExternalLabels(ctx context.Context, base *url.URL) (labels.Labels, error)
- func (c *Client) LabelNamesInGRPC(ctx context.Context, base *url.URL, matchers []*labels.Matcher, ...) ([]string, error)
- func (c *Client) LabelValuesInGRPC(ctx context.Context, base *url.URL, label string, matchers []*labels.Matcher, ...) ([]string, error)
- func (c *Client) MetricMetadataInGRPC(ctx context.Context, base *url.URL, metric string, limit int) (map[string][]metadatapb.Meta, error)
- func (c *Client) PromqlQueryInstant(ctx context.Context, base *url.URL, query string, t time.Time, ...) (promql.Vector, []string, error)
- func (c *Client) QueryInstant(ctx context.Context, base *url.URL, query string, t time.Time, ...) (model.Vector, []string, error)
- func (c *Client) QueryRange(ctx context.Context, base *url.URL, query string, ...) (model.Matrix, []string, error)
- func (c *Client) RulesInGRPC(ctx context.Context, base *url.URL, typeRules string) ([]*rulespb.RuleGroup, error)
- func (c *Client) SeriesInGRPC(ctx context.Context, base *url.URL, matchers []*labels.Matcher, ...) ([]map[string]string, error)
- func (c *Client) Snapshot(ctx context.Context, base *url.URL, skipHead bool) (string, error)
- func (c *Client) TargetsInGRPC(ctx context.Context, base *url.URL, stateTargets string) (*targetspb.TargetDiscovery, error)
- type Flags
- type HTTPClient
- type QueryOptions
Constants ¶
const (
SUCCESS = "success"
)
Variables ¶
var (
ErrFlagEndpointNotFound = errors.New("no flag endpoint found")
)
Functions ¶
func IsWALDirAccessible ¶ added in v0.10.0
IsWALDirAccessible returns no error if WAL dir can be found. This helps to tell if we have access to Prometheus TSDB directory.
Types ¶
type Client ¶ added in v0.11.0
type Client struct { HTTPClient // contains filtered or unexported fields }
Client represents a Prometheus API client.
func NewClient ¶ added in v0.11.0
func NewClient(c HTTPClient, logger log.Logger, userAgent string) *Client
NewClient returns a new Prometheus API client.
func NewDefaultClient ¶ added in v0.14.0
func NewDefaultClient() *Client
NewDefaultClient returns Client with tracing tripperware.
func NewWithTracingClient ¶ added in v0.14.0
NewWithTracingClient returns client with tracing tripperware.
func (*Client) AlertmanagerAlerts ¶ added in v0.14.0
AlertmanagerAlerts returns alerts from Alertmanager.
func (*Client) AlertsInGRPC ¶ added in v0.30.0
AlertsInGRPC returns the rules from Prometheus alerts API. It uses gRPC errors. NOTE: This method is tested in pkg/store/prometheus_test.go against Prometheus.
func (*Client) BuildVersion ¶ added in v0.21.0
BuildVersion returns Prometheus version from /api/v1/status/buildinfo Prometheus endpoint. For Prometheus versions < 2.14.0 it returns "0" as Prometheus version.
func (*Client) ConfiguredFlags ¶ added in v0.14.0
ConfiguredFlags returns configured flags from /api/v1/status/flags Prometheus endpoint. Added to Prometheus from v2.2.
func (*Client) ExemplarsInGRPC ¶ added in v0.20.0
func (c *Client) ExemplarsInGRPC(ctx context.Context, base *url.URL, query string, startTime, endTime int64) ([]*exemplarspb.ExemplarData, error)
ExemplarsInGRPC returns the exemplars from Prometheus exemplars API. It uses gRPC errors. NOTE: This method is tested in pkg/store/prometheus_test.go against Prometheus.
func (*Client) ExternalLabels ¶ added in v0.14.0
ExternalLabels returns sorted external labels from /api/v1/status/config Prometheus endpoint. Note that configuration can be hot reloadable on Prometheus, so this config might change in runtime.
func (*Client) LabelNamesInGRPC ¶ added in v0.14.0
func (c *Client) LabelNamesInGRPC(ctx context.Context, base *url.URL, matchers []*labels.Matcher, startTime, endTime int64) ([]string, error)
LabelNamesInGRPC returns all known label names constrained by the given matchers. It uses gRPC errors. NOTE: This method is tested in pkg/store/prometheus_test.go against Prometheus.
func (*Client) LabelValuesInGRPC ¶ added in v0.14.0
func (c *Client) LabelValuesInGRPC(ctx context.Context, base *url.URL, label string, matchers []*labels.Matcher, startTime, endTime int64) ([]string, error)
LabelValuesInGRPC returns all known label values for a given label name. It uses gRPC errors. NOTE: This method is tested in pkg/store/prometheus_test.go against Prometheus.
func (*Client) MetricMetadataInGRPC ¶ added in v0.19.0
func (c *Client) MetricMetadataInGRPC(ctx context.Context, base *url.URL, metric string, limit int) (map[string][]metadatapb.Meta, error)
MetricMetadataInGRPC returns the metadata from Prometheus metric metadata API. It uses gRPC errors.
func (*Client) PromqlQueryInstant ¶ added in v0.11.0
func (c *Client) PromqlQueryInstant(ctx context.Context, base *url.URL, query string, t time.Time, opts QueryOptions) (promql.Vector, []string, error)
PromqlQueryInstant performs instant query and returns results in promql.Vector type that is compatible with promql package.
func (*Client) QueryInstant ¶ added in v0.11.0
func (c *Client) QueryInstant(ctx context.Context, base *url.URL, query string, t time.Time, opts QueryOptions) (model.Vector, []string, error)
QueryInstant performs an instant query using a default HTTP client and returns results in model.Vector type.
func (*Client) QueryRange ¶ added in v0.15.0
func (c *Client) QueryRange(ctx context.Context, base *url.URL, query string, startTime, endTime, step int64, opts QueryOptions) (model.Matrix, []string, error)
QueryRange performs a range query using a default HTTP client and returns results in model.Matrix type.
func (*Client) RulesInGRPC ¶ added in v0.14.0
func (c *Client) RulesInGRPC(ctx context.Context, base *url.URL, typeRules string) ([]*rulespb.RuleGroup, error)
RulesInGRPC returns the rules from Prometheus rules API. It uses gRPC errors. NOTE: This method is tested in pkg/store/prometheus_test.go against Prometheus.
func (*Client) SeriesInGRPC ¶ added in v0.14.0
func (c *Client) SeriesInGRPC(ctx context.Context, base *url.URL, matchers []*labels.Matcher, startTime, endTime int64) ([]map[string]string, error)
SeriesInGRPC returns the labels from Prometheus series API. It uses gRPC errors. NOTE: This method is tested in pkg/store/prometheus_test.go against Prometheus.
func (*Client) Snapshot ¶ added in v0.14.0
Snapshot will request Prometheus to perform snapshot in directory returned by this function. Returned directory is relative to Prometheus data-dir. NOTE: `--web.enable-admin-api` flag has to be set on Prometheus. Added to Prometheus from v2.1. TODO(bwplotka): Add metrics.
type Flags ¶
type Flags struct { TSDBPath string `json:"storage.tsdb.path"` TSDBRetention model.Duration `json:"storage.tsdb.retention"` TSDBMinTime model.Duration `json:"storage.tsdb.min-block-duration"` TSDBMaxTime model.Duration `json:"storage.tsdb.max-block-duration"` WebEnableAdminAPI bool `json:"web.enable-admin-api"` WebEnableLifecycle bool `json:"web.enable-lifecycle"` }
func (*Flags) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.
type HTTPClient ¶ added in v0.11.0
HTTPClient sends an HTTP request and returns the response.
type QueryOptions ¶ added in v0.7.0
type QueryOptions struct { Deduplicate bool PartialResponseStrategy storepb.PartialResponseStrategy Method string MaxSourceResolution string }