prometheus

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2017 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Overview

Package prometheus contains business logic of working with Prometheus.

Index

Constants

View Source
const (
	// store scrape configs in Consul under that key
	ConsulKey = "prometheus/scrape_configs"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AlertRule

type AlertRule struct {
	Name     string
	FilePath string
	Text     string
	Disabled bool
}

type BasicAuth

type BasicAuth struct {
	Username string
	Password string
}

type LabelPair

type LabelPair struct {
	Name  string
	Value string
}

type RelabelConfig added in v1.5.0

type RelabelConfig struct {
	TargetLabel string
	Replacement string
}

type ScrapeConfig

type ScrapeConfig struct {
	JobName        string
	ScrapeInterval string
	ScrapeTimeout  string
	MetricsPath    string
	HonorLabels    bool
	Scheme         string
	BasicAuth      *BasicAuth
	TLSConfig      TLSConfig
	StaticConfigs  []StaticConfig
	RelabelConfigs []RelabelConfig
}

type Service

type Service struct {
	ConfigPath string
	// contains filtered or unexported fields
}

Service is responsible for interactions with Prometheus. It assumes the following:

  • Prometheus API is accessible;
  • Prometheus configuration and rule files are accessible;
  • promtool is available.

func NewService

func NewService(config string, baseURL string, promtool string, consul *consul.Client) (*Service, error)

func (*Service) AddStaticTargets

func (svc *Service) AddStaticTargets(ctx context.Context, jobName string, targets []string) error

AddStaticTargets adds static targets to existing scrape config. Errors: NotFound(5) if no such scrape config is present.

func (*Service) Check

func (svc *Service) Check(ctx context.Context) error

Check updates Prometehus configuration using information from Consul KV. (During PMM update prometheus.yml is overwritten, but Consul data directory is kept.) It returns error if configuration is not right or Prometheus is not available.

func (*Service) CreateScrapeConfig

func (svc *Service) CreateScrapeConfig(ctx context.Context, cfg *ScrapeConfig) error

CreateScrapeConfig creates a new scrape config. Errors: InvalidArgument(3) if some argument is not valid, AlreadyExists(6) if scrape config with that job name is already present.

func (*Service) DeleteAlert

func (svc *Service) DeleteAlert(ctx context.Context, name string) error

DeleteAlert removes existing alert rule by name, or error if no such rule is present.

func (*Service) DeleteScrapeConfig

func (svc *Service) DeleteScrapeConfig(ctx context.Context, jobName string) error

DeleteScrapeConfig removes existing scrape config by job name. Errors: NotFound(5) if no such scrape config is present.

func (*Service) GetAlert

func (svc *Service) GetAlert(ctx context.Context, name string) (*AlertRule, error)

GetAlert return alert rule by name, or error if no such rule is present.

func (*Service) GetScrapeConfig

func (svc *Service) GetScrapeConfig(ctx context.Context, jobName string) (*ScrapeConfig, error)

GetScrapeConfig returns a scrape config by job name. Errors: NotFound(5) if no such scrape config is present.

func (*Service) ListAlertRules

func (svc *Service) ListAlertRules(ctx context.Context) ([]AlertRule, error)

ListAlertRules returns all alert rules.

func (*Service) ListScrapeConfigs

func (svc *Service) ListScrapeConfigs(ctx context.Context) ([]ScrapeConfig, error)

ListScrapeConfigs returns all scrape configs.

func (*Service) PutAlert

func (svc *Service) PutAlert(ctx context.Context, rule *AlertRule) error

PutAlert creates or replaces existing alert rule.

func (*Service) RemoveStaticTargets

func (svc *Service) RemoveStaticTargets(ctx context.Context, jobName string, targets []string) error

RemoveStaticTargets removes static targets from existing scrape config. Errors: NotFound(5) if no such scrape config is present.

func (*Service) SetScrapeConfigs added in v1.5.0

func (svc *Service) SetScrapeConfigs(ctx context.Context, useConsul bool, configs ...*ScrapeConfig) error

SetScrapeConfigs creates new or completely replaces existing scrape configs with a given names. Errors: InvalidArgument(3) if some argument is not valid.

type StaticConfig

type StaticConfig struct {
	Targets []string
	Labels  []LabelPair
}

type TLSConfig

type TLSConfig struct {
	InsecureSkipVerify bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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