prometheus

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package prometheus contains code to access prometheus api.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alert

type Alert struct {
	v1.Alert
}

Alert is a prometheus alert with a server.

func (Alert) Header

func (a Alert) Header() []string

Header represents a alert header.

func (Alert) Job

func (a Alert) Job() string

Job returns the job label value.

func (Alert) Name

func (a Alert) Name() string

Name returns the alert name label value.

func (Alert) Row

func (a Alert) Row() []string

Row represents a alert row.

type AlertFilterFunc

type AlertFilterFunc func(Alert) bool

AlertFilterFunc is a function to filter alerts. If function returns true service is selected else omitted.

func AlertByJob

func AlertByJob(r *regexp.Regexp) AlertFilterFunc

AlertByJob filters Alerts by job.

func AlertByName

func AlertByName(r *regexp.Regexp) AlertFilterFunc

AlertByName filters Alerts by job.

func AlertByServer

func AlertByServer(r *regexp.Regexp) AlertFilterFunc

AlertByServer filters Alerts by prometheus server.

func AlertByState

func AlertByState(state v1.AlertState) AlertFilterFunc

AlertByState filters Alerts by health.

type Alerts

type Alerts []Alert

Alerts is a slice of prometheus alerts.

func (Alerts) Filter

func (a Alerts) Filter(filters ...AlertFilterFunc) Alerts

Filter filters Alerts with AlertFilterFunc.

type Client

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

Client is a prometheus API client·

func New

func New(urls ...string) (*Client, error)

New creates a new client.

func (Client) Alerts

func (c Client) Alerts(ctx context.Context) (Alerts, error)

Alerts returns all alerts.

func (Client) Targets

func (c Client) Targets(ctx context.Context, appendScraperAsTarget bool) (Targets, error)

Targets returns all active targets. If appendScraperAsTarget is true the scraper status is added to the active targets and all errors accessing scrapers are ignored.

type Target

type Target struct {
	v1.ActiveTarget
}

Target is prometheus Target.

func (Target) Header

func (t Target) Header() []string

Header represents a target header.

func (Target) Job

func (t Target) Job() string

Job returns the job label value.

func (Target) Row

func (t Target) Row() []string

Row represents a target row.

type TargetFilterFunc

type TargetFilterFunc func(Target) bool

TargetFilterFunc is a function to filter targets. If function returns true service is selected else omitted.

func TargetByHealth

func TargetByHealth(health v1.HealthStatus) TargetFilterFunc

TargetByHealth filters Targets by health.

func TargetByJob

func TargetByJob(r *regexp.Regexp) TargetFilterFunc

TargetByJob filters Targets by job.

func TargetByScrapeURL

func TargetByScrapeURL(r *regexp.Regexp) TargetFilterFunc

TargetByScrapeURL filters Targets by scrape url.

func TargetBySelector

func TargetBySelector(selector labels.Selector) TargetFilterFunc

TargetBySelector filters Services by Selector.

func TargetByServer

func TargetByServer(r *regexp.Regexp) TargetFilterFunc

TargetByServer filters Targets by prometheus server.

type Targets

type Targets []Target

Targets is a slice of prometheus targets.

func (Targets) Active

func (t Targets) Active() []*v1.ActiveTarget

Active returns the active targets.

func (Targets) Compact

func (t Targets) Compact()

Compact removes labels and last error information.

func (Targets) Deduplicate

func (t Targets) Deduplicate() Targets

Deduplicate deduplicates targets by scrape url. If identical targets have different health status, then HealthBad status has highest priority. Multiple sources are appended in the sourceLabelName label.

func (Targets) Filter

func (t Targets) Filter(filters ...TargetFilterFunc) Targets

Filter filters Targets with TargetFilterFunc.

func (Targets) Sort

func (t Targets) Sort()

Sort sorts targets by job and scrape url.

Jump to

Keyboard shortcuts

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