mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-02-09 15:27:11 +00:00
Add omitempty for DisableCompression and DisableKeepAlive fields in ScrapeConfig (#796)
* Add omitempty for DisableCompression and DisableKeepAlive fields in ScrapeConfig * Add omitempty annotation to all the default/optional values * Fix annotations after review
This commit is contained in:
parent
9ce5c0c33f
commit
6fcbd17bdd
10 changed files with 92 additions and 92 deletions
|
@ -13,18 +13,18 @@ import (
|
||||||
//
|
//
|
||||||
// See https://prometheus.io/docs/prometheus/latest/configuration/configuration/#tls_config
|
// See https://prometheus.io/docs/prometheus/latest/configuration/configuration/#tls_config
|
||||||
type TLSConfig struct {
|
type TLSConfig struct {
|
||||||
CAFile string `yaml:"ca_file"`
|
CAFile string `yaml:"ca_file,omitempty"`
|
||||||
CertFile string `yaml:"cert_file"`
|
CertFile string `yaml:"cert_file,omitempty"`
|
||||||
KeyFile string `yaml:"key_file"`
|
KeyFile string `yaml:"key_file,omitempty"`
|
||||||
ServerName string `yaml:"server_name"`
|
ServerName string `yaml:"server_name,omitempty"`
|
||||||
InsecureSkipVerify bool `yaml:"insecure_skip_verify"`
|
InsecureSkipVerify bool `yaml:"insecure_skip_verify,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// BasicAuthConfig represents basic auth config.
|
// BasicAuthConfig represents basic auth config.
|
||||||
type BasicAuthConfig struct {
|
type BasicAuthConfig struct {
|
||||||
Username string `yaml:"username"`
|
Username string `yaml:"username"`
|
||||||
Password string `yaml:"password"`
|
Password string `yaml:"password,omitempty"`
|
||||||
PasswordFile string `yaml:"password_file"`
|
PasswordFile string `yaml:"password_file,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Config is auth config.
|
// Config is auth config.
|
||||||
|
|
|
@ -14,13 +14,13 @@ import (
|
||||||
//
|
//
|
||||||
// See https://prometheus.io/docs/prometheus/latest/configuration/configuration/#relabel_config
|
// See https://prometheus.io/docs/prometheus/latest/configuration/configuration/#relabel_config
|
||||||
type RelabelConfig struct {
|
type RelabelConfig struct {
|
||||||
SourceLabels []string `yaml:"source_labels"`
|
SourceLabels []string `yaml:"source_labels,flow,omitempty"`
|
||||||
Separator *string `yaml:"separator"`
|
Separator *string `yaml:"separator,omitempty"`
|
||||||
TargetLabel string `yaml:"target_label"`
|
TargetLabel string `yaml:"target_label,omitempty"`
|
||||||
Regex *string `yaml:"regex"`
|
Regex *string `yaml:"regex,omitempty"`
|
||||||
Modulus uint64 `yaml:"modulus"`
|
Modulus uint64 `yaml:"modulus,omitempty"`
|
||||||
Replacement *string `yaml:"replacement"`
|
Replacement *string `yaml:"replacement,omitempty"`
|
||||||
Action string `yaml:"action"`
|
Action string `yaml:"action,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// LoadRelabelConfigs loads relabel configs from the given path.
|
// LoadRelabelConfigs loads relabel configs from the given path.
|
||||||
|
|
|
@ -50,9 +50,9 @@ type Config struct {
|
||||||
//
|
//
|
||||||
// See https://prometheus.io/docs/prometheus/latest/configuration/configuration/
|
// See https://prometheus.io/docs/prometheus/latest/configuration/configuration/
|
||||||
type GlobalConfig struct {
|
type GlobalConfig struct {
|
||||||
ScrapeInterval time.Duration `yaml:"scrape_interval"`
|
ScrapeInterval time.Duration `yaml:"scrape_interval,omitempty"`
|
||||||
ScrapeTimeout time.Duration `yaml:"scrape_timeout"`
|
ScrapeTimeout time.Duration `yaml:"scrape_timeout,omitempty"`
|
||||||
ExternalLabels map[string]string `yaml:"external_labels"`
|
ExternalLabels map[string]string `yaml:"external_labels,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ScrapeConfig represents essential parts for `scrape_config` section of Prometheus config.
|
// ScrapeConfig represents essential parts for `scrape_config` section of Prometheus config.
|
||||||
|
@ -60,34 +60,34 @@ type GlobalConfig struct {
|
||||||
// See https://prometheus.io/docs/prometheus/latest/configuration/configuration/#scrape_config
|
// See https://prometheus.io/docs/prometheus/latest/configuration/configuration/#scrape_config
|
||||||
type ScrapeConfig struct {
|
type ScrapeConfig struct {
|
||||||
JobName string `yaml:"job_name"`
|
JobName string `yaml:"job_name"`
|
||||||
ScrapeInterval time.Duration `yaml:"scrape_interval"`
|
ScrapeInterval time.Duration `yaml:"scrape_interval,omitempty"`
|
||||||
ScrapeTimeout time.Duration `yaml:"scrape_timeout"`
|
ScrapeTimeout time.Duration `yaml:"scrape_timeout,omitempty"`
|
||||||
MetricsPath string `yaml:"metrics_path"`
|
MetricsPath string `yaml:"metrics_path,omitempty"`
|
||||||
HonorLabels bool `yaml:"honor_labels"`
|
HonorLabels bool `yaml:"honor_labels,omitempty"`
|
||||||
HonorTimestamps bool `yaml:"honor_timestamps"`
|
HonorTimestamps bool `yaml:"honor_timestamps,omitempty"`
|
||||||
Scheme string `yaml:"scheme"`
|
Scheme string `yaml:"scheme,omitempty"`
|
||||||
Params map[string][]string `yaml:"params"`
|
Params map[string][]string `yaml:"params,omitempty"`
|
||||||
BasicAuth *promauth.BasicAuthConfig `yaml:"basic_auth"`
|
BasicAuth *promauth.BasicAuthConfig `yaml:"basic_auth,omitempty"`
|
||||||
BearerToken string `yaml:"bearer_token"`
|
BearerToken string `yaml:"bearer_token,omitempty"`
|
||||||
BearerTokenFile string `yaml:"bearer_token_file"`
|
BearerTokenFile string `yaml:"bearer_token_file,omitempty"`
|
||||||
TLSConfig *promauth.TLSConfig `yaml:"tls_config"`
|
TLSConfig *promauth.TLSConfig `yaml:"tls_config,omitempty"`
|
||||||
StaticConfigs []StaticConfig `yaml:"static_configs"`
|
StaticConfigs []StaticConfig `yaml:"static_configs,omitempty"`
|
||||||
FileSDConfigs []FileSDConfig `yaml:"file_sd_configs"`
|
FileSDConfigs []FileSDConfig `yaml:"file_sd_configs,omitempty"`
|
||||||
KubernetesSDConfigs []kubernetes.SDConfig `yaml:"kubernetes_sd_configs"`
|
KubernetesSDConfigs []kubernetes.SDConfig `yaml:"kubernetes_sd_configs,omitempty"`
|
||||||
OpenStackSDConfigs []openstack.SDConfig `yaml:"openstack_sd_configs"`
|
OpenStackSDConfigs []openstack.SDConfig `yaml:"openstack_sd_configs,omitempty"`
|
||||||
ConsulSDConfigs []consul.SDConfig `yaml:"consul_sd_configs"`
|
ConsulSDConfigs []consul.SDConfig `yaml:"consul_sd_configs,omitempty"`
|
||||||
DockerSwarmConfigs []dockerswarm.SDConfig `yaml:"dockerswarm_sd_configs"`
|
DockerSwarmConfigs []dockerswarm.SDConfig `yaml:"dockerswarm_sd_configs,omitempty"`
|
||||||
DNSSDConfigs []dns.SDConfig `yaml:"dns_sd_configs"`
|
DNSSDConfigs []dns.SDConfig `yaml:"dns_sd_configs,omitempty"`
|
||||||
EC2SDConfigs []ec2.SDConfig `yaml:"ec2_sd_configs"`
|
EC2SDConfigs []ec2.SDConfig `yaml:"ec2_sd_configs,omitempty"`
|
||||||
GCESDConfigs []gce.SDConfig `yaml:"gce_sd_configs"`
|
GCESDConfigs []gce.SDConfig `yaml:"gce_sd_configs,omitempty"`
|
||||||
RelabelConfigs []promrelabel.RelabelConfig `yaml:"relabel_configs"`
|
RelabelConfigs []promrelabel.RelabelConfig `yaml:"relabel_configs,omitempty"`
|
||||||
MetricRelabelConfigs []promrelabel.RelabelConfig `yaml:"metric_relabel_configs"`
|
MetricRelabelConfigs []promrelabel.RelabelConfig `yaml:"metric_relabel_configs,omitempty"`
|
||||||
SampleLimit int `yaml:"sample_limit"`
|
SampleLimit int `yaml:"sample_limit,omitempty"`
|
||||||
|
|
||||||
// These options are supported only by lib/promscrape.
|
// These options are supported only by lib/promscrape.
|
||||||
DisableCompression bool `yaml:"disable_compression"`
|
DisableCompression bool `yaml:"disable_compression,omitempty"`
|
||||||
DisableKeepAlive bool `yaml:"disable_keepalive"`
|
DisableKeepAlive bool `yaml:"disable_keepalive,omitempty"`
|
||||||
StreamParse bool `yaml:"stream_parse"`
|
StreamParse bool `yaml:"stream_parse,omitempty"`
|
||||||
|
|
||||||
// This is set in loadConfig
|
// This is set in loadConfig
|
||||||
swc *scrapeWorkConfig
|
swc *scrapeWorkConfig
|
||||||
|
@ -106,7 +106,7 @@ type FileSDConfig struct {
|
||||||
// See https://prometheus.io/docs/prometheus/latest/configuration/configuration/#static_config
|
// See https://prometheus.io/docs/prometheus/latest/configuration/configuration/#static_config
|
||||||
type StaticConfig struct {
|
type StaticConfig struct {
|
||||||
Targets []string `yaml:"targets"`
|
Targets []string `yaml:"targets"`
|
||||||
Labels map[string]string `yaml:"labels"`
|
Labels map[string]string `yaml:"labels,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadStaticConfigs(path string) ([]StaticConfig, error) {
|
func loadStaticConfigs(path string) ([]StaticConfig, error) {
|
||||||
|
|
|
@ -10,18 +10,18 @@ import (
|
||||||
//
|
//
|
||||||
// See https://prometheus.io/docs/prometheus/latest/configuration/configuration/#consul_sd_config
|
// See https://prometheus.io/docs/prometheus/latest/configuration/configuration/#consul_sd_config
|
||||||
type SDConfig struct {
|
type SDConfig struct {
|
||||||
Server string `yaml:"server"`
|
Server string `yaml:"server,omitempty"`
|
||||||
Token *string `yaml:"token"`
|
Token *string `yaml:"token"`
|
||||||
Datacenter string `yaml:"datacenter"`
|
Datacenter string `yaml:"datacenter"`
|
||||||
Scheme string `yaml:"scheme"`
|
Scheme string `yaml:"scheme,omitempty"`
|
||||||
Username string `yaml:"username"`
|
Username string `yaml:"username"`
|
||||||
Password string `yaml:"password"`
|
Password string `yaml:"password"`
|
||||||
TLSConfig *promauth.TLSConfig `yaml:"tls_config"`
|
TLSConfig *promauth.TLSConfig `yaml:"tls_config,omitempty"`
|
||||||
Services []string `yaml:"services"`
|
Services []string `yaml:"services,omitempty"`
|
||||||
Tags []string `yaml:"tags"`
|
Tags []string `yaml:"tags,omitempty"`
|
||||||
NodeMeta map[string]string `yaml:"node_meta"`
|
NodeMeta map[string]string `yaml:"node_meta,omitempty"`
|
||||||
TagSeparator *string `yaml:"tag_separator"`
|
TagSeparator *string `yaml:"tag_separator,omitempty"`
|
||||||
AllowStale bool `yaml:"allow_stale"`
|
AllowStale bool `yaml:"allow_stale,omitempty"`
|
||||||
// RefreshInterval time.Duration `yaml:"refresh_interval"`
|
// RefreshInterval time.Duration `yaml:"refresh_interval"`
|
||||||
// refresh_interval is obtained from `-promscrape.consulSDCheckInterval` command-line option.
|
// refresh_interval is obtained from `-promscrape.consulSDCheckInterval` command-line option.
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,8 +17,8 @@ import (
|
||||||
// See https://prometheus.io/docs/prometheus/latest/configuration/configuration/#dns_sd_config
|
// See https://prometheus.io/docs/prometheus/latest/configuration/configuration/#dns_sd_config
|
||||||
type SDConfig struct {
|
type SDConfig struct {
|
||||||
Names []string `yaml:"names"`
|
Names []string `yaml:"names"`
|
||||||
Type string `yaml:"type"`
|
Type string `yaml:"type,omitempty"`
|
||||||
Port *int `yaml:"port"`
|
Port *int `yaml:"port,omitempty"`
|
||||||
// RefreshInterval time.Duration `yaml:"refresh_interval"`
|
// RefreshInterval time.Duration `yaml:"refresh_interval"`
|
||||||
// refresh_interval is obtained from `-promscrape.dnsSDCheckInterval` command-line option.
|
// refresh_interval is obtained from `-promscrape.dnsSDCheckInterval` command-line option.
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,13 +12,13 @@ import (
|
||||||
type SDConfig struct {
|
type SDConfig struct {
|
||||||
Host string `yaml:"host"`
|
Host string `yaml:"host"`
|
||||||
// TODO: add support for proxy_url
|
// TODO: add support for proxy_url
|
||||||
TLSConfig *promauth.TLSConfig `yaml:"tls_config"`
|
TLSConfig *promauth.TLSConfig `yaml:"tls_config,omitempty"`
|
||||||
Role string `yaml:"role"`
|
Role string `yaml:"role"`
|
||||||
Port int `yaml:"port"`
|
Port int `yaml:"port,omitempty"`
|
||||||
// refresh_interval is obtained from `-promscrape.dockerswarmSDCheckInterval` command-line option
|
// refresh_interval is obtained from `-promscrape.dockerswarmSDCheckInterval` command-line option
|
||||||
BasicAuth *promauth.BasicAuthConfig `yaml:"basic_auth"`
|
BasicAuth *promauth.BasicAuthConfig `yaml:"basic_auth,omitempty"`
|
||||||
BearerToken string `yaml:"bearer_token"`
|
BearerToken string `yaml:"bearer_token,omitempty"`
|
||||||
BearerTokenFile string `yaml:"bearer_token_file"`
|
BearerTokenFile string `yaml:"bearer_token_file,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetLabels returns dockerswarm labels according to sdc.
|
// GetLabels returns dockerswarm labels according to sdc.
|
||||||
|
|
|
@ -8,17 +8,17 @@ import (
|
||||||
//
|
//
|
||||||
// See https://prometheus.io/docs/prometheus/latest/configuration/configuration/#ec2_sd_config
|
// See https://prometheus.io/docs/prometheus/latest/configuration/configuration/#ec2_sd_config
|
||||||
type SDConfig struct {
|
type SDConfig struct {
|
||||||
Region string `yaml:"region"`
|
Region string `yaml:"region,omitempty"`
|
||||||
Endpoint string `yaml:"endpoint"`
|
Endpoint string `yaml:"endpoint,omitempty"`
|
||||||
AccessKey string `yaml:"access_key"`
|
AccessKey string `yaml:"access_key,omitempty"`
|
||||||
SecretKey string `yaml:"secret_key"`
|
SecretKey string `yaml:"secret_key,omitempty"`
|
||||||
// TODO add support for Profile, not working atm
|
// TODO add support for Profile, not working atm
|
||||||
Profile string `yaml:"profile"`
|
Profile string `yaml:"profile,omitempty"`
|
||||||
RoleARN string `yaml:"role_arn"`
|
RoleARN string `yaml:"role_arn,omitempty"`
|
||||||
// RefreshInterval time.Duration `yaml:"refresh_interval"`
|
// RefreshInterval time.Duration `yaml:"refresh_interval"`
|
||||||
// refresh_interval is obtained from `-promscrape.ec2SDCheckInterval` command-line option.
|
// refresh_interval is obtained from `-promscrape.ec2SDCheckInterval` command-line option.
|
||||||
Port *int `yaml:"port"`
|
Port *int `yaml:"port,omitempty"`
|
||||||
Filters []Filter `yaml:"filters"`
|
Filters []Filter `yaml:"filters,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter is ec2 filter.
|
// Filter is ec2 filter.
|
||||||
|
|
|
@ -10,11 +10,11 @@ import (
|
||||||
type SDConfig struct {
|
type SDConfig struct {
|
||||||
Project string `yaml:"project"`
|
Project string `yaml:"project"`
|
||||||
Zone ZoneYAML `yaml:"zone"`
|
Zone ZoneYAML `yaml:"zone"`
|
||||||
Filter string `yaml:"filter"`
|
Filter string `yaml:"filter,omitempty"`
|
||||||
// RefreshInterval time.Duration `yaml:"refresh_interval"`
|
// RefreshInterval time.Duration `yaml:"refresh_interval"`
|
||||||
// refresh_interval is obtained from `-promscrape.gceSDCheckInterval` command-line option.
|
// refresh_interval is obtained from `-promscrape.gceSDCheckInterval` command-line option.
|
||||||
Port *int `yaml:"port"`
|
Port *int `yaml:"port,omitempty"`
|
||||||
TagSeparator *string `yaml:"tag_separator"`
|
TagSeparator *string `yaml:"tag_separator,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ZoneYAML holds info about zones.
|
// ZoneYAML holds info about zones.
|
||||||
|
|
|
@ -10,14 +10,14 @@ import (
|
||||||
//
|
//
|
||||||
// See https://prometheus.io/docs/prometheus/latest/configuration/configuration/#kubernetes_sd_config
|
// See https://prometheus.io/docs/prometheus/latest/configuration/configuration/#kubernetes_sd_config
|
||||||
type SDConfig struct {
|
type SDConfig struct {
|
||||||
APIServer string `yaml:"api_server"`
|
APIServer string `yaml:"api_server,omitempty"`
|
||||||
Role string `yaml:"role"`
|
Role string `yaml:"role"`
|
||||||
BasicAuth *promauth.BasicAuthConfig `yaml:"basic_auth"`
|
BasicAuth *promauth.BasicAuthConfig `yaml:"basic_auth,omitempty"`
|
||||||
BearerToken string `yaml:"bearer_token"`
|
BearerToken string `yaml:"bearer_token,omitempty"`
|
||||||
BearerTokenFile string `yaml:"bearer_token_file"`
|
BearerTokenFile string `yaml:"bearer_token_file,omitempty"`
|
||||||
TLSConfig *promauth.TLSConfig `yaml:"tls_config"`
|
TLSConfig *promauth.TLSConfig `yaml:"tls_config,omitempty"`
|
||||||
Namespaces Namespaces `yaml:"namespaces"`
|
Namespaces Namespaces `yaml:"namespaces,omitempty"`
|
||||||
Selectors []Selector `yaml:"selectors"`
|
Selectors []Selector `yaml:"selectors,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Namespaces represents namespaces for SDConfig
|
// Namespaces represents namespaces for SDConfig
|
||||||
|
|
|
@ -10,25 +10,25 @@ import (
|
||||||
//
|
//
|
||||||
// See https://prometheus.io/docs/prometheus/latest/configuration/configuration/#openstack_sd_config
|
// See https://prometheus.io/docs/prometheus/latest/configuration/configuration/#openstack_sd_config
|
||||||
type SDConfig struct {
|
type SDConfig struct {
|
||||||
IdentityEndpoint string `yaml:"identity_endpoint"`
|
IdentityEndpoint string `yaml:"identity_endpoint,omitempty"`
|
||||||
Username string `yaml:"username"`
|
Username string `yaml:"username,omitempty"`
|
||||||
UserID string `yaml:"userid"`
|
UserID string `yaml:"userid,omitempty"`
|
||||||
Password string `yaml:"password"`
|
Password string `yaml:"password,omitempty"`
|
||||||
ProjectName string `yaml:"project_name"`
|
ProjectName string `yaml:"project_name,omitempty"`
|
||||||
ProjectID string `yaml:"project_id"`
|
ProjectID string `yaml:"project_id,omitempty"`
|
||||||
DomainName string `yaml:"domain_name"`
|
DomainName string `yaml:"domain_name,omitempty"`
|
||||||
DomainID string `yaml:"domain_id"`
|
DomainID string `yaml:"domain_id,omitempty"`
|
||||||
ApplicationCredentialName string `yaml:"application_credential_name"`
|
ApplicationCredentialName string `yaml:"application_credential_name,omitempty"`
|
||||||
ApplicationCredentialID string `yaml:"application_credential_id"`
|
ApplicationCredentialID string `yaml:"application_credential_id,omitempty"`
|
||||||
ApplicationCredentialSecret string `yaml:"application_credential_secret"`
|
ApplicationCredentialSecret string `yaml:"application_credential_secret,omitempty"`
|
||||||
Role string `yaml:"role"`
|
Role string `yaml:"role"`
|
||||||
Region string `yaml:"region"`
|
Region string `yaml:"region"`
|
||||||
// RefreshInterval time.Duration `yaml:"refresh_interval"`
|
// RefreshInterval time.Duration `yaml:"refresh_interval"`
|
||||||
// refresh_interval is obtained from `-promscrape.openstackSDCheckInterval` command-line option.
|
// refresh_interval is obtained from `-promscrape.openstackSDCheckInterval` command-line option.
|
||||||
Port int `yaml:"port"`
|
Port int `yaml:"port,omitempty"`
|
||||||
AllTenants bool `yaml:"all_tenants"`
|
AllTenants bool `yaml:"all_tenants,omitempty"`
|
||||||
TLSConfig *promauth.TLSConfig `yaml:"tls_config"`
|
TLSConfig *promauth.TLSConfig `yaml:"tls_config,omitempty"`
|
||||||
Availability string `yaml:"availability"`
|
Availability string `yaml:"availability,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetLabels returns gce labels according to sdc.
|
// GetLabels returns gce labels according to sdc.
|
||||||
|
|
Loading…
Reference in a new issue