Documentation ¶
Index ¶
- Variables
- func CheckTargetAddress(address string) error
- func JoinDir(dir, path string) string
- func NewAuthorizationCredentialsFileRoundTripper(authType, authCredentialsFile string, rt http.RoundTripper) http.RoundTripper
- func NewAuthorizationCredentialsRoundTripper(authType string, authCredentials Secret, rt http.RoundTripper) http.RoundTripper
- func NewBasicAuthRoundTripper(username string, password Secret, passwordFile string, rt http.RoundTripper) http.RoundTripper
- func NewClientFromConfig(cfg HTTPClientConfig, name string, optFuncs ...HTTPClientOption) (*http.Client, error)
- func NewOAuth2RoundTripper(config *OAuth2, next http.RoundTripper) http.RoundTripper
- func NewRoundTripperFromConfig(cfg HTTPClientConfig, name string, optFuncs ...HTTPClientOption) (http.RoundTripper, error)
- func NewTLSConfig(cfg *TLSConfig) (*tls.Config, error)
- func NewTLSRoundTripper(cfg *tls.Config, caFile string, ...) (http.RoundTripper, error)
- type Authorization
- type BasicAuth
- type Config
- type DialContextFunc
- type DirectorySetter
- type HTTPClientConfig
- type HTTPClientOption
- type OAuth2
- type Profile
- type SampleTypeConfig
- type Secret
- type TLSConfig
- type URL
Constants ¶
This section is empty.
Variables ¶
var DefaultHTTPClientConfig = HTTPClientConfig{ FollowRedirects: true, }
DefaultHTTPClientConfig is the default HTTP client configuration.
Functions ¶
func CheckTargetAddress ¶
func JoinDir ¶
JoinDir joins dir and path if path is relative. If path is empty or absolute, it is returned unchanged.
func NewAuthorizationCredentialsFileRoundTripper ¶
func NewAuthorizationCredentialsFileRoundTripper(authType, authCredentialsFile string, rt http.RoundTripper) http.RoundTripper
NewAuthorizationCredentialsFileRoundTripper adds the authorization credentials read from the provided file to a request unless the authorization header has already been set. This file is read for every request.
func NewAuthorizationCredentialsRoundTripper ¶
func NewAuthorizationCredentialsRoundTripper(authType string, authCredentials Secret, rt http.RoundTripper) http.RoundTripper
NewAuthorizationCredentialsRoundTripper adds the provided credentials to a request unless the authorization header has already been set.
func NewBasicAuthRoundTripper ¶
func NewBasicAuthRoundTripper(username string, password Secret, passwordFile string, rt http.RoundTripper) http.RoundTripper
NewBasicAuthRoundTripper will apply a BASIC auth authorization header to a request unless it has already been set.
func NewClientFromConfig ¶
func NewClientFromConfig(cfg HTTPClientConfig, name string, optFuncs ...HTTPClientOption) (*http.Client, error)
NewClientFromConfig returns a new HTTP client configured for the given config.HTTPClientConfig and config.HTTPClientOption. The name is used as go-conntrack metric label.
func NewOAuth2RoundTripper ¶
func NewOAuth2RoundTripper(config *OAuth2, next http.RoundTripper) http.RoundTripper
func NewRoundTripperFromConfig ¶
func NewRoundTripperFromConfig(cfg HTTPClientConfig, name string, optFuncs ...HTTPClientOption) (http.RoundTripper, error)
NewRoundTripperFromConfig returns a new HTTP RoundTripper configured for the given config.HTTPClientConfig and config.HTTPClientOption. The name is used as go-conntrack metric label.
func NewTLSConfig ¶
NewTLSConfig creates a new tls.Config from the given TLSConfig.
func NewTLSRoundTripper ¶
Types ¶
type Authorization ¶
type Authorization struct { Type string `yaml:"type,omitempty" json:"type,omitempty"` Credentials Secret `yaml:"credentials,omitempty" json:"credentials,omitempty"` CredentialsFile string `yaml:"credentials-file,omitempty" json:"credentials-file,omitempty"` }
Authorization contains HTTP authorization credentials.
func (*Authorization) SetDirectory ¶
func (a *Authorization) SetDirectory(dir string)
SetDirectory joins any relative file paths with dir.
type BasicAuth ¶
type BasicAuth struct { Username string `yaml:"username" json:"username"` Password Secret `yaml:"password,omitempty" json:"password,omitempty"` PasswordFile string `yaml:"password-file,omitempty" json:"password-file,omitempty"` }
BasicAuth contains basic HTTP authentication credentials.
func (*BasicAuth) SetDirectory ¶
SetDirectory joins any relative file paths with dir.
func (*BasicAuth) UnmarshalYAML ¶
UnmarshalYAML implements the yaml.Unmarshaler interface.
type Config ¶
type Config struct { // The job name to which the job label is set by default. JobName string `yaml:"job-name"` // How frequently to scrape the targets of this scrape config. ScrapeInterval time.Duration `yaml:"scrape-interval,omitempty"` // The timeout for scraping targets of this config. ScrapeTimeout time.Duration `yaml:"scrape-timeout,omitempty"` // The URL scheme with which to fetch metrics from targets. Scheme string `yaml:"scheme,omitempty"` // An uncompressed response body larger than this many bytes will cause the // scrape to fail. 0 means no limit. BodySizeLimit bytesize.ByteSize `yaml:"body-size-limit,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. ServiceDiscoveryConfigs discovery.Configs `yaml:"-"` HTTPClientConfig HTTPClientConfig `yaml:",inline"` // List of target relabel configurations. RelabelConfigs []*relabel.Config `yaml:"relabel-configs,omitempty"` // List of profiles to be scraped. EnabledProfiles []string `yaml:"enabled-profiles,omitempty"` // Profiles parameters. Profiles map[string]*Profile `yaml:"profiles,omitempty"` }
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns the default scrape configuration.
func (*Config) IsProfileEnabled ¶
IsProfileEnabled reports whether the given profile is enabled.
func (*Config) MarshalYAML ¶
MarshalYAML implements the yaml.Marshaler interface.
func (*Config) SetDirectory ¶
SetDirectory joins any relative file paths with dir.
func (*Config) UnmarshalYAML ¶
UnmarshalYAML implements the yaml.Unmarshaler interface.
type DialContextFunc ¶
DialContextFunc defines the signature of the DialContext() function implemented by net.Dialer.
type DirectorySetter ¶
type DirectorySetter interface { // SetDirectory joins any relative file paths with dir. // Any paths that are empty or absolute remain unchanged. SetDirectory(dir string) }
DirectorySetter is a config type that contains file paths that may be relative to the file containing the config.
type HTTPClientConfig ¶
type HTTPClientConfig struct { // The HTTP basic authentication credentials for the targets. BasicAuth *BasicAuth `yaml:"basic-auth,omitempty" json:"basic-auth,omitempty"` // The HTTP authorization credentials for the targets. Authorization *Authorization `yaml:"authorization,omitempty" json:"authorization,omitempty"` // The OAuth2 client credentials used to fetch a token for the targets. OAuth2 *OAuth2 `yaml:"oauth2,omitempty" json:"oauth2,omitempty"` // The bearer token for the targets. Deprecated in favour of // Authorization.Credentials. BearerToken Secret `yaml:"bearer-token,omitempty" json:"bearer-token,omitempty"` // The bearer token file for the targets. Deprecated in favour of // Authorization.CredentialsFile. BearerTokenFile string `yaml:"bearer-token-file,omitempty" json:"bearer-token-file,omitempty"` // HTTP proxy server to use to connect to the targets. ProxyURL URL `yaml:"proxy-url,omitempty" json:"proxy-url,omitempty"` // TLSConfig to use to connect to the targets. TLSConfig TLSConfig `yaml:"tls-config,omitempty" json:"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" json:"follow-redirects"` }
HTTPClientConfig configures an HTTP client.
func (*HTTPClientConfig) SetDirectory ¶
func (c *HTTPClientConfig) SetDirectory(dir string)
SetDirectory joins any relative file paths with dir.
func (HTTPClientConfig) String ¶
func (c HTTPClientConfig) String() string
func (*HTTPClientConfig) UnmarshalJSON ¶
func (c *HTTPClientConfig) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Marshaler interface for URL.
func (*HTTPClientConfig) UnmarshalYAML ¶
func (c *HTTPClientConfig) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML implements the yaml.Unmarshaler interface
func (*HTTPClientConfig) Validate ¶
func (c *HTTPClientConfig) Validate() error
Validate validates the HTTPClientConfig to check only one of BearerToken, BasicAuth and BearerTokenFile is configured.
type HTTPClientOption ¶
type HTTPClientOption func(options *httpClientOptions)
HTTPClientOption defines an option that can be applied to the HTTP client.
func WithDialContextFunc ¶
func WithDialContextFunc(fn DialContextFunc) HTTPClientOption
WithDialContextFunc allows you to override func gets used for the actual dialing. The default is `net.Dialer.DialContext`.
func WithHTTP2Disabled ¶
func WithHTTP2Disabled() HTTPClientOption
WithHTTP2Disabled allows to disable HTTP2.
func WithIdleConnTimeout ¶
func WithIdleConnTimeout(timeout time.Duration) HTTPClientOption
WithIdleConnTimeout allows setting the idle connection timeout.
func WithKeepAlivesDisabled ¶
func WithKeepAlivesDisabled() HTTPClientOption
WithKeepAlivesDisabled allows to disable HTTP keepalive.
type OAuth2 ¶
type OAuth2 struct { ClientID string `yaml:"client-id" json:"client-id"` ClientSecret Secret `yaml:"client-secret" json:"client-secret"` ClientSecretFile string `yaml:"client-secret-file" json:"client-secret-file"` Scopes []string `yaml:"scopes,omitempty" json:"scopes,omitempty"` TokenURL string `yaml:"token-url" json:"token-url"` EndpointParams map[string]string `yaml:"endpoint-params,omitempty" json:"endpoint-params,omitempty"` // TLSConfig is used to connect to the token URL. TLSConfig TLSConfig `yaml:"tls-config,omitempty"` }
OAuth2 is the oauth2 client configuration.
func (*OAuth2) SetDirectory ¶
SetDirectory joins any relative file paths with dir.
type Profile ¶
type Profile struct { Path string `yaml:"path,omitempty"` // A set of query parameters with which the target is scraped. Params url.Values `yaml:"params,omitempty"` // SampleTypes contains overrides for pprof sample types. SampleTypes map[string]*SampleTypeConfig `yaml:"sample-types,omitempty"` // AllSampleTypes specifies whether to parse samples of // types not listed in SampleTypes member. AllSampleTypes bool `yaml:"all-sample-types,omitempty"` }
type SampleTypeConfig ¶
type SampleTypeConfig struct { Units string `yaml:"units,omitempty"` DisplayName string `yaml:"display-name,omitempty"` // TODO(kolesnikovae): Introduce Kind? // In Go, we have at least the following combinations: // instant: Aggregation:avg && !Cumulative && !Sampled // cumulative: Aggregation:sum && Cumulative && !Sampled // delta: Aggregation:sum && !Cumulative && Sampled Aggregation string `yaml:"aggregation,omitempty"` Cumulative bool `yaml:"cumulative,omitempty"` Sampled bool `yaml:"sampled,omitempty"` }
type Secret ¶
type Secret string
Secret special type for storing secrets.
func (Secret) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface for Secret.
func (Secret) MarshalYAML ¶
MarshalYAML implements the yaml.Marshaler interface for Secrets.
func (*Secret) UnmarshalYAML ¶
UnmarshalYAML implements the yaml.Unmarshaler interface for Secrets.
type TLSConfig ¶
type TLSConfig struct { // The CA cert to use for the targets. CAFile string `yaml:"ca-file,omitempty" json:"ca-file,omitempty"` // The client cert file for the targets. CertFile string `yaml:"cert-file,omitempty" json:"cert-file,omitempty"` // The client key file for the targets. KeyFile string `yaml:"key-file,omitempty" json:"key-file,omitempty"` // Used to verify the hostname for the targets. ServerName string `yaml:"server-name,omitempty" json:"server-name,omitempty"` // Disable target certificate validation. InsecureSkipVerify bool `yaml:"insecure-skip-verify" json:"insecure-skip-verify"` }
TLSConfig configures the options for TLS connections.
func (*TLSConfig) SetDirectory ¶
SetDirectory joins any relative file paths with dir.
func (*TLSConfig) UnmarshalYAML ¶
UnmarshalYAML implements the yaml.Unmarshaler interface.
type URL ¶
URL is a custom URL type that allows validation at configuration load time.
func (URL) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface for URL.
func (URL) MarshalYAML ¶
MarshalYAML implements the yaml.Marshaler interface for URLs.
func (*URL) UnmarshalJSON ¶
UnmarshalJSON implements the json.Marshaler interface for URL.
func (*URL) UnmarshalYAML ¶
UnmarshalYAML implements the yaml.Unmarshaler interface for URLs.