Documentation
¶
Overview ¶
Package prometheus contains business logic of working with Prometheus.
Index ¶
- Constants
- func TearDownTest(t testingT, p *Service, before []byte)
- type BasicAuth
- type Health
- type LabelPair
- type RelabelConfig
- type ScrapeConfig
- type ScrapeTargetHealth
- type ScrapeTargetReachability
- type Service
- func (svc *Service) Check(ctx context.Context) error
- func (svc *Service) CreateScrapeConfig(ctx context.Context, cfg *ScrapeConfig, checkReachability bool) error
- func (svc *Service) DeleteScrapeConfig(ctx context.Context, jobName string) error
- func (svc *Service) GetScrapeConfig(ctx context.Context, jobName string) (*ScrapeConfig, []ScrapeTargetHealth, error)
- func (svc *Service) ListScrapeConfigs(ctx context.Context) ([]ScrapeConfig, []ScrapeTargetHealth, error)
- func (svc *Service) SetScrapeConfigs(ctx context.Context, useConsul bool, configs ...*ScrapeConfig) error
- func (svc *Service) UpdateScrapeConfig(ctx context.Context, cfg *ScrapeConfig, checkReachability bool) error
- type StaticConfig
- type TLSConfig
Constants ¶
const (
// store scrape configs in Consul under that key
ConsulKey = "prometheus/scrape_configs"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type RelabelConfig ¶ added in v1.5.0
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 ScrapeTargetHealth ¶ added in v1.7.0
type ScrapeTargetHealth struct {
JobName string
Job string
Target string
Instance string
Health Health
}
ScrapeTargetHealth represents Prometheus scrape target health: unknown, down, or up.
type ScrapeTargetReachability ¶ added in v1.7.0
ScrapeTargetReachability represents a single reachability check result.
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 SetupTest ¶ added in v1.15.0
SetupTest returns a Prometheus service for testing. Returned parameters should be passed to TearDownTest after test.
func (*Service) Check ¶
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, checkReachability bool) 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, FailedPrecondition(9) if reachability check was requested and some scrape target can't be reached.
func (*Service) DeleteScrapeConfig ¶
DeleteScrapeConfig removes existing scrape config by job name. Errors: NotFound(5) if no such scrape config is present.
func (*Service) GetScrapeConfig ¶
func (svc *Service) GetScrapeConfig(ctx context.Context, jobName string) (*ScrapeConfig, []ScrapeTargetHealth, error)
GetScrapeConfig returns a scrape config by job name. Errors: NotFound(5) if no such scrape config is present.
func (*Service) ListScrapeConfigs ¶
func (svc *Service) ListScrapeConfigs(ctx context.Context) ([]ScrapeConfig, []ScrapeTargetHealth, error)
ListScrapeConfigs returns all scrape configs.
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.
func (*Service) UpdateScrapeConfig ¶ added in v1.7.0
func (svc *Service) UpdateScrapeConfig(ctx context.Context, cfg *ScrapeConfig, checkReachability bool) error
UpdateScrapeConfig updates existing scrape config by job name. Errors: InvalidArgument(3) if some argument is not valid, NotFound(5) if no such scrape config is present, FailedPrecondition(9) if reachability check was requested and some scrape target can't be reached.
Source Files
¶
- base.go
- config_updater.go
- scrape_configs.go
- testing.go