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) ConfiguredFlags(ctx context.Context, base *url.URL) (Flags, error)
- func (c *Client) ExternalLabels(ctx context.Context, base *url.URL) (labels.Labels, error)
- func (c *Client) LabelNamesInGRPC(ctx context.Context, base *url.URL, startTime, endTime int64) ([]string, error)
- func (c *Client) LabelValuesInGRPC(ctx context.Context, base *url.URL, label string, startTime, endTime int64) ([]string, 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 []storepb.LabelMatcher, ...) ([]map[string]string, error)
- func (c *Client) Snapshot(ctx context.Context, base *url.URL, skipHead bool) (string, 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) 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) ExternalLabels ¶ added in v0.14.0
ExternalLabels returns 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, startTime, endTime int64) ([]string, error)
LabelNames returns all known label names. 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, 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) 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 []storepb.LabelMatcher, 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 }