Documentation ¶
Index ¶
- Constants
- type AlertingConfig
- type AlertingNameConfig
- type AlertingRulesConfig
- type AlertingRulesManager
- type AlertmanagerConfig
- type BasicAuth
- type Config
- type GlobalConfig
- type Group
- type HTTPClientConfig
- type Manager
- type NamespaceDiscovery
- type QueueConfig
- type Regexp
- type RelabelAction
- type RelabelConfig
- type RemoteReadConfig
- type RemoteWriteConfig
- type Role
- type RulesConfig
- type SDConfig
- type ScrapeConfig
- type Secret
- type SelectorConfig
- type ServiceDiscoveryConfig
- type TLSConfig
- type URL
Constants ¶
const ( // STARTING starting STARTING = iota // STARTED started STARTED //STOPPED stoped STOPPED )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AlertingConfig ¶
type AlertingConfig struct { AlertRelabelConfigs []*RelabelConfig `yaml:"alert_relabel_configs,omitempty"` AlertmanagerConfigs []*AlertmanagerConfig `yaml:"alertmanagers,omitempty"` }
AlertingConfig configures alerting and alertmanager related configs.
type AlertingNameConfig ¶
type AlertingNameConfig struct { Name string `yaml:"name" json:"name"` Rules []*RulesConfig `yaml:"rules" json:"rules"` }
AlertingNameConfig alerting config
type AlertingRulesConfig ¶
type AlertingRulesConfig struct {
Groups []*AlertingNameConfig `yaml:"groups" json:"groups"`
}
AlertingRulesConfig alerting rule config
type AlertingRulesManager ¶
type AlertingRulesManager struct { RulesConfig *AlertingRulesConfig // contains filtered or unexported fields }
AlertingRulesManager alerting rule manage
func NewRulesManager ¶
func NewRulesManager(config *option.Config) *AlertingRulesManager
NewRulesManager new rule manager
func (*AlertingRulesManager) AddRules ¶
func (a *AlertingRulesManager) AddRules(val AlertingNameConfig) error
AddRules add rule
func (*AlertingRulesManager) InitRulesConfig ¶
func (a *AlertingRulesManager) InitRulesConfig()
InitRulesConfig init rule config
func (*AlertingRulesManager) LoadAlertingRulesConfig ¶
func (a *AlertingRulesManager) LoadAlertingRulesConfig() error
LoadAlertingRulesConfig load alerting rule config
func (*AlertingRulesManager) SaveAlertingRulesConfig ¶
func (a *AlertingRulesManager) SaveAlertingRulesConfig() error
SaveAlertingRulesConfig save alerting rule config
type AlertmanagerConfig ¶
type AlertmanagerConfig struct { ServiceDiscoveryConfig ServiceDiscoveryConfig `yaml:",inline"` HTTPClientConfig HTTPClientConfig `yaml:",inline"` // The URL scheme to use when talking to Alertmanagers. Scheme string `yaml:"scheme,omitempty"` // Path prefix to add in front of the push endpoint path. PathPrefix string `yaml:"path_prefix,omitempty"` // The timeout used when sending alerts. Timeout time.Duration `yaml:"timeout,omitempty"` // List of Alertmanager relabel configurations. RelabelConfigs []*RelabelConfig `yaml:"relabel_configs,omitempty"` }
AlertmanagerConfig configures how Alertmanagers can be discovered and communicated with.
type BasicAuth ¶
type BasicAuth struct { Username string `yaml:"username"` Password Secret `yaml:"password,omitempty"` PasswordFile string `yaml:"password_file,omitempty"` // Catches all undefined fields and must be empty after parsing. XXX map[string]interface{} `yaml:",inline"` }
BasicAuth contains basic HTTP authentication credentials.
type Config ¶
type Config struct { GlobalConfig GlobalConfig `yaml:"global"` AlertingConfig AlertingConfig `yaml:"alerting,omitempty"` RuleFiles []string `yaml:"rule_files,omitempty"` ScrapeConfigs []*ScrapeConfig `yaml:"scrape_configs,omitempty"` RemoteWriteConfigs []*RemoteWriteConfig `yaml:"remote_write,omitempty"` RemoteReadConfigs []*RemoteReadConfig `yaml:"remote_read,omitempty"` // contains filtered or unexported fields }
Config is the top-level configuration for Prometheus's config files.
type GlobalConfig ¶
type GlobalConfig struct { // How frequently to scrape targets by default. ScrapeInterval model.Duration `yaml:"scrape_interval,omitempty"` // The default timeout when scraping targets. ScrapeTimeout model.Duration `yaml:"scrape_timeout,omitempty"` // How frequently to evaluate rules by default. EvaluationInterval model.Duration `yaml:"evaluation_interval,omitempty"` // The labels to add to any timeseries that this Prometheus instance scrapes. ExternalLabels model.LabelSet `yaml:"external_labels,omitempty"` }
GlobalConfig configures values that are used across other configuration objects.
type Group ¶
type Group struct { // Targets is a list of targets identified by a label set. Each target is // uniquely identifiable in the group by its address label. Targets []string `yaml:"targets,flow"` // Labels is a set of labels that is common across all targets in the group. Labels model.LabelSet `yaml:"labels,omitempty"` // Source is an identifier that describes a group of targets. Source string `yaml:"source,omitempty"` }
Group group
type HTTPClientConfig ¶
type HTTPClientConfig struct { // The HTTP basic authentication credentials for the targets. BasicAuth *BasicAuth `yaml:"basic_auth,omitempty"` // The bearer token for the targets. BearerToken Secret `yaml:"bearer_token,omitempty"` // The bearer token file for the targets. BearerTokenFile string `yaml:"bearer_token_file,omitempty"` // HTTP proxy server to use to connect to the targets. ProxyURL URL `yaml:"proxy_url,omitempty"` // TLSConfig to use to connect to the targets. TLSConfig TLSConfig `yaml:"tls_config,omitempty"` // Catches all undefined fields and must be empty after parsing. XXX map[string]interface{} `yaml:",inline"` }
HTTPClientConfig configures an HTTP client.
type Manager ¶
type Manager struct { Opt *option.Config Config *Config Process *os.Process Status int Registry *discover.KeepAlive // contains filtered or unexported fields }
Manager manage struct
func NewManager ¶
func NewManager(config *option.Config, a *AlertingRulesManager) *Manager
NewManager new manager
func (*Manager) RestartDaemon ¶
RestartDaemon restart daemon
func (*Manager) StartDaemon ¶
StartDaemon start prometheus daemon
func (*Manager) UpdateScrape ¶
func (p *Manager) UpdateScrape(scrape *ScrapeConfig)
UpdateScrape update scrape
type NamespaceDiscovery ¶
type NamespaceDiscovery struct {
Names []string `yaml:"names"`
}
NamespaceDiscovery is the configuration for discovering Kubernetes namespaces.
type QueueConfig ¶
type QueueConfig struct { // Number of samples to buffer per shard before we start dropping them. Capacity int `yaml:"capacity,omitempty"` // Max number of shards, i.e. amount of concurrency. MaxShards int `yaml:"max_shards,omitempty"` // Maximum number of samples per send. MaxSamplesPerSend int `yaml:"max_samples_per_send,omitempty"` // Maximum time sample will wait in buffer. BatchSendDeadline time.Duration `yaml:"batch_send_deadline,omitempty"` // Max number of times to retry a batch on recoverable errors. MaxRetries int `yaml:"max_retries,omitempty"` // On recoverable errors, backoff exponentially. MinBackoff time.Duration `yaml:"min_backoff,omitempty"` MaxBackoff time.Duration `yaml:"max_backoff,omitempty"` }
QueueConfig is the configuration for the queue used to write to remote storage.
type Regexp ¶
Regexp encapsulates a regexp.Regexp and makes it YAML marshallable.
func MustNewRegexp ¶
MustNewRegexp works like NewRegexp, but panics if the regular expression does not compile.
func NewRegexp ¶
NewRegexp creates a new anchored Regexp and returns an error if the passed-in regular expression does not compile.
func (Regexp) MarshalYAML ¶
MarshalYAML implements the yaml.Marshaler interface.
func (*Regexp) UnmarshalYAML ¶
UnmarshalYAML implements the yaml.Unmarshaler interface.
type RelabelAction ¶
type RelabelAction string
RelabelAction is the action to be performed on relabeling.
type RelabelConfig ¶
type RelabelConfig struct { // A list of labels from which values are taken and concatenated // with the configured separator in order. SourceLabels model.LabelNames `yaml:"source_labels,flow,omitempty"` // Separator is the string between concatenated values from the source labels. Separator string `yaml:"separator,omitempty"` // Regex against which the concatenation is matched. Regex Regexp `yaml:"regex,omitempty"` // Modulus to take of the hash of concatenated values from the source labels. Modulus uint64 `yaml:"modulus,omitempty"` // TargetLabel is the label to which the resulting string is written in a replacement. // Regexp interpolation is allowed for the replace action. TargetLabel string `yaml:"target_label,omitempty"` // Replacement is the regex replacement pattern to be used. Replacement string `yaml:"replacement,omitempty"` // Action is the action to be performed for the relabeling. Action RelabelAction `yaml:"action,omitempty"` }
RelabelConfig is the configuration for relabeling of target label sets.
type RemoteReadConfig ¶
type RemoteReadConfig struct { URL *URL `yaml:"url"` RemoteTimeout model.Duration `yaml:"remote_timeout,omitempty"` ReadRecent bool `yaml:"read_recent,omitempty"` // We cannot do proper Go type embedding below as the parser will then parse // values arbitrarily into the overflow maps of further-down types. HTTPClientConfig HTTPClientConfig `yaml:",inline"` // RequiredMatchers is an optional list of equality matchers which have to // be present in a selector to query the remote read endpoint. RequiredMatchers model.LabelSet `yaml:"required_matchers,omitempty"` }
RemoteReadConfig is the configuration for reading from remote storage.
type RemoteWriteConfig ¶
type RemoteWriteConfig struct { URL *URL `yaml:"url"` RemoteTimeout model.Duration `yaml:"remote_timeout,omitempty"` WriteRelabelConfigs []*RelabelConfig `yaml:"write_relabel_configs,omitempty"` // We cannot do proper Go type embedding below as the parser will then parse // values arbitrarily into the overflow maps of further-down types. HTTPClientConfig HTTPClientConfig `yaml:",inline"` QueueConfig QueueConfig `yaml:"queue_config,omitempty"` }
RemoteWriteConfig is the configuration for writing to remote storage.
type RulesConfig ¶
type RulesConfig struct { Alert string `yaml:"alert" json:"alert"` Expr string `yaml:"expr" json:"expr"` For string `yaml:"for" json:"for"` Labels map[string]string `yaml:"labels" json:"labels"` Annotations map[string]string `yaml:"annotations" json:"annotations"` }
RulesConfig rule config
type SDConfig ¶
type SDConfig struct { Role Role `yaml:"role"` NamespaceDiscovery NamespaceDiscovery `yaml:"namespaces,omitempty"` Selectors []SelectorConfig `yaml:"selectors,omitempty"` }
SDConfig is the configuration for Kubernetes service discovery.
type ScrapeConfig ¶
type ScrapeConfig struct { // The job name to which the job label is set by default. JobName string `yaml:"job_name"` // Indicator whether the scraped metrics should remain unmodified. HonorLabels bool `yaml:"honor_labels,omitempty"` // A set of query parameters with which the target is scraped. Params url.Values `yaml:"params,omitempty"` // How frequently to scrape the targets of this scrape config. ScrapeInterval model.Duration `yaml:"scrape_interval,omitempty"` // The timeout for scraping targets of this config. ScrapeTimeout model.Duration `yaml:"scrape_timeout,omitempty"` // The HTTP resource path on which to fetch metrics from targets. MetricsPath string `yaml:"metrics_path,omitempty"` // The URL scheme with which to fetch metrics from targets. Scheme string `yaml:"scheme,omitempty"` // More than this many samples post metric-relabelling will cause the scrape to fail. SampleLimit uint `yaml:"sample_limit,omitempty"` ServiceDiscoveryConfig ServiceDiscoveryConfig `yaml:",inline"` HTTPClientConfig HTTPClientConfig `yaml:",inline"` // List of target relabel configurations. RelabelConfigs []*RelabelConfig `yaml:"relabel_configs,omitempty"` // List of metric relabel configurations. MetricRelabelConfigs []*RelabelConfig `yaml:"metric_relabel_configs,omitempty"` }
ScrapeConfig configures a scraping unit for Prometheus.
type SelectorConfig ¶
type SelectorConfig struct { Role Role `yaml:"role,omitempty"` Label string `yaml:"label,omitempty"` Field string `yaml:"field,omitempty"` }
SelectorConfig selector config
type ServiceDiscoveryConfig ¶
type ServiceDiscoveryConfig struct { // List of labeled target groups for this job. StaticConfigs []*Group `yaml:"static_configs,omitempty"` // List of Kubernetes service discovery configurations. KubernetesSDConfigs []*SDConfig `yaml:"kubernetes_sd_configs,omitempty"` }
ServiceDiscoveryConfig configures lists of different service discovery mechanisms.
type TLSConfig ¶
type TLSConfig struct { // The CA cert to use for the targets. CAFile string `yaml:"ca_file,omitempty"` // The client cert file for the targets. CertFile string `yaml:"cert_file,omitempty"` // The client key file for the targets. KeyFile string `yaml:"key_file,omitempty"` // Used to verify the hostname for the targets. ServerName string `yaml:"server_name,omitempty"` // Disable target certificate validation. InsecureSkipVerify bool `yaml:"insecure_skip_verify"` // Catches all undefined fields and must be empty after parsing. XXX map[string]interface{} `yaml:",inline"` }
TLSConfig configures the options for TLS connections.