prometheus

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LabelFilterMapper kong.MapperFunc = func(ctx *kong.DecodeContext, target reflect.Value) error {
	var filterStr string
	if err := ctx.Scan.PopValueInto("string", &filterStr); err != nil {
		return err
	}

	kv := strings.SplitN(filterStr, "=", 2)
	if len(kv) != 2 {
		return fmt.Errorf("unable to parse %q as a key-value expression", filterStr)
	}

	target.Set(reflect.ValueOf(metricsql.LabelFilter{Label: kv[0], Value: kv[1]}))
	return nil
}

Functions

func CachedQueryFunc

func CachedQueryFunc(cache map[int64]promql.Vector) rules.QueryFunc

func RewriteExpr

func RewriteExpr(expr string, filters ...metricsql.LabelFilter) (string, error)

Types

type APIClient

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

func NewAPIClient

func NewAPIClient(prometheusURL string, parallelism int) (*APIClient, error)

func (*APIClient) LabelValues

func (a *APIClient) LabelValues(ctx context.Context, label string, ts time.Time) ([]metricsql.LabelFilter, error)

func (*APIClient) QueryExpr

func (a *APIClient) QueryExpr(
	ctx context.Context,
	expr string,
	from time.Time,
	to time.Time,
	interval time.Duration,
) (map[int64]promql.Vector, []time.Time, error)

type Client

type Client interface {
	LabelValues(context.Context, string, time.Time) ([]metricsql.LabelFilter, error)
	QueryExpr(context.Context, string, time.Time, time.Time, time.Duration) (map[int64]promql.Vector, []time.Time, error)
}

Jump to

Keyboard shortcuts

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