prometheus

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2025 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const Type = "prometheus"

Variables

This section is empty.

Functions

func Register

func Register()

Register registers the Prometheus collector with the metrics registry.

Types

type Collector

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

func NewCollector

func NewCollector(logger *slog.Logger, name string) *Collector

func (*Collector) Configure

func (c *Collector) Configure(settings map[string]any) (err error)

func (*Collector) Name

func (c *Collector) Name() string

func (*Collector) Results

func (c *Collector) Results() []metrics.Results

func (*Collector) Run

func (c *Collector) Run(ctx context.Context) error

func (*Collector) Type

func (c *Collector) Type() string

type Config

type Config struct {
	// URL points to the metrics endpoint of the service to be monitored.
	URL string `yaml:"url"`
	// ScrapeInterval is the time between scrapes (defaults to 1s).
	ScrapeInterval time.Duration `yaml:"scrape-interval"`
	// Queries are the query configurations used when querying the collected
	// metrics.
	Queries []QueryConfig `yaml:"queries"`
}

type QueryConfig

type QueryConfig struct {
	Name string `yaml:"name"`
	// QueryString is the PromQL query string to be executed.
	QueryString string `yaml:"query"`
	// Interval is the query resolution.
	Interval time.Duration `yaml:"interval"`
	// Unit is the unit of the metric, only for display purposes (optional).
	Unit string `yaml:"unit"`
}

type QueryLogger

type QueryLogger struct {
	slog.Handler
}

func (QueryLogger) Close

func (QueryLogger) Close() error

func (QueryLogger) Handle

func (l QueryLogger) Handle(ctx context.Context, record slog.Record) error

type SequentialQueryTracker

type SequentialQueryTracker chan struct{}

SequentialQueryTracker is a query tracker that allows only one query to be active at a time.

func NewSequentialQueryTracker

func NewSequentialQueryTracker() SequentialQueryTracker

func (SequentialQueryTracker) Close

func (s SequentialQueryTracker) Close() error

func (SequentialQueryTracker) Delete

func (s SequentialQueryTracker) Delete(int)

func (SequentialQueryTracker) GetMaxConcurrent

func (s SequentialQueryTracker) GetMaxConcurrent() int

func (SequentialQueryTracker) Insert

func (s SequentialQueryTracker) Insert(ctx context.Context, _ string) (int, error)

Jump to

Keyboard shortcuts

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