prometheus

package
v0.64.1-rhobs3 Latest Latest
Warning

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

Go to latest
Published: May 9, 2023 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StorageDir   = "/prometheus"
	ConfDir      = "/etc/prometheus/config"
	ConfOutDir   = "/etc/prometheus/config_out"
	WebConfigDir = "/etc/prometheus/web_config"

	//TODO: RulesDir should be moved to the server package, since it is not used by the agent.
	// It is here at the moment because promcfg uses it, and moving as is will cause import cycle error.
	RulesDir = "/etc/prometheus/rules"

	ConfigFilename           = "prometheus.yaml.gz"
	ConfigEnvsubstFilename   = "prometheus.env.yaml"
	SSetInputHashName        = "prometheus-operator-input-hash"
	DefaultPortName          = "web"
	DefaultQueryLogDirectory = "/var/log/prometheus"
)

Variables

View Source
var (
	MinReplicas int32 = 1

	ManagedByOperatorLabels = map[string]string{
							// contains filtered or unexported fields
	}
	ShardLabelName                = "operator.prometheus.io/shard"
	PrometheusNameLabelName       = "operator.prometheus.io/name"
	PrometheusModeLabeLName       = "operator.prometheus.io/mode"
	ProbeTimeoutSeconds     int32 = 3
	LabelPrometheusName           = "prometheus-name"
)

Functions

func BuildCommonPrometheusArgs

func BuildCommonPrometheusArgs(cpf monitoringv1.CommonPrometheusFields, cg *ConfigGenerator, webRoutePrefix string) []monitoringv1.Argument

BuildCommonPrometheusArgs builds a slice of arguments that are common between Prometheus Server and Agent.

func BuildCommonVolumes

func BuildCommonVolumes(p monitoringv1.PrometheusInterface, tlsAssetSecrets []string) ([]v1.Volume, []v1.VolumeMount, error)

BuildCommonVolumes returns a set of volumes to be mounted on statefulset spec that are common between Prometheus Server and Agent

func CompareScrapeTimeoutToScrapeInterval

func CompareScrapeTimeoutToScrapeInterval(scrapeTimeout, scrapeInterval monitoringv1.Duration) error

CompareScrapeTimeoutToScrapeInterval validates value of scrapeTimeout based on scrapeInterval

func ExpectedStatefulSetShardNames

func ExpectedStatefulSetShardNames(
	p monitoringv1.PrometheusInterface,
) []string

func KeyToStatefulSetKey

func KeyToStatefulSetKey(p monitoringv1.PrometheusInterface, key string, shard int) string

func MakeConfigSecret

func MakeConfigSecret(p monitoringv1.PrometheusInterface, config operator.Config) *v1.Secret

func MakeEmptyConfigurationSecret

func MakeEmptyConfigurationSecret(p monitoringv1.PrometheusInterface, config operator.Config) (*v1.Secret, error)

func NewTLSAssetSecret

func NewTLSAssetSecret(p monitoringv1.PrometheusInterface, labels map[string]string) *v1.Secret

func ProbeHandler

func ProbeHandler(probePath string, cpf monitoringv1.CommonPrometheusFields, webConfigGenerator *ConfigGenerator, webRoutePrefix string) v1.ProbeHandler

func StatefulSetKeyToPrometheusKey

func StatefulSetKeyToPrometheusKey(key string) (bool, string)

func SubPathForStorage

func SubPathForStorage(s *monitoringv1.StorageSpec) string

TODO: Storage methods should be moved to server package. It is stil here because promcfg still uses it.

func TLSAssetsSecretName

func TLSAssetsSecretName(p monitoringv1.PrometheusInterface) string

func UsesDefaultQueryLogVolume

func UsesDefaultQueryLogVolume(queryLogFile string) bool

TODO: QueryLogFile methods should be moved to server package. They are still here because promcfg is using them.

func ValidateRemoteWriteSpec

func ValidateRemoteWriteSpec(spec monitoringv1.RemoteWriteSpec) error

ValidateRemoteWriteSpec checks that mutually exclusive configurations are not included in the Prometheus remoteWrite configuration section. Reference: https://github.com/prometheus/prometheus/blob/main/docs/configuration/configuration.md#remote_write

func WebConfigSecretName

func WebConfigSecretName(p monitoringv1.PrometheusInterface) string

Types

type Collector

type Collector struct {
	// contains filtered or unexported fields
}

func NewCollectorForStores

func NewCollectorForStores(s ...cache.Store) *Collector

func (*Collector) Collect

func (c *Collector) Collect(ch chan<- prometheus.Metric)

Collect implements the prometheus.Collector interface.

func (*Collector) Describe

func (c *Collector) Describe(ch chan<- *prometheus.Desc)

Describe implements the prometheus.Collector interface.

type ConfigGenerator

type ConfigGenerator struct {
	// contains filtered or unexported fields
}

ConfigGenerator knows how to generate a Prometheus configuration which is compatible with a given Prometheus version.

func NewConfigGenerator added in v0.23.0

func NewConfigGenerator(logger log.Logger, p v1.PrometheusInterface, endpointSliceSupported bool) (*ConfigGenerator, error)

NewConfigGenerator creates a ConfigGenerator for the provided Prometheus resource.

func (*ConfigGenerator) AddHonorLabels

func (cg *ConfigGenerator) AddHonorLabels(cfg yaml.MapSlice, honorLabels bool) yaml.MapSlice

AddHonorLabels adds the honor_labels field into scrape configurations. if OverrideHonorLabels is true then honor_labels is always false.

func (*ConfigGenerator) AddHonorTimestamps

func (cg *ConfigGenerator) AddHonorTimestamps(cfg yaml.MapSlice, userHonorTimestamps *bool) yaml.MapSlice

AddHonorTimestamps adds the honor_timestamps field into scrape configurations. honor_timestamps is false only when the user specified it or when the global override applies. For backwards compatibility with Prometheus <2.9.0 we don't set honor_timestamps.

func (*ConfigGenerator) AddLimitsToYAML

func (cg *ConfigGenerator) AddLimitsToYAML(cfg yaml.MapSlice, k limitKey, limit uint64, enforcedLimit *uint64) yaml.MapSlice

AddLimitsToYAML appends the given limit key to the configuration if supported by the Prometheus version.

func (*ConfigGenerator) AppendCommandlineArgument

func (cg *ConfigGenerator) AppendCommandlineArgument(m []monitoringv1.Argument, argument monitoringv1.Argument) []monitoringv1.Argument

AppendCommandlineArgument appends the name/v argument to the given []monitoringv1.Argument and returns the updated slice.

func (*ConfigGenerator) AppendMapItem

func (cg *ConfigGenerator) AppendMapItem(m yaml.MapSlice, k string, v interface{}) yaml.MapSlice

AppendMapItem appends the k/v item to the given yaml.MapSlice and returns the updated slice.

func (*ConfigGenerator) EndpointSliceSupported

func (cg *ConfigGenerator) EndpointSliceSupported() bool

func (*ConfigGenerator) GenerateAgentConfiguration

func (cg *ConfigGenerator) GenerateAgentConfiguration(
	sMons map[string]*v1.ServiceMonitor,
	pMons map[string]*v1.PodMonitor,
	probes map[string]*v1.Probe,
	store *assets.Store,
	additionalScrapeConfigs []byte,
) ([]byte, error)

GenerateAgentConfiguration creates a serialized YAML representation of a Prometheus Agent configuration using the provided resources.

func (*ConfigGenerator) GenerateServerConfiguration

func (cg *ConfigGenerator) GenerateServerConfiguration(
	evaluationInterval v1.Duration,
	queryLogFile string,
	ruleSelector *metav1.LabelSelector,
	exemplars *v1.Exemplars,
	tsdb v1.TSDBSpec,
	alerting *v1.AlertingSpec,
	remoteRead []v1.RemoteReadSpec,
	sMons map[string]*v1.ServiceMonitor,
	pMons map[string]*v1.PodMonitor,
	probes map[string]*v1.Probe,
	store *assets.Store,
	additionalScrapeConfigs []byte,
	additionalAlertRelabelConfigs []byte,
	additionalAlertManagerConfigs []byte,
	ruleConfigMapNames []string,
) ([]byte, error)

GenerateServerConfiguration creates a serialized YAML representation of a Prometheus Server configuration using the provided resources.

func (*ConfigGenerator) IsCompatible

func (cg *ConfigGenerator) IsCompatible() bool

IsCompatible return true or false depending if the version being used is compatible

func (*ConfigGenerator) Warn

func (cg *ConfigGenerator) Warn(field string)

Warn logs a warning.

func (*ConfigGenerator) WithKeyVals

func (cg *ConfigGenerator) WithKeyVals(keyvals ...interface{}) *ConfigGenerator

WithKeyVals returns a new ConfigGenerator with the same characteristics as the current object, expect that the keyvals are appended to the existing logger.

func (*ConfigGenerator) WithMaximumVersion

func (cg *ConfigGenerator) WithMaximumVersion(version string) *ConfigGenerator

WithMaximumVersion returns a new ConfigGenerator that does nothing (except logging a warning message) if the Prometheus version is greater than or equal to the given version. The method panics if version isn't a valid SemVer value.

func (*ConfigGenerator) WithMinimumVersion

func (cg *ConfigGenerator) WithMinimumVersion(version string) *ConfigGenerator

WithMinimumVersion returns a new ConfigGenerator that does nothing (except logging a warning message) if the Prometheus version is lesser than the given version. The method panics if version isn't a valid SemVer value.

type ListAllByNamespacer

type ListAllByNamespacer interface {
	ListAllByNamespace(namespace string, selector labels.Selector, appendFn cache.AppendFunc) error
}

type ResourceSelector

type ResourceSelector struct {
	// contains filtered or unexported fields
}

func NewResourceSelector

func NewResourceSelector(l log.Logger, p monitoringv1.PrometheusInterface, store *assets.Store, podMonitorLister ListAllByNamespacer, serviceMonitorLister ListAllByNamespacer, probeLister ListAllByNamespacer, namespaceInformers cache.SharedIndexInformer, metrics *operator.Metrics) *ResourceSelector

func (*ResourceSelector) SelectPodMonitors

func (rs *ResourceSelector) SelectPodMonitors(ctx context.Context) (map[string]*monitoringv1.PodMonitor, error)

SelectPodMonitors selects PodMonitors based on the selectors in the Prometheus CR and filters them returning only those with a valid configuration. This function also populates authentication stores and performs validations against scrape intervals and relabel configs.

func (*ResourceSelector) SelectProbes

func (rs *ResourceSelector) SelectProbes(ctx context.Context) (map[string]*monitoringv1.Probe, error)

SelectProbes selects Probes based on the selectors in the Prometheus CR and filters them returning only those with a valid configuration. This function also populates authentication stores and performs validations against scrape intervals, relabel configs and Probe URLs.

func (*ResourceSelector) SelectServiceMonitors

func (rs *ResourceSelector) SelectServiceMonitors(ctx context.Context) (map[string]*monitoringv1.ServiceMonitor, error)

SelectServiceMonitors selects ServiceMonitors based on the selectors in the Prometheus CR and filters them returning only those with a valid configuration. This function also populates authentication stores and performs validations against scrape intervals and relabel configs.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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