Documentation ¶
Overview ¶
Package prometheus contains business logic of working with Prometheus.
Index ¶
- type AlertRule
- type BasicAuth
- type LabelPair
- type ScrapeConfig
- type Service
- func (svc *Service) AddStaticTargets(ctx context.Context, jobName string, targets []string) error
- func (svc *Service) Check(ctx context.Context) error
- func (svc *Service) CreateScrapeConfig(ctx context.Context, cfg *ScrapeConfig) error
- func (svc *Service) DeleteAlert(ctx context.Context, name string) error
- func (svc *Service) DeleteScrapeConfig(ctx context.Context, jobName string) error
- func (svc *Service) GetAlert(ctx context.Context, name string) (*AlertRule, error)
- func (svc *Service) GetScrapeConfig(ctx context.Context, jobName string) (*ScrapeConfig, error)
- func (svc *Service) ListAlertRules(ctx context.Context) ([]AlertRule, error)
- func (svc *Service) ListScrapeConfigs(ctx context.Context) ([]ScrapeConfig, error)
- func (svc *Service) PutAlert(ctx context.Context, rule *AlertRule) error
- func (svc *Service) RemoveStaticTargets(ctx context.Context, jobName string, targets []string) error
- type StaticConfig
- type TLSConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ScrapeConfig ¶
type Service ¶
type Service struct {
// 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 (*Service) AddStaticTargets ¶
AddStaticTargets adds static targets to existing scrape config. Errors: NotFound(5) if no such scrape config is present.
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) 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 ¶
DeleteAlert removes existing alert rule by name, or error if no such rule is present.
func (*Service) DeleteScrapeConfig ¶
DeleteScrapeConfig removes existing scrape config by job name. Errors: NotFound(5) if no such scrape config is present.
func (*Service) GetScrapeConfig ¶
GetScrapeConfig returns a scrape config by job name. Errors: NotFound(5) if no such scrape config is present.
func (*Service) ListAlertRules ¶
ListAlertRules returns all alert rules.
func (*Service) ListScrapeConfigs ¶
func (svc *Service) ListScrapeConfigs(ctx context.Context) ([]ScrapeConfig, error)
ListScrapeConfigs returns all scrape configs.