config

package
v0.0.0-...-594395b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 9, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Copyright 2025 The Prometheus Authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultModule set default configuration for the Module
	DefaultModule = Module{
		HTTP:      DefaultHTTPProbe,
		TCP:       DefaultTCPProbe,
		ICMP:      DefaultICMPProbe,
		DNS:       DefaultDNSProbe,
		Unix:      DefaultUnixProbe,
		Websocket: DefaultWebsocketProbe,
	}

	// DefaultHTTPProbe set default value for HTTPProbe
	DefaultHTTPProbe = HTTPProbe{
		IPProtocolFallback: true,
		HTTPClientConfig:   config.DefaultHTTPClientConfig,
	}

	// DefaultGRPCProbe set default value for GRPCProbe
	DefaultGRPCProbe = GRPCProbe{
		Service:            "",
		IPProtocolFallback: true,
	}

	// DefaultTCPProbe set default value for TCPProbe
	DefaultTCPProbe = TCPProbe{
		IPProtocolFallback: true,
	}

	// DefaultICMPProbe set default value for ICMPProbe
	DefaultICMPTTL   = 64
	DefaultICMPProbe = ICMPProbe{
		IPProtocolFallback: true,
		TTL:                DefaultICMPTTL,
	}

	// DefaultDNSProbe set default value for DNSProbe
	DefaultDNSProbe = DNSProbe{
		IPProtocolFallback: true,
		Recursion:          true,
	}

	// DefaultUnixProbe set default value for UnixProbe
	DefaultUnixProbe = UnixProbe{}

	// DefaultWebsocketProbe set default value for WebsocketProbe
	DefaultWebsocketProbe = WebsocketProbe{
		IPProtocolFallback: true,
	}
)

Functions

func GenerateChecksum

func GenerateChecksum(yamlFilePath string) (string, error)

Types

type CELProgram

type CELProgram struct {
	cel.Program
	Expression string
}

CELProgram encapsulates a cel.Program and makes it YAML marshalable.

func MustNewCELProgram

func MustNewCELProgram(s string) CELProgram

MustNewCELProgram works like NewCELProgram, but panics if the CEL expression does not compile.

func NewCELProgram

func NewCELProgram(s string) (CELProgram, error)

NewCELProgram creates a new CEL Program and returns an error if the passed-in CEL expression does not compile.

func (CELProgram) MarshalYAML

func (c CELProgram) MarshalYAML() (interface{}, error)

MarshalYAML implements the yaml.Marshaler interface.

func (*CELProgram) UnmarshalYAML

func (c *CELProgram) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

type Config

type Config struct {
	Modules map[string]Module `yaml:"modules"`
}

func (*Config) UnmarshalYAML

func (s *Config) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

type DNSProbe

type DNSProbe struct {
	IPProtocol         string           `yaml:"preferred_ip_protocol,omitempty"`
	IPProtocolFallback bool             `yaml:"ip_protocol_fallback,omitempty"`
	DNSOverTLS         bool             `yaml:"dns_over_tls,omitempty"`
	TLSConfig          config.TLSConfig `yaml:"tls_config,omitempty"`
	SourceIPAddress    string           `yaml:"source_ip_address,omitempty"`
	TransportProtocol  string           `yaml:"transport_protocol,omitempty"`
	QueryClass         string           `yaml:"query_class,omitempty"` // Defaults to IN.
	QueryName          string           `yaml:"query_name,omitempty"`
	QueryType          string           `yaml:"query_type,omitempty"`        // Defaults to ANY.
	Recursion          bool             `yaml:"recursion_desired,omitempty"` // Defaults to true.
	ValidRcodes        []string         `yaml:"valid_rcodes,omitempty"`      // Defaults to NOERROR.
	ValidateAnswer     DNSRRValidator   `yaml:"validate_answer_rrs,omitempty"`
	ValidateAuthority  DNSRRValidator   `yaml:"validate_authority_rrs,omitempty"`
	ValidateAdditional DNSRRValidator   `yaml:"validate_additional_rrs,omitempty"`
}

func (*DNSProbe) UnmarshalYAML

func (s *DNSProbe) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

type DNSRRValidator

type DNSRRValidator struct {
	FailIfMatchesRegexp     []string `yaml:"fail_if_matches_regexp,omitempty"`
	FailIfAllMatchRegexp    []string `yaml:"fail_if_all_match_regexp,omitempty"`
	FailIfNotMatchesRegexp  []string `yaml:"fail_if_not_matches_regexp,omitempty"`
	FailIfNoneMatchesRegexp []string `yaml:"fail_if_none_matches_regexp,omitempty"`
}

func (*DNSRRValidator) UnmarshalYAML

func (s *DNSRRValidator) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

type GRPCProbe

type GRPCProbe struct {
	Service             string           `yaml:"service,omitempty"`
	TLS                 bool             `yaml:"tls,omitempty"`
	TLSConfig           config.TLSConfig `yaml:"tls_config,omitempty"`
	IPProtocolFallback  bool             `yaml:"ip_protocol_fallback,omitempty"`
	PreferredIPProtocol string           `yaml:"preferred_ip_protocol,omitempty"`
	Metadata            metadata.MD      `yaml:"metadata,omitempty"`
}

func (*GRPCProbe) UnmarshalYAML

func (s *GRPCProbe) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

type HTTPProbe

type HTTPProbe struct {
	// Defaults to 2xx.
	ValidStatusCodes             []int                   `yaml:"valid_status_codes,omitempty"`
	ValidHTTPVersions            []string                `yaml:"valid_http_versions,omitempty"`
	IPProtocol                   string                  `yaml:"preferred_ip_protocol,omitempty"`
	IPProtocolFallback           bool                    `yaml:"ip_protocol_fallback,omitempty"`
	SkipResolvePhaseWithProxy    bool                    `yaml:"skip_resolve_phase_with_proxy,omitempty"`
	NoFollowRedirects            *bool                   `yaml:"no_follow_redirects,omitempty"`
	FailIfSSL                    bool                    `yaml:"fail_if_ssl,omitempty"`
	FailIfNotSSL                 bool                    `yaml:"fail_if_not_ssl,omitempty"`
	Method                       string                  `yaml:"method,omitempty"`
	Headers                      map[string]string       `yaml:"headers,omitempty"`
	FailIfBodyMatchesRegexp      []Regexp                `yaml:"fail_if_body_matches_regexp,omitempty"`
	FailIfBodyNotMatchesRegexp   []Regexp                `yaml:"fail_if_body_not_matches_regexp,omitempty"`
	FailIfBodyJsonMatchesCEL     *CELProgram             `yaml:"fail_if_body_json_matches_cel,omitempty"`
	FailIfBodyJsonNotMatchesCEL  *CELProgram             `yaml:"fail_if_body_json_not_matches_cel,omitempty"`
	FailIfHeaderMatchesRegexp    []HeaderMatch           `yaml:"fail_if_header_matches,omitempty"`
	FailIfHeaderNotMatchesRegexp []HeaderMatch           `yaml:"fail_if_header_not_matches,omitempty"`
	Body                         string                  `yaml:"body,omitempty"`
	BodyFile                     string                  `yaml:"body_file,omitempty"`
	HTTPClientConfig             config.HTTPClientConfig `yaml:"http_client_config,inline"`
	Compression                  string                  `yaml:"compression,omitempty"`
	BodySizeLimit                units.Base2Bytes        `yaml:"body_size_limit,omitempty"`
	UseHTTP3                     bool                    `yaml:"enable_http3,omitempty"`
}

func (*HTTPProbe) UnmarshalYAML

func (s *HTTPProbe) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

type HeaderMatch

type HeaderMatch struct {
	Header       string `yaml:"header,omitempty"`
	Regexp       Regexp `yaml:"regexp,omitempty"`
	AllowMissing bool   `yaml:"allow_missing,omitempty"`
}

func (*HeaderMatch) UnmarshalYAML

func (s *HeaderMatch) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

type ICMPProbe

type ICMPProbe struct {
	IPProtocol         string `yaml:"preferred_ip_protocol,omitempty"` // Defaults to "ip6".
	IPProtocolFallback bool   `yaml:"ip_protocol_fallback,omitempty"`
	SourceIPAddress    string `yaml:"source_ip_address,omitempty"`
	PayloadSize        int    `yaml:"payload_size,omitempty"`
	DontFragment       bool   `yaml:"dont_fragment,omitempty"`
	TTL                int    `yaml:"ttl,omitempty"`
}

func (*ICMPProbe) UnmarshalYAML

func (s *ICMPProbe) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

type Label

type Label struct {
	Name  string `yaml:"name,omitempty"`
	Value string `yaml:"value,omitempty"`
}

type Module

type Module struct {
	Prober    string         `yaml:"prober,omitempty"`
	Timeout   time.Duration  `yaml:"timeout,omitempty"`
	HTTP      HTTPProbe      `yaml:"http,omitempty"`
	TCP       TCPProbe       `yaml:"tcp,omitempty"`
	ICMP      ICMPProbe      `yaml:"icmp,omitempty"`
	DNS       DNSProbe       `yaml:"dns,omitempty"`
	GRPC      GRPCProbe      `yaml:"grpc,omitempty"`
	Unix      UnixProbe      `yaml:"unix,omitempty"`
	Websocket WebsocketProbe `yaml:"websocket,omitempty"`
}

func (*Module) UnmarshalYAML

func (s *Module) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

type QueryResponse

type QueryResponse struct {
	Expect      Regexp  `yaml:"expect,omitempty"`
	ExpectBytes string  `yaml:"expect_bytes,omitempty"`
	Labels      []Label `yaml:"labels,omitempty"`
	Send        string  `yaml:"send,omitempty"`
	StartTLS    bool    `yaml:"starttls,omitempty"`
}

func (*QueryResponse) UnmarshalYAML

func (s *QueryResponse) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

type Regexp

type Regexp struct {
	*regexp.Regexp
	// contains filtered or unexported fields
}

Regexp encapsulates a regexp.Regexp and makes it YAML marshalable.

func MustNewRegexp

func MustNewRegexp(s string) Regexp

MustNewRegexp works like NewRegexp, but panics if the regular expression does not compile.

func NewRegexp

func NewRegexp(s string) (Regexp, error)

NewRegexp creates a new anchored Regexp and returns an error if the passed-in regular expression does not compile.

func (Regexp) MarshalYAML

func (re Regexp) MarshalYAML() (interface{}, error)

MarshalYAML implements the yaml.Marshaler interface.

func (*Regexp) UnmarshalYAML

func (re *Regexp) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

type SafeConfig

type SafeConfig struct {
	sync.RWMutex
	C *Config
	// contains filtered or unexported fields
}

func NewSafeConfig

func NewSafeConfig(reg prometheus.Registerer) *SafeConfig

func (*SafeConfig) ReloadConfig

func (sc *SafeConfig) ReloadConfig(confFile string, logger *slog.Logger) (err error)

type TCPProbe

type TCPProbe struct {
	IPProtocol         string           `yaml:"preferred_ip_protocol,omitempty"`
	IPProtocolFallback bool             `yaml:"ip_protocol_fallback,omitempty"`
	SourceIPAddress    string           `yaml:"source_ip_address,omitempty"`
	QueryResponse      []QueryResponse  `yaml:"query_response,omitempty"`
	TLS                bool             `yaml:"tls,omitempty"`
	TLSConfig          config.TLSConfig `yaml:"tls_config,omitempty"`
}

func (*TCPProbe) UnmarshalYAML

func (s *TCPProbe) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

type UnixProbe

type UnixProbe struct {
	QueryResponse []QueryResponse  `yaml:"query_response,omitempty"`
	TLS           bool             `yaml:"tls,omitempty"`
	TLSConfig     config.TLSConfig `yaml:"tls_config,omitempty"`
}

func (*UnixProbe) UnmarshalYAML

func (s *UnixProbe) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

type WebsocketProbe

type WebsocketProbe struct {
	HTTPClientConfig   config.HTTPClientConfig `yaml:"http_config,omitempty"`
	Headers            config.Headers          `yaml:"headers,omitempty"`
	QueryResponse      []QueryResponse         `yaml:"query_response,omitempty"`
	IPProtocol         string                  `yaml:"preferred_ip_protocol,omitempty"`
	IPProtocolFallback bool                    `yaml:"ip_protocol_fallback,omitempty"`
}

func (*WebsocketProbe) UnmarshalYAML

func (s *WebsocketProbe) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL