Documentation
¶
Index ¶
- Constants
- Variables
- func AddAPIServerConfigToStore(ctx context.Context, store *assets.StoreBuilder, namespace string, ...) error
- func AddRemoteReadsToStore(ctx context.Context, store *assets.StoreBuilder, namespace string, ...) error
- func AddScrapeClassesToStore(ctx context.Context, store *assets.StoreBuilder, namespace string, ...) error
- func ApplyConfigurationFromPrometheus(p *monitoringv1.Prometheus, updateScaleSubresource bool) *monitoringv1ac.PrometheusApplyConfiguration
- func ApplyConfigurationFromPrometheusAgent(p *monitoringv1alpha1.PrometheusAgent, updateScaleSubresource bool) *monitoringv1alpha1ac.PrometheusAgentApplyConfiguration
- func BuildCommonVolumes(p monitoringv1.PrometheusInterface, tlsSecrets *operator.ShardedSecret, ...) ([]corev1.Volume, []corev1.VolumeMount, error)
- func BuildConfigReloader(p monitoringv1.PrometheusInterface, c Config, initContainer bool, ...) corev1.Container
- func BuildStatefulSetService(name string, selector map[string]string, p monitoringv1.PrometheusInterface, ...) *corev1.Service
- func BuildWebconfig(cpf monitoringv1.CommonPrometheusFields, p monitoringv1.PrometheusInterface) (monitoringv1.Argument, []corev1.Volume, []corev1.VolumeMount, error)
- func CompareScrapeTimeoutToScrapeInterval(scrapeTimeout, scrapeInterval monitoringv1.Duration) error
- func ConfigSecretName(p monitoringv1.PrometheusInterface) string
- func CreateConfigReloaderVolumeMounts() []corev1.VolumeMount
- func ExpectedStatefulSetShardNames(p monitoringv1.PrometheusInterface) []string
- func KeyToStatefulSetKey(p monitoringv1.PrometheusInterface, key string, shard int) string
- func LabelSelectorForStatefulSets(mode string) string
- func MakeConfigurationSecret(p monitoringv1.PrometheusInterface, config Config, data []byte) (*corev1.Secret, error)
- func MakeContainerPorts(cpf monitoringv1.CommonPrometheusFields) []corev1.ContainerPort
- func MakeExpectedLivenessProbe() *corev1.Probe
- func MakeExpectedReadinessProbe() *corev1.Probe
- func MakeExpectedStartupProbe() *corev1.Probe
- func MakeK8sTopologySpreadConstraint(selectorLabels map[string]string, tscs []monitoringv1.TopologySpreadConstraint) []corev1.TopologySpreadConstraint
- func NewLogger() *slog.Logger
- func NewTLSAssetSecret(p monitoringv1.PrometheusInterface, config Config) *corev1.Secret
- func Prefix(p monitoringv1.PrometheusInterface) string
- func PrefixedName(p monitoringv1.PrometheusInterface) string
- func ReplicasNumberPtr(p monitoringv1.PrometheusInterface) *int32
- func RetentionPercentageEnabled(retentionPercentage *resource.Quantity) bool
- func RetentionTimeOrDefault(retention monitoringv1.Duration, retentionSize monitoringv1.ByteSize, ...) monitoringv1.Duration
- func ShareProcessNamespace(p monitoringv1.PrometheusInterface) *bool
- func SubPathForStorage(s *monitoringv1.StorageSpec) string
- func TLSAssetsSecretName(p monitoringv1.PrometheusInterface) string
- func UnbalancedTopologyShardingMessage(p monitoringv1.PrometheusInterface) (bool, string)
- func UsesDefaultFileVolume(file string) bool
- func VolumeClaimName(p monitoringv1.PrometheusInterface, cpf monitoringv1.CommonPrometheusFields) string
- func VolumeName(p monitoringv1.PrometheusInterface) string
- func WebConfigSecretName(p monitoringv1.PrometheusInterface) string
- type Collector
- type Config
- type ConfigGenerator
- func (cg *ConfigGenerator) AddHonorLabels(cfg yaml.MapSlice, honorLabels bool) yaml.MapSlice
- func (cg *ConfigGenerator) AddHonorTimestamps(cfg yaml.MapSlice, userHonorTimestamps *bool) yaml.MapSlice
- func (cg *ConfigGenerator) AddLimitsToYAML(cfg yaml.MapSlice, k limitKey, limit *int64, enforcedLimit *int64) yaml.MapSlice
- func (cg *ConfigGenerator) AddRemoteWriteToStore(ctx context.Context, store *assets.StoreBuilder, namespace string, ...) error
- func (cg *ConfigGenerator) AddTrackTimestampsStaleness(cfg yaml.MapSlice, trackTimestampsStaleness *bool) yaml.MapSlice
- func (cg *ConfigGenerator) AppendCommandlineArgument(m []monitoringv1.Argument, argument monitoringv1.Argument) []monitoringv1.Argument
- func (cg *ConfigGenerator) AppendMapItem(m yaml.MapSlice, k string, v any) yaml.MapSlice
- func (cg *ConfigGenerator) BuildCommonPrometheusArgs() []monitoringv1.Argument
- func (cg *ConfigGenerator) BuildPodMetadata() (map[string]string, map[string]string)
- func (cg *ConfigGenerator) BuildProbes() (*corev1.Probe, *corev1.Probe, *corev1.Probe)
- func (cg *ConfigGenerator) GenerateAgentConfiguration(sMons map[string]*monitoringv1.ServiceMonitor, ...) ([]byte, error)
- func (cg *ConfigGenerator) GenerateRemoteWriteConfig(rws []monitoringv1.RemoteWriteSpec, s assets.StoreGetter) yaml.MapItem
- func (cg *ConfigGenerator) GenerateServerConfiguration(p *monitoringv1.Prometheus, sMons map[string]*monitoringv1.ServiceMonitor, ...) ([]byte, error)
- func (cg *ConfigGenerator) InzoneShardForShard(shardIndex int32) int32
- func (cg *ConfigGenerator) IsCompatible() bool
- func (cg *ConfigGenerator) NodeSelectorWithTopologyZone(shardIndex int32) map[string]string
- func (cg *ConfigGenerator) TopologyZoneForShard(shardIndex int32) string
- func (cg *ConfigGenerator) Version() semver.Version
- func (cg *ConfigGenerator) Warn(field string)
- func (cg *ConfigGenerator) WithKeyVals(keyvals ...any) *ConfigGenerator
- func (cg *ConfigGenerator) WithMaximumVersion(version string) *ConfigGenerator
- func (cg *ConfigGenerator) WithMinimumVersion(version string) *ConfigGenerator
- type ConfigGeneratorOption
- func WithDaemonSet() ConfigGeneratorOption
- func WithEndpointSliceSupport() ConfigGeneratorOption
- func WithInlineTLSConfig() ConfigGeneratorOption
- func WithPodTopologyLabelsSupport() ConfigGeneratorOption
- func WithPrometheusRetentionPolicies() ConfigGeneratorOption
- func WithPrometheusTopologySharding() ConfigGeneratorOption
- func WithoutVersionCheck() ConfigGeneratorOption
- type DeletionChecker
- type ListAllByNamespaceFn
- type ReconciledConditionGetter
- type ResourceSelector
- func (rs *ResourceSelector) SelectPodMonitors(ctx context.Context, listFn ListAllByNamespaceFn) (operator.TypedResourcesSelection[*monitoringv1.PodMonitor], error)
- func (rs *ResourceSelector) SelectProbes(ctx context.Context, listFn ListAllByNamespaceFn) (operator.TypedResourcesSelection[*monitoringv1.Probe], error)
- func (rs *ResourceSelector) SelectScrapeConfigs(ctx context.Context, listFn ListAllByNamespaceFn) (operator.TypedResourcesSelection[*monitoringv1alpha1.ScrapeConfig], error)
- func (rs *ResourceSelector) SelectServiceMonitors(ctx context.Context, listFn ListAllByNamespaceFn) (operator.TypedResourcesSelection[*monitoringv1.ServiceMonitor], error)
- func (rs *ResourceSelector) ValidateRelabelConfigs(rcs []monitoringv1.RelabelConfig) error
- type StatefulSetGetter
- type StatusReporter
Constants ¶
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. // nolint:godoclint RulesDir = "/etc/prometheus/rules" ConfigFilename = "prometheus.yaml.gz" ConfigEnvsubstFilename = "prometheus.env.yaml" DefaultPortName = "web" DefaultLogFileVolume = "log-file" DefaultLogDirectory = "/var/log/prometheus" DefaultRetention = "24h" // DefaultTerminationGracePeriodSeconds defines how long Kubernetes should // wait before killing Prometheus on pod termination. // Prometheus may take a significant time to shut down due to data // checkpointing. By default, the operator allows up to 10 minutes for // clean termination. DefaultTerminationGracePeriodSeconds = int64(600) )
Variables ¶
var ( // ShardLabelName is the statefulset's label identifying the Prometheus/PrometheusAgent resource's shard. ShardLabelName = "operator.prometheus.io/shard" // PrometheusNameLabelName is the statefulset's label identifying the Prometheus/PrometheusAgent resource. PrometheusNameLabelName = "operator.prometheus.io/name" // PrometheusModeLabelName is the statefulset's label identifying whether the owning resource is a Prometheus or PrometheusAgent. PrometheusModeLabelName = "operator.prometheus.io/mode" ProbeTimeoutSeconds int32 = 3 LabelPrometheusName = "prometheus-name" )
Functions ¶
func AddAPIServerConfigToStore ¶ added in v0.67.0
func AddAPIServerConfigToStore(ctx context.Context, store *assets.StoreBuilder, namespace string, config *monitoringv1.APIServerConfig) error
func AddRemoteReadsToStore ¶ added in v0.67.0
func AddRemoteReadsToStore(ctx context.Context, store *assets.StoreBuilder, namespace string, rrs []monitoringv1.RemoteReadSpec) error
AddRemoteReadsToStore loads all secret/configmap references from remote-read configs into the store.
func AddScrapeClassesToStore ¶ added in v0.72.0
func AddScrapeClassesToStore(ctx context.Context, store *assets.StoreBuilder, namespace string, scrapeClasses []monitoringv1.ScrapeClass) error
func ApplyConfigurationFromPrometheus ¶ added in v0.69.1
func ApplyConfigurationFromPrometheus(p *monitoringv1.Prometheus, updateScaleSubresource bool) *monitoringv1ac.PrometheusApplyConfiguration
ApplyConfigurationFromPrometheus updates the Prometheus/PrometheusAgent Status subresource. It can optionally update the scale subresource as well.
func ApplyConfigurationFromPrometheusAgent ¶ added in v0.69.1
func ApplyConfigurationFromPrometheusAgent(p *monitoringv1alpha1.PrometheusAgent, updateScaleSubresource bool) *monitoringv1alpha1ac.PrometheusAgentApplyConfiguration
func BuildCommonVolumes ¶ added in v0.64.0
func BuildCommonVolumes(p monitoringv1.PrometheusInterface, tlsSecrets *operator.ShardedSecret, statefulSet bool) ([]corev1.Volume, []corev1.VolumeMount, error)
BuildCommonVolumes returns a set of volumes to be mounted on the spec that are common between Prometheus Server and Agent.
func BuildConfigReloader ¶ added in v0.70.0
func BuildConfigReloader( p monitoringv1.PrometheusInterface, c Config, initContainer bool, mounts []corev1.VolumeMount, watchedDirectories []string, opts ...operator.ReloaderOption, ) corev1.Container
func BuildStatefulSetService ¶ added in v0.79.0
func BuildStatefulSetService(name string, selector map[string]string, p monitoringv1.PrometheusInterface, config Config) *corev1.Service
BuildStatefulSetService returns a governing service to be used for a statefulset.
func BuildWebconfig ¶ added in v0.75.0
func BuildWebconfig( cpf monitoringv1.CommonPrometheusFields, p monitoringv1.PrometheusInterface, ) (monitoringv1.Argument, []corev1.Volume, []corev1.VolumeMount, error)
func CompareScrapeTimeoutToScrapeInterval ¶ added in v0.64.0
func CompareScrapeTimeoutToScrapeInterval(scrapeTimeout, scrapeInterval monitoringv1.Duration) error
CompareScrapeTimeoutToScrapeInterval validates value of scrapeTimeout based on scrapeInterval.
func ConfigSecretName ¶ added in v0.64.0
func ConfigSecretName(p monitoringv1.PrometheusInterface) string
func CreateConfigReloaderVolumeMounts ¶ added in v0.75.0
func CreateConfigReloaderVolumeMounts() []corev1.VolumeMount
func ExpectedStatefulSetShardNames ¶ added in v0.64.0
func ExpectedStatefulSetShardNames( p monitoringv1.PrometheusInterface, ) []string
func KeyToStatefulSetKey ¶ added in v0.64.0
func KeyToStatefulSetKey(p monitoringv1.PrometheusInterface, key string, shard int) string
func LabelSelectorForStatefulSets ¶ added in v0.85.0
LabelSelectorForStatefulSets returns a label selector which selects statefulsets deployed with the server or agent mode.
func MakeConfigurationSecret ¶ added in v0.67.0
func MakeConfigurationSecret(p monitoringv1.PrometheusInterface, config Config, data []byte) (*corev1.Secret, error)
func MakeContainerPorts ¶ added in v0.75.0
func MakeContainerPorts(cpf monitoringv1.CommonPrometheusFields) []corev1.ContainerPort
func MakeExpectedLivenessProbe ¶ added in v0.75.0
func MakeExpectedReadinessProbe ¶ added in v0.75.0
func MakeExpectedStartupProbe ¶ added in v0.75.0
func MakeK8sTopologySpreadConstraint ¶ added in v0.71.0
func MakeK8sTopologySpreadConstraint(selectorLabels map[string]string, tscs []monitoringv1.TopologySpreadConstraint) []corev1.TopologySpreadConstraint
func NewTLSAssetSecret ¶ added in v0.64.0
func NewTLSAssetSecret(p monitoringv1.PrometheusInterface, config Config) *corev1.Secret
func Prefix ¶ added in v0.76.0
func Prefix(p monitoringv1.PrometheusInterface) string
func PrefixedName ¶ added in v0.76.0
func PrefixedName(p monitoringv1.PrometheusInterface) string
func ReplicasNumberPtr ¶ added in v0.67.0
func ReplicasNumberPtr( p monitoringv1.PrometheusInterface, ) *int32
ReplicasNumberPtr returns a ptr to the normalized number of replicas.
func RetentionPercentageEnabled ¶ added in v0.94.0
RetentionPercentageEnabled returns whether the given percentage-based retention is configured. A zero percentage means that percentage-based retention is disabled.
func RetentionTimeOrDefault ¶ added in v0.92.0
func RetentionTimeOrDefault(retention monitoringv1.Duration, retentionSize monitoringv1.ByteSize, retentionPercentage *resource.Quantity) monitoringv1.Duration
RetentionTimeOrDefault returns the configured time-based retention or the default retention when none of time, size and percentage are configured.
func ShareProcessNamespace ¶ added in v0.70.0
func ShareProcessNamespace(p monitoringv1.PrometheusInterface) *bool
func SubPathForStorage ¶ added in v0.64.0
func SubPathForStorage(s *monitoringv1.StorageSpec) string
SubPathForStorage is stil here because promcfg still uses it.
func TLSAssetsSecretName ¶ added in v0.64.0
func TLSAssetsSecretName(p monitoringv1.PrometheusInterface) string
func UnbalancedTopologyShardingMessage ¶ added in v0.95.0
func UnbalancedTopologyShardingMessage(p monitoringv1.PrometheusInterface) (bool, string)
UnbalancedTopologyShardingMessage returns true and a warning message when the resource uses topology sharding with a number of shards that isn't a multiple of the number of topology zones. In that case, shard indices wrap around and some targets end up being scraped by more than one shard, resulting in duplicated samples. It returns false and an empty string otherwise.
Callers are expected to only invoke it when the PrometheusTopologySharding feature gate is enabled.
func UsesDefaultFileVolume ¶ added in v0.80.0
func VolumeClaimName ¶ added in v0.66.0
func VolumeClaimName(p monitoringv1.PrometheusInterface, cpf monitoringv1.CommonPrometheusFields) string
func VolumeName ¶ added in v0.64.0
func VolumeName(p monitoringv1.PrometheusInterface) string
func WebConfigSecretName ¶ added in v0.49.0
func WebConfigSecretName(p monitoringv1.PrometheusInterface) string
Types ¶
type Collector ¶ added in v0.64.0
type Collector struct {
// contains filtered or unexported fields
}
func NewCollectorForStores ¶ added in v0.64.0
func (*Collector) Collect ¶ added in v0.64.0
func (c *Collector) Collect(ch chan<- prometheus.Metric)
Collect implements the prometheus.Collector interface.
func (*Collector) Describe ¶ added in v0.64.0
func (c *Collector) Describe(ch chan<- *prometheus.Desc)
Describe implements the prometheus.Collector interface.
type Config ¶
type Config struct {
LocalHost string
ReloaderConfig operator.ContainerConfig
PrometheusDefaultBaseImage string
ThanosDefaultBaseImage string
Annotations operator.Map
Labels operator.Map
WatchObjectRefsInAllNamespaces bool
}
Config defines the operator's parameters for the Prometheus controllers. Whenever the value of one of these parameters is changed, it triggers an update of the managed statefulsets.
type ConfigGenerator ¶ added in v0.48.0
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 *slog.Logger, p monitoringv1.PrometheusInterface, opts ...ConfigGeneratorOption, ) (*ConfigGenerator, error)
NewConfigGenerator creates a ConfigGenerator for the provided Prometheus resource.
func (*ConfigGenerator) AddHonorLabels ¶ added in v0.55.0
AddHonorLabels adds the honor_labels field into scrape configurations. if OverrideHonorLabels is true then honor_labels is always false.
func (*ConfigGenerator) AddHonorTimestamps ¶ added in v0.55.0
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 ¶ added in v0.55.0
func (cg *ConfigGenerator) AddLimitsToYAML(cfg yaml.MapSlice, k limitKey, limit *int64, enforcedLimit *int64) yaml.MapSlice
AddLimitsToYAML appends the given limit key to the configuration if supported by the Prometheus version.
func (*ConfigGenerator) AddRemoteWriteToStore ¶ added in v0.87.0
func (cg *ConfigGenerator) AddRemoteWriteToStore(ctx context.Context, store *assets.StoreBuilder, namespace string, rws []monitoringv1.RemoteWriteSpec) error
AddRemoteWriteToStore validates the remote-write configurations and loads all secret/configmap references into the store.
func (*ConfigGenerator) AddTrackTimestampsStaleness ¶ added in v0.70.0
func (cg *ConfigGenerator) AddTrackTimestampsStaleness(cfg yaml.MapSlice, trackTimestampsStaleness *bool) yaml.MapSlice
AddTrackTimestampsStaleness adds the track_timestamps_staleness field into scrape configurations. For backwards compatibility with Prometheus <2.48.0 we don't set track_timestamps_staleness.
func (*ConfigGenerator) AppendCommandlineArgument ¶ added in v0.62.0
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 ¶ added in v0.55.0
AppendMapItem appends the k/v item to the given yaml.MapSlice and returns the updated slice.
func (*ConfigGenerator) BuildCommonPrometheusArgs ¶ added in v0.78.0
func (cg *ConfigGenerator) BuildCommonPrometheusArgs() []monitoringv1.Argument
BuildCommonPrometheusArgs builds a slice of arguments that are common between Prometheus Server and Agent.
func (*ConfigGenerator) BuildPodMetadata ¶ added in v0.78.0
func (cg *ConfigGenerator) BuildPodMetadata() (map[string]string, map[string]string)
func (*ConfigGenerator) BuildProbes ¶ added in v0.78.0
BuildProbes returns a tuple of 3 probe definitions: 1. startup probe 2. readiness probe 3. liveness probe
The /-/ready handler returns OK only after the TSDB initialization has completed. The WAL replay can take a significant time for large setups hence we enable the startup probe with a generous failure threshold (15 minutes) to ensure that the readiness probe only comes into effect once Prometheus is effectively ready. We don't want to use the /-/healthy handler here because it returns OK as soon as the web server is started (irrespective of the WAL replay).
func (*ConfigGenerator) GenerateAgentConfiguration ¶ added in v0.64.0
func (cg *ConfigGenerator) GenerateAgentConfiguration( sMons map[string]*monitoringv1.ServiceMonitor, pMons map[string]*monitoringv1.PodMonitor, probes map[string]*monitoringv1.Probe, sCons map[string]*monitoringv1alpha1.ScrapeConfig, store *assets.StoreBuilder, additionalScrapeConfigs []byte, ) ([]byte, error)
GenerateAgentConfiguration creates a serialized YAML representation of a Prometheus Agent configuration using the provided resources.
func (*ConfigGenerator) GenerateRemoteWriteConfig ¶ added in v0.82.0
func (cg *ConfigGenerator) GenerateRemoteWriteConfig(rws []monitoringv1.RemoteWriteSpec, s assets.StoreGetter) yaml.MapItem
func (*ConfigGenerator) GenerateServerConfiguration ¶ added in v0.64.0
func (cg *ConfigGenerator) GenerateServerConfiguration( p *monitoringv1.Prometheus, sMons map[string]*monitoringv1.ServiceMonitor, pMons map[string]*monitoringv1.PodMonitor, probes map[string]*monitoringv1.Probe, sCons map[string]*monitoringv1alpha1.ScrapeConfig, store *assets.StoreBuilder, 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) InzoneShardForShard ¶ added in v0.91.0
func (cg *ConfigGenerator) InzoneShardForShard(shardIndex int32) int32
InzoneShardForShard returns floor(shardIndex / numZones), which is the position of the shard within its zone (0-indexed). Returns shardIndex unmodified when topology sharding is not active.
func (*ConfigGenerator) IsCompatible ¶ added in v0.62.0
func (cg *ConfigGenerator) IsCompatible() bool
IsCompatible return true or false depending if the version being used is compatible.
func (*ConfigGenerator) NodeSelectorWithTopologyZone ¶ added in v0.91.0
func (cg *ConfigGenerator) NodeSelectorWithTopologyZone(shardIndex int32) map[string]string
NodeSelectorWithTopologyZone returns the pod's node selector for the given shard index taking into account topology sharding if enabled.
func (*ConfigGenerator) TopologyZoneForShard ¶ added in v0.91.0
func (cg *ConfigGenerator) TopologyZoneForShard(shardIndex int32) string
TopologyZoneForShard returns the zone assigned to the shard index. It returns an empty string if topology sharding isn't enabled.
func (*ConfigGenerator) Version ¶ added in v0.78.0
func (cg *ConfigGenerator) Version() semver.Version
Version returns the currently configured Prometheus version.
func (*ConfigGenerator) Warn ¶ added in v0.62.0
func (cg *ConfigGenerator) Warn(field string)
Warn logs a warning.
func (*ConfigGenerator) WithKeyVals ¶ added in v0.55.0
func (cg *ConfigGenerator) WithKeyVals(keyvals ...any) *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 ¶ added in v0.55.0
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 ¶ added in v0.55.0
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 ConfigGeneratorOption ¶ added in v0.77.0
type ConfigGeneratorOption func(*ConfigGenerator)
func WithDaemonSet ¶ added in v0.77.0
func WithDaemonSet() ConfigGeneratorOption
func WithEndpointSliceSupport ¶ added in v0.77.0
func WithEndpointSliceSupport() ConfigGeneratorOption
func WithInlineTLSConfig ¶ added in v0.81.0
func WithInlineTLSConfig() ConfigGeneratorOption
WithInlineTLSConfig is an API only used by https://github.com/open-telemetry/opentelemetry-operator.
func WithPodTopologyLabelsSupport ¶ added in v0.92.0
func WithPodTopologyLabelsSupport() ConfigGeneratorOption
WithPodTopologyLabelsSupport tells the config generator that the topology.kubernetes.io/zone label is injected as a pod label. In that case, the operator no longer forces attach_metadata.node=true for topology sharding and instead uses the pod label for zone detection.
func WithPrometheusRetentionPolicies ¶ added in v0.91.0
func WithPrometheusRetentionPolicies() ConfigGeneratorOption
func WithPrometheusTopologySharding ¶ added in v0.80.0
func WithPrometheusTopologySharding() ConfigGeneratorOption
func WithoutVersionCheck ¶ added in v0.82.0
func WithoutVersionCheck() ConfigGeneratorOption
WithoutVersionCheck returns a ConfigGenerator which doesn't perform any version check.
type DeletionChecker ¶ added in v0.90.0
DeletionChecker returns true if the given object is being deleted.
type ListAllByNamespaceFn ¶ added in v0.65.1
type ReconciledConditionGetter ¶ added in v0.90.0
type ReconciledConditionGetter interface {
GetCondition(string, int64) monitoringv1.Condition
}
ReconciledConditionGetter returns the Reconciled condition for the workload resource identified by <namespace>/<name>. The second argument is the observed generation.
type ResourceSelector ¶ added in v0.64.0
type ResourceSelector struct {
// contains filtered or unexported fields
}
ResourceSelector knows how to select and verify scrape configuration resources that are matched by a Prometheus or PrometheusAgent object.
func NewResourceSelector ¶ added in v0.64.0
func NewResourceSelector( l *slog.Logger, p monitoringv1.PrometheusInterface, store *assets.StoreBuilder, namespaceInformers cache.SharedIndexInformer, metrics *operator.Metrics, eventRecorder *operator.EventRecorder, ) (*ResourceSelector, error)
func (*ResourceSelector) SelectPodMonitors ¶ added in v0.64.0
func (rs *ResourceSelector) SelectPodMonitors(ctx context.Context, listFn ListAllByNamespaceFn) (operator.TypedResourcesSelection[*monitoringv1.PodMonitor], error)
SelectPodMonitors returns the PodMonitors that match the selectors in the Prometheus custom resource. This function also populates authentication stores and performs validations against scrape intervals and relabel configs.
func (*ResourceSelector) SelectProbes ¶ added in v0.64.0
func (rs *ResourceSelector) SelectProbes(ctx context.Context, listFn ListAllByNamespaceFn) (operator.TypedResourcesSelection[*monitoringv1.Probe], error)
SelectProbes returns the probes matching the selectors specified in the Prometheus CR. This function also populates authentication stores and performs validations against scrape intervals, relabel configs and Probe URLs.
func (*ResourceSelector) SelectScrapeConfigs ¶ added in v0.65.0
func (rs *ResourceSelector) SelectScrapeConfigs(ctx context.Context, listFn ListAllByNamespaceFn) (operator.TypedResourcesSelection[*monitoringv1alpha1.ScrapeConfig], error)
SelectScrapeConfigs returns the ScrapeConfigs which match the selectors in the Prometheus CR and filters them returning all the configuration.
func (*ResourceSelector) SelectServiceMonitors ¶ added in v0.64.0
func (rs *ResourceSelector) SelectServiceMonitors(ctx context.Context, listFn ListAllByNamespaceFn) (operator.TypedResourcesSelection[*monitoringv1.ServiceMonitor], error)
SelectServiceMonitors returns the ServiceMonitors that match the selectors in the Prometheus custom resource. This function also populates authentication stores and performs validations against scrape intervals and relabel configs.
func (*ResourceSelector) ValidateRelabelConfigs ¶ added in v0.76.0
func (rs *ResourceSelector) ValidateRelabelConfigs(rcs []monitoringv1.RelabelConfig) error
type StatefulSetGetter ¶ added in v0.90.0
StatefulSetGetter returns a statefulset object identified by <namespace>/<name>.
type StatusReporter ¶ added in v0.66.0
type StatusReporter struct {
// contains filtered or unexported fields
}
StatusReporter reports the status for Prometheus and PrometheusAgent resources based on the state of the statefulsets and pods.
func NewStatusReporter ¶ added in v0.90.0
func NewStatusReporter(client kubernetes.Interface, rcg ReconciledConditionGetter, ssg StatefulSetGetter, dc DeletionChecker, repairPolicy operator.RepairPolicy) *StatusReporter
NewStatusReporter returns a new StatusReporter.
func (*StatusReporter) Process ¶ added in v0.66.0
func (sr *StatusReporter) Process(ctx context.Context, logger *slog.Logger, p monitoringv1.PrometheusInterface, key string) (*monitoringv1.PrometheusStatus, error)
Process will determine the Status of a Prometheus or PrometheusAgent resource depending on the current state of the underlying workload resources (including pods).