Documentation ¶
Overview ¶
Package promconfig is for Prometheus configuration file parsing and generation without dependencies.
Index ¶
- Constants
- func Copy(s interface{}) interface{}
- func MaskSecret(c interface{})
- type AlertingConfig
- type AlertmanagerConfig
- type Authorization
- type AzureSDConfig
- type BasicAuth
- type Config
- type ConsulSDConfig
- type DNSSDConfig
- type DigitaloceanSDConfig
- type DockerswarmSDConfig
- type Duration
- type EC2SDConfig
- type FilesSDConfig
- type Filter
- type GceSDConfig
- type GlobalConfig
- type Group
- type HTTPClientConfig
- type HTTPSDConfig
- type KubernetesSDConfig
- type OAuth2
- type QueueConfig
- type RelabelConfig
- type RemoteReadConfig
- type RemoteWriteConfig
- type ScrapeConfig
- type ServiceDiscoveryConfig
- type TLSConfig
Constants ¶
const ( // AlertmanagerAPIVersionV1 represents // github.com/prometheus/alertmanager/api/v1. AlertmanagerAPIVersionV1 = "v1" // AlertmanagerAPIVersionV2 represents // github.com/prometheus/alertmanager/api/v2. AlertmanagerAPIVersionV2 = "v2" )
Variables ¶
This section is empty.
Functions ¶
func Copy ¶ added in v0.2.5
func Copy(s interface{}) interface{}
Copy creates a deep copy of whatever is passed to it and returns the copy in an interface{}. The returned value will need to be asserted to the correct type.
func MaskSecret ¶ added in v0.2.5
func MaskSecret(c interface{})
MaskSecret loops over struct and masks values for Secret datatype.
Types ¶
type AlertingConfig ¶
type AlertingConfig struct { AlertRelabelConfigs []*RelabelConfig `yaml:"alert_relabel_configs,omitempty"` AlertmanagerConfigs []*AlertmanagerConfig `yaml:"alertmanagers,omitempty"` }
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 Duration `yaml:"timeout,omitempty"` // The api version of Alertmanager. APIVersion string `yaml:"api_version,omitempty"` // List of Alertmanager relabel configurations. RelabelConfigs []*RelabelConfig `yaml:"relabel_configs,omitempty"` }
AlertmanagerConfig configures how Alertmanagers can be discovered and communicated with.
type Authorization ¶ added in v0.2.3
type Authorization struct { Type string `yaml:"type,omitempty"` Credentials string `yaml:"credentials,omitempty" secret:"true"` CredentialsFile string `yaml:"credentials_file,omitempty"` }
Authorization contains HTTP authorization credentials.
type AzureSDConfig ¶ added in v0.2.3
type AzureSDConfig struct { Environment string `yaml:"environment,omitempty"` SubscriptionID string `yaml:"subscription_id"` TenantID string `yaml:"tenant_id,omitempty"` ClientID string `yaml:"client_id,omitempty"` ClientSecret string `yaml:"client_secret,omitempty"` RefreshInterval Duration `yaml:"refresh_interval,omitempty"` Port int `yaml:"port,omitempty"` }
AzureSDConfig is the configuration for Azure cloud service discovery.
type BasicAuth ¶
type BasicAuth struct { Username string `yaml:"username"` Password string `yaml:"password,omitempty" secret:"true"` PasswordFile string `yaml:"password_file,omitempty"` }
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"` }
Config is the top-level configuration for Prometheus's config files.
type ConsulSDConfig ¶ added in v0.2.3
type ConsulSDConfig struct { Server string `yaml:"server,omitempty"` Token string `yaml:"token"` Datacenter string `yaml:"datacenter"` Scheme string `yaml:"scheme,omitempty"` Username string `yaml:"username"` Password string `yaml:"password"` TLSConfig TLSConfig `yaml:"tls_config,omitempty"` Services []string `yaml:"services,omitempty"` Tags []string `yaml:"tags,omitempty"` NodeMeta map[string]string `yaml:"node_meta,omitempty"` TagSeprator string `yaml:"tag_seprator,omitempty"` AllowStale bool `yaml:"allow_stale"` RefreshInterval Duration `yaml:"refresh_interval,omitempty"` }
ConsulSDConfig is the configuration for the consul catalogue service discovery.
type DNSSDConfig ¶ added in v0.2.3
type DNSSDConfig struct { Names []string `yaml:"names"` Type string `yaml:"type,omitempty"` RefreshInterval Duration `yaml:"refresh_interval,omitempty"` Port int `yaml:"port,omitempty"` }
DNSSDConfig is configuration for dns based service discovery.
type DigitaloceanSDConfig ¶ added in v0.2.3
type DigitaloceanSDConfig struct { HTTPClientConfig HTTPClientConfig `yaml:",inline"` RefreshInterval Duration `yaml:"refresh_interval,omitempty"` Port int `yaml:"port,omitempty"` }
DigitaloceanSDConfig is the configuration for digitalocean droplet service discovery.
type DockerswarmSDConfig ¶ added in v0.2.3
type DockerswarmSDConfig struct { HTTPClientConfig HTTPClientConfig `yaml:",inline"` Host string `yaml:"host"` Role string `yaml:"role"` RefreshInterval Duration `yaml:"refresh_interval,omitempty"` Port int `yaml:"port,omitempty"` Filters []*Filter `yaml:"filters,omitempty"` }
DockerswarmSDConfig is the configuration for service discovery of docker services, tasks or nodes.
type Duration ¶
Duration wraps time.Duration. It is used to parse the custom duration format from YAML. This type should not propagate beyond the scope of input/output processing.
func ParseDuration ¶
ParseDuration parses a string into a time.Duration, assuming that a year always has 365d, a week always has 7d, and a day always has 24h.
func (Duration) MarshalYAML ¶
MarshalYAML implements the yaml.Marshaler interface.
func (*Duration) UnmarshalYAML ¶
UnmarshalYAML implements the yaml.Unmarshaler interface.
type EC2SDConfig ¶ added in v0.2.3
type EC2SDConfig struct { Region string `yaml:"region,omitempty"` Endpoint string `yaml:"endpoint,omitempty"` AccessKey string `yaml:"access_key,omitempty"` SecretKey string `yaml:"secret_key,omitempty"` Profile string `yaml:"profile,omitempty"` RoleArn string `yaml:"role_arn,omitempty"` RefreshInterval Duration `yaml:"refresh_interval,omitempty"` Port int `yaml:"port,omitempty"` Filters []*Filter `yaml:"filters,omitempty"` }
EC2SDConfig is the configuration for AWS EC2 instance service discovery.
type FilesSDConfig ¶
type FilesSDConfig struct { Files []string `yaml:"files"` RefreshInterval Duration `yaml:"refresh_interval,omitempty"` }
FilesSDConfig is the configuration for file based discovery.
type GceSDConfig ¶ added in v0.2.3
type GceSDConfig struct { Project string `yaml:"project"` Zone string `yaml:"zone"` Filter string `yaml:"filter,omitempty"` RefreshInterval Duration `yaml:"refresh_interval,omitempty"` Port int `yaml:"port,omitempty"` TagSeprator string `yaml:"tag_separator,omitempty"` }
GceSDConfig is the configuration for Google cloud GCE instance service discovery.
type GlobalConfig ¶
type GlobalConfig struct { // How frequently to scrape targets by default. ScrapeInterval Duration `yaml:"scrape_interval,omitempty"` // The default timeout when scraping targets. ScrapeTimeout Duration `yaml:"scrape_timeout,omitempty"` // How frequently to evaluate rules by default. EvaluationInterval Duration `yaml:"evaluation_interval,omitempty"` // File to which PromQL queries are logged. QueryLogFile string `yaml:"query_log_file,omitempty"` // The labels to add to any timeseries that this Prometheus instance scrapes. ExternalLabels map[string]string `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,omitempty"` // Labels is a set of labels that is common across all targets in the group. Labels map[string]string `yaml:"labels,omitempty"` }
Group is a set of targets with a common label set(production , test, staging etc.).
type HTTPClientConfig ¶
type HTTPClientConfig struct { // The HTTP basic authentication credentials for the targets. BasicAuth *BasicAuth `yaml:"basic_auth,omitempty"` // The HTTP authorization credentials for the targets. Authorization *Authorization `yaml:"authorization,omitempty"` // The OAuth2 client credentials used to fetch a token for the targets. OAuth2 *OAuth2 `yaml:"oauth2,omitempty"` // The bearer token for the targets. // Deprecated: use Authorization.Credentials instead. BearerToken string `yaml:"bearer_token,omitempty" secret:"true"` // The bearer token file for the targets. // Deprecated: use Authorization.Credentials instead. BearerTokenFile string `yaml:"bearer_token_file,omitempty"` // HTTP proxy server to use to connect to the targets. ProxyURL string `yaml:"proxy_url,omitempty"` // TLSConfig to use to connect to the targets. TLSConfig TLSConfig `yaml:"tls_config,omitempty"` // FollowRedirects specifies whether the client should follow HTTP 3xx redirects. // The omitempty flag is not set, because it would be hidden from the // marshalled configuration when set to false. FollowRedirects bool `yaml:"follow_redirects"` }
HTTPClientConfig configures an HTTP client.
type HTTPSDConfig ¶ added in v0.2.3
type HTTPSDConfig struct { HTTPClientConfig HTTPClientConfig `yaml:",inline"` RefreshInterval Duration `yaml:"refresh_interval,omitempty"` URL string `yaml:"url,omitempty"` }
HTTPSDConfig is the configuration for HTTP service discovery.
type KubernetesSDConfig ¶
type KubernetesSDConfig struct { APIServer string `yaml:"api_server,omitempty"` Role string `yaml:"role"` HTTPClientConfig HTTPClientConfig `yaml:",inline"` NamespaceDiscovery []string `yaml:"namespaces,omitempty"` }
KubernetesSDConfig is the configuration for Kubernetes service discovery.
type OAuth2 ¶ added in v0.2.3
type OAuth2 struct { ClientID string `yaml:"client_id"` ClientSecret string `yaml:"client_secret" secret:"true"` ClientSecretFile string `yaml:"client_secret_file"` Scopes []string `yaml:"scopes,omitempty"` TokenURL string `yaml:"token_url"` EndpointParams map[string]string `yaml:"endpoint_params,omitempty"` }
OAuth2 is the oauth2 client configuration.
type QueueConfig ¶
type QueueConfig struct { // Number of samples to buffer per shard before we block. Defaults to // MaxSamplesPerSend. Capacity int `yaml:"capacity,omitempty"` // Max number of shards, i.e. amount of concurrency. MaxShards int `yaml:"max_shards,omitempty"` // Min number of shards, i.e. amount of concurrency. MinShards int `yaml:"min_shards,omitempty"` // Maximum number of samples per send. MaxSamplesPerSend int `yaml:"max_samples_per_send,omitempty"` // Maximum time sample will wait in buffer. BatchSendDeadline Duration `yaml:"batch_send_deadline,omitempty"` // On recoverable errors, backoff exponentially. MinBackoff Duration `yaml:"min_backoff,omitempty"` MaxBackoff Duration `yaml:"max_backoff,omitempty"` }
QueueConfig is the configuration for the queue used to write to remote storage.
type RelabelConfig ¶
type RelabelConfig struct { // A list of labels from which values are taken and concatenated // with the configured separator in order. SourceLabels []string `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 string `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 string `yaml:"action,omitempty"` }
RelabelConfig is the configuration for relabeling of target label sets.
type RemoteReadConfig ¶
type RemoteReadConfig struct { URL string `yaml:"url"` RemoteTimeout Duration `yaml:"remote_timeout,omitempty"` ReadRecent bool `yaml:"read_recent,omitempty"` Name string `yaml:"name,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 map[string]string `yaml:"required_matchers,omitempty"` }
RemoteReadConfig is the configuration for reading from remote storage.
type RemoteWriteConfig ¶
type RemoteWriteConfig struct { URL string `yaml:"url"` RemoteTimeout Duration `yaml:"remote_timeout,omitempty"` WriteRelabelConfigs []*RelabelConfig `yaml:"write_relabel_configs,omitempty"` Name string `yaml:"name,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 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"` // Indicator whether the scraped timestamps should be respected. HonorTimestamps bool `yaml:"honor_timestamps"` // 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 Duration `yaml:"scrape_interval,omitempty"` // The timeout for scraping targets of this config. ScrapeTimeout 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"` // Whether to parse target responses in a streaming manner. StreamParse bool `yaml:"stream_parse,omitempty"` }
ScrapeConfig configures a scraping unit for Prometheus.
type ServiceDiscoveryConfig ¶
type ServiceDiscoveryConfig struct { // List of labeled target groups for this job. StaticConfigs []*Group `yaml:"static_configs,omitempty"` // List of file service discovery configurations. FileSDConfigs []*FilesSDConfig `yaml:"file_sd_configs,omitempty"` // List of HTTP service discovery configurations. HTTPSDConfigs []*HTTPSDConfig `yaml:"http_sd_configs,omitempty"` // List of Kubernetes service discovery configurations. KubernetesSDConfigs []*KubernetesSDConfig `yaml:"kubernetes_sd_configs,omitempty"` // List of AWS EC2 service discovery configurations. EC2SDConfigs []*EC2SDConfig `yaml:"ec2_sd_configs,omitempty"` // List of Google cloud GCE service discovery configurations. GceSDConfigs []*GceSDConfig `yaml:"gce_sd_configs,omitempty"` // List of azure cloud service discovery configurations. AzureSDConfigs []*AzureSDConfig `yaml:"azure_sd_configs,omitempty"` // List of digitalocean droplet service discovery configurations. DigitaloceanSDConfigs []*DigitaloceanSDConfig `yaml:"digitalocean_sd_configs,omitempty"` // List of consul catalog service discovery configurations. ConsulSDConfigs []*ConsulSDConfig `yaml:"consul_sd_configs,omitempty"` // List of docker swarm service discovery configurations. DockerswarmSDConfigs []*DockerswarmSDConfig `yaml:"dockerswarm_sd_configs,omitempty"` // List of dns-based service discovery configurations. DNSSDConfigs []*DNSSDConfig `yaml:"dns_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"` }
TLSConfig configures the options for TLS connections.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package alertmanager provides utilities to work with Alertmanager's configuration
|
Package alertmanager provides utilities to work with Alertmanager's configuration |