gmpmonitoring

package
v0.1.88 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: Apache-2.0 Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

GMP API data types

This package is a maintained API-only extraction from GoogleCloudPlatform/prometheus-engine. It contains PodMonitoring, Rules, their lists and the complete closure of nested data types, including status, authentication and TLS fields. Upstream license headers, field comments, JSON tags and generation markers are preserved. The generated upstream.sha256 records the resolved source version, upstream commit, module checksums and input file checksums.

Collection, rule evaluation, admission, Secret resolution and Prometheus config construction are excluded. The package imports only Kubernetes API machinery and the already selected prometheus/common/model package. It does not import the Google operator or require its Prometheus fork. Existing dependency versions stay unchanged. ClusterPodMonitoring, ClusterRules and GlobalRules are deferred; management rules spanning HCP namespaces require a separate rule-scope decision.

AddToScheme registers the four supported kinds. HyperShift adds them to both Scheme and AllMonitoringScheme regardless of process environment. Existing CoreOS/RHOBS registration remains unchanged. Registration creates no resources, clients or watches and does not select a backend at reconciliation time.

Maintenance

The GCP HCP team owns this API snapshot, its extraction tooling and compatibility validation. Changes to the package and tooling are reviewed by gcp-reviewers through the normal HyperShift review process.

The source version is selected in hack/gmp-api-source/go.mod. This is a download-only module; do not run go mod tidy there. HyperShift does not import the upstream operator package. Do not edit generated types, deepcopies or checksums by hand.

Version bumps are deliberate. The pin should track the GMP version deployed by GKE, not the latest upstream release, so renovate.json disables automated dependency updates for hack/gmp-api-source/go.mod. The regeneration tooling does not monitor upstream releases or establish compatibility with deployed GKE/GMP components.

Regenerate the current snapshot

From the repository root, with Go, Python 3 and Make available:

make gmp-sync
make verify-gmp-sync

Regenerating an unchanged source pin should produce no differences. The updater downloads the selected module in isolation, extracts the supported data types, copies the upstream license and CRD fixtures, records provenance and generates deepcopies with the repository's pinned controller-gen. It does not change HyperShift's root module or vendor directory. Ordinary make generate continues to regenerate deepcopies offline.

make verify-gmp-sync verifies the recorded inputs and regenerates into temporary storage. It fails on missing, different or unexpected generated files without rewriting tracked files. It runs as part of make lint (and therefore make verify-ci, make verify, and make verify-parallel), so a stale snapshot fails CI; run it manually after any GMP snapshot, tooling or dependency change to catch drift before pushing. make gmp-sync runs as part of make update. An offline unit test in hack/gmp-api-gen runs with the regular unit tests and fails if upstream.sha256 no longer matches the version and checksums pinned in hack/gmp-api-source.

Update to a newer upstream version
  1. Select a source version appropriate for the supported GKE/GMP environments and review its relevant API/schema changes with the GCP HCP team.

  2. Update the prometheus-engine requirement in hack/gmp-api-source/go.mod.

  3. Run make gmp-sync.

  4. Run make verify-gmp-sync and the focused tests:

    GO111MODULE=on GOWORK=off GOFLAGS=-mod=vendor go test -race \
      ./hack/gmp-api-gen ./support/gmpmonitoring
    
  5. Review the generated diff and include compatibility evidence in the PR.

Expected changes are limited to the source pin/checksums, generated provenance, API types, deepcopies, license and schema fixtures. Unexpected runtime dependencies or extraction failures require review by the owning team; do not work around them by editing generated files. The extractor follows the type closure plus the monitoring condition constant group only. If an added type requires another constant, extend the generator deliberately.

The pinned source is always downloaded with checksum database verification (GOSUMDB=sum.golang.org), regardless of local GOPRIVATE/GONOSUMDB settings. Generation fails if copied upstream source contains Go directives such as //go:generate or build constraints.

Compatibility checks

The copied source version does not need to numerically match the deployed GMP image version. Compatibility depends on the fields HyperShift emits and the schemas and behavior supported by the deployed components. Record the GKE version, GMP operator image and validation performed when assessing compatibility.

Tests cover scheme registration in fresh default (CoreOS) and RHOBS processes, actual HyperShift YAML/JSON serializer round trips (objects and lists, including status), deepcopy isolation and emitted objects against pinned upstream v1 OpenAPI schemas with negative controls. Schema fixtures are test input only; HyperShift does not install these CRDs.

Offline schema validation checks OpenAPI structure and constraints. It does not execute Kubernetes CEL validation or Google's admission/runtime checks. The pinned source is a serialization reference, not a claim that every deployed GKE cluster uses that schema. Live CRD compatibility, scrape behavior and rule evaluation require later validation against the selected GKE/GMP versions.

Documentation

Overview

Package gmpmonitoring contains upstream-derived monitoring.googleapis.com/v1 API data types only. Collection, admission and rule evaluation belong to GMP.

+kubebuilder:object:generate=true +groupName=monitoring.googleapis.com

Index

Constants

This section is empty.

Variables

View Source
var AddToScheme = SchemeBuilder.AddToScheme

AddToScheme registers GMP types without installing CRDs or starting watches.

View Source
var SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)

SchemeBuilder registers only the supported monitoring data objects.

View Source
var SchemeGroupVersion = schema.GroupVersion{Group: "monitoring.googleapis.com", Version: "v1"}

SchemeGroupVersion is the API version of the copied GMP types.

Functions

This section is empty.

Types

type Auth

type Auth struct {
	// Type is the authentication type. Defaults to Bearer.
	// Basic will cause an error, as the BasicAuth object should be used instead.
	// +kubebuilder:validation:XValidation:rule="self != 'Basic'",message="authorization type cannot be set to \"basic\", use \"basic_auth\" instead"
	// +optional
	Type string `json:"type,omitempty"`
	// Credentials uses the secret as the credentials (token) for the authentication header.
	// +optional
	Credentials *SecretSelector `json:"credentials,omitempty"`
}

Auth sets the `Authorization` header on every HTTP request.

func (*Auth) DeepCopy

func (in *Auth) DeepCopy() *Auth

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Auth.

func (*Auth) DeepCopyInto

func (in *Auth) DeepCopyInto(out *Auth)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type BasicAuth

type BasicAuth struct {
	// Username is the BasicAuth username.
	// +optional
	Username string `json:"username,omitempty"`
	// Password uses the secret as the BasicAuth password.
	// +optional
	Password *SecretSelector `json:"password,omitempty"`
}

BasicAuth sets the `Authorization` header on every HTTP request with the configured username and password.

func (*BasicAuth) DeepCopy

func (in *BasicAuth) DeepCopy() *BasicAuth

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BasicAuth.

func (*BasicAuth) DeepCopyInto

func (in *BasicAuth) DeepCopyInto(out *BasicAuth)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type HTTPClientConfig

type HTTPClientConfig struct {
	// Authorization is the HTTP authorization credentials for the targets.
	// +optional
	Authorization *Auth `json:"authorization,omitempty"`
	// BasicAuth is the HTTP basic authentication credentials for the targets.
	// +optional
	BasicAuth *BasicAuth `json:"basicAuth,omitempty"`
	// TLS configures the scrape request's TLS settings.
	// +optional
	TLS *TLS `json:"tls,omitempty"`
	// OAuth2 is the OAuth2 client credentials used to fetch a token for the targets.
	// +optional
	OAuth2      *OAuth2 `json:"oauth2,omitempty"`
	ProxyConfig `json:",inline"`
}

HTTPClientConfig stores HTTP-client configurations. +kubebuilder:validation:XValidation:rule="((has(self.authorization) ? 1 : 0) + (has(self.basicAuth) ? 1 : 0) + (has(self.oauth2) ? 1 : 0)) <= 1"

func (*HTTPClientConfig) DeepCopy

func (in *HTTPClientConfig) DeepCopy() *HTTPClientConfig

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HTTPClientConfig.

func (*HTTPClientConfig) DeepCopyInto

func (in *HTTPClientConfig) DeepCopyInto(out *HTTPClientConfig)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type LabelMapping

type LabelMapping struct {
	// Kubernetes resource label to remap.
	From string `json:"from"`
	// Remapped Prometheus target label.
	// Defaults to the same name as `From`.
	// +kubebuilder:validation:Pattern=^[a-zA-Z_][a-zA-Z0-9_]*$
	// +kubebuilder:validation:MaxLength:100
	// +kubebuilder:validation:XValidation:rule="self != 'project_id' && self != 'location' && self != 'cluster' && self != 'namespace' && self != 'job' && self != 'instance' && self != 'top_level_controller' && self != 'top_level_controller_type' && self != '__address__'",messageExpression="'cannot relabel onto protected label \"%s\"'.format([self])"
	To string `json:"to,omitempty"`
}

LabelMapping specifies how to transfer a label from a Kubernetes resource onto a Prometheus target.

func (*LabelMapping) DeepCopy

func (in *LabelMapping) DeepCopy() *LabelMapping

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LabelMapping.

func (*LabelMapping) DeepCopyInto

func (in *LabelMapping) DeepCopyInto(out *LabelMapping)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type MonitoringCondition

type MonitoringCondition struct {
	Type MonitoringConditionType `json:"type"`
	// Status of the condition, one of True, False, Unknown.
	Status corev1.ConditionStatus `json:"status"`
	// The last time this condition was updated.
	// +optional
	LastUpdateTime metav1.Time `json:"lastUpdateTime,omitempty"`
	// Last time the condition transitioned from one status to another.
	// +optional
	LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"`
	// The reason for the condition's last transition.
	// +optional
	Reason string `json:"reason,omitempty"`
	// A human-readable message indicating details about the transition.
	// +optional
	Message string `json:"message,omitempty"`
}

MonitoringCondition describes the condition of a PodMonitoring.

func (*MonitoringCondition) DeepCopy

func (in *MonitoringCondition) DeepCopy() *MonitoringCondition

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MonitoringCondition.

func (*MonitoringCondition) DeepCopyInto

func (in *MonitoringCondition) DeepCopyInto(out *MonitoringCondition)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type MonitoringConditionType

type MonitoringConditionType string

MonitoringConditionType is the type of MonitoringCondition.

const (
	// ConfigurationCreateSuccess indicates that the config generated from the
	// monitoring resource was created successfully.
	ConfigurationCreateSuccess MonitoringConditionType = "ConfigurationCreateSuccess"
)

type MonitoringStatus

type MonitoringStatus struct {
	// The generation observed by the controller.
	// +optional
	ObservedGeneration int64 `json:"observedGeneration"`
	// Represents the latest available observations of a podmonitor's current state.
	Conditions []MonitoringCondition `json:"conditions,omitempty"`
}

MonitoringStatus holds status information of a monitoring resource.

func (*MonitoringStatus) DeepCopy

func (in *MonitoringStatus) DeepCopy() *MonitoringStatus

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MonitoringStatus.

func (*MonitoringStatus) DeepCopyInto

func (in *MonitoringStatus) DeepCopyInto(out *MonitoringStatus)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type OAuth2

type OAuth2 struct {
	// ClientID is the public identifier for the client.
	// +optional
	ClientID string `json:"clientID"`
	// ClientSecret uses the secret as the client secret token.
	// +optional
	ClientSecret *SecretSelector `json:"clientSecret,omitempty"`
	// Scopes represents the scopes for the token request.
	// +optional
	Scopes []string `json:"scopes,omitempty"`
	// TokenURL is the URL to fetch the token from.
	// +optional
	TokenURL string `json:"tokenURL"`
	// EndpointParams are additional parameters to append to the token URL.
	// +optional
	EndpointParams map[string]string `json:"endpointParams,omitempty"`
	// TLS configures the token request's TLS settings.
	// +optional
	TLS         *TLS `json:"tlsConfig,omitempty"`
	ProxyConfig `json:",inline"`
}

OAuth2 is the OAuth2 client configuration.

func (*OAuth2) DeepCopy

func (in *OAuth2) DeepCopy() *OAuth2

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OAuth2.

func (*OAuth2) DeepCopyInto

func (in *OAuth2) DeepCopyInto(out *OAuth2)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type PodMonitoring

type PodMonitoring struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	// Specification of desired Pod selection for target discovery by
	// Prometheus.
	Spec PodMonitoringSpec `json:"spec"`
	// Most recently observed status of the resource.
	// +optional
	Status PodMonitoringStatus `json:"status"`
}

PodMonitoring defines monitoring for a set of pods, scoped to pods within the PodMonitoring's namespace. +genclient +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +kubebuilder:subresource:status +kubebuilder:storageversion +kubebuilder:validation:XValidation:rule="self.spec.endpoints.all(e, !has(e.authorization) || !has(e.authorization.credentials) || !has(e.authorization.credentials.secret) || !has(e.authorization.credentials.secret.__namespace__))",message="Namespace not allowed on PodMonitoring secret references.",reason="FieldValueForbidden" +kubebuilder:validation:XValidation:rule="self.spec.endpoints.all(e, !has(e.basicAuth) || !has(e.basicAuth.password) || !has(e.basicAuth.password.secret) || !has(e.basicAuth.password.secret.__namespace__))",message="Namespace not allowed on PodMonitoring secret references.",reason="FieldValueForbidden" +kubebuilder:validation:XValidation:rule="self.spec.endpoints.all(e, !has(e.tls) || !has(e.tls.ca) || !has(e.tls.ca.secret) || !has(e.tls.ca.secret.__namespace__))",message="Namespace not allowed on PodMonitoring secret references.",reason="FieldValueForbidden" +kubebuilder:validation:XValidation:rule="self.spec.endpoints.all(e, !has(e.tls) || !has(e.tls.cert) || !has(e.tls.cert.secret) || !has(e.tls.cert.secret.__namespace__))",message="Namespace not allowed on PodMonitoring secret references.",reason="FieldValueForbidden" +kubebuilder:validation:XValidation:rule="self.spec.endpoints.all(e, !has(e.tls) || !has(e.tls.key) || !has(e.tls.key.secret) || !has(e.tls.key.secret.__namespace__))",message="Namespace not allowed on PodMonitoring secret references.",reason="FieldValueForbidden" +kubebuilder:validation:XValidation:rule="self.spec.endpoints.all(e, !has(e.oauth2) || !has(e.oauth2.clientSecret) || !has(e.oauth2.clientSecret.secret) || !has(e.oauth2.clientSecret.secret.__namespace__))",message="Namespace not allowed on PodMonitoring secret references.",reason="FieldValueForbidden"

func (*PodMonitoring) DeepCopy

func (in *PodMonitoring) DeepCopy() *PodMonitoring

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodMonitoring.

func (*PodMonitoring) DeepCopyInto

func (in *PodMonitoring) DeepCopyInto(out *PodMonitoring)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*PodMonitoring) DeepCopyObject

func (in *PodMonitoring) DeepCopyObject() runtime.Object

DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.

type PodMonitoringList

type PodMonitoringList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []PodMonitoring `json:"items"`
}

PodMonitoringList is a list of PodMonitorings. +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

func (*PodMonitoringList) DeepCopy

func (in *PodMonitoringList) DeepCopy() *PodMonitoringList

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodMonitoringList.

func (*PodMonitoringList) DeepCopyInto

func (in *PodMonitoringList) DeepCopyInto(out *PodMonitoringList)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*PodMonitoringList) DeepCopyObject

func (in *PodMonitoringList) DeepCopyObject() runtime.Object

DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.

type PodMonitoringSpec

type PodMonitoringSpec struct {
	// Label selector that specifies which pods are selected for this monitoring
	// configuration.
	Selector metav1.LabelSelector `json:"selector"`
	// The endpoints to scrape on the selected pods.
	// +kubebuilder:validation:MinItems=1
	// +kubebuilder:validation:MaxItems=10
	Endpoints []ScrapeEndpoint `json:"endpoints"`
	// Labels to add to the Prometheus target for discovered endpoints.
	// The `instance` label is always set to `<pod_name>:<port>` or `<node_name>:<port>`
	// if the scraped pod is controlled by a DaemonSet.
	TargetLabels TargetLabels `json:"targetLabels,omitempty"`
	// Limits to apply at scrape time.
	Limits *ScrapeLimits `json:"limits,omitempty"`
	// FilterRunning will drop any pods that are in the "Failed" or "Succeeded"
	// pod lifecycle.
	// See: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-phase
	FilterRunning *bool `json:"filterRunning,omitempty"`
}

PodMonitoringSpec contains specification parameters for PodMonitoring.

func (*PodMonitoringSpec) DeepCopy

func (in *PodMonitoringSpec) DeepCopy() *PodMonitoringSpec

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodMonitoringSpec.

func (*PodMonitoringSpec) DeepCopyInto

func (in *PodMonitoringSpec) DeepCopyInto(out *PodMonitoringSpec)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type PodMonitoringStatus

type PodMonitoringStatus struct {
	MonitoringStatus `json:",inline"`
	// Represents the latest available observations of target state for each ScrapeEndpoint.
	EndpointStatuses []ScrapeEndpointStatus `json:"endpointStatuses,omitempty"`
}

PodMonitoringStatus holds status information of a PodMonitoring resource.

func (*PodMonitoringStatus) DeepCopy

func (in *PodMonitoringStatus) DeepCopy() *PodMonitoringStatus

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodMonitoringStatus.

func (*PodMonitoringStatus) DeepCopyInto

func (in *PodMonitoringStatus) DeepCopyInto(out *PodMonitoringStatus)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type ProxyConfig

type ProxyConfig struct {
	// ProxyURL is the HTTP proxy server to use to connect to the targets.
	//
	// Encoded passwords are not supported.
	// +optional
	// +kubebuilder:validation:MaxLength=2000
	// +kubebuilder:validation:XValidation:rule="isURL(self) && !self.matches('@')"
	ProxyURL string `json:"proxyUrl,omitempty"`
}

ProxyConfig specifies the proxy HTTP configuration.

func (*ProxyConfig) DeepCopy

func (in *ProxyConfig) DeepCopy() *ProxyConfig

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ProxyConfig.

func (*ProxyConfig) DeepCopyInto

func (in *ProxyConfig) DeepCopyInto(out *ProxyConfig)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type RelabelingRule

type RelabelingRule struct {
	// The source labels select values from existing labels. Their content is concatenated
	// using the configured separator and matched against the configured regular expression
	// for the replace, keep, and drop actions.
	// +kubebuilder:validation:MaxItems=100
	// +kubebuilder:validation:items:Pattern=^[a-zA-Z_][a-zA-Z0-9_]*$
	SourceLabels []string `json:"sourceLabels,omitempty"`
	// Separator placed between concatenated source label values. Defaults to ';'.
	Separator string `json:"separator,omitempty"`
	// Label to which the resulting value is written in a replace action.
	// It is mandatory for replace actions. Regex capture groups are available.
	// +kubebuilder:validation:Pattern=^[a-zA-Z_][a-zA-Z0-9_]*$
	// +kubebuilder:validation:MaxLength:100
	// +kubebuilder:validation:XValidation:rule="self != 'project_id' && self != 'location' && self != 'cluster' && self != 'namespace' && self != 'job' && self != 'instance' && self != 'top_level_controller' && self != 'top_level_controller_type' && self != '__address__'",messageExpression="'cannot relabel onto protected label \"%s\"'.format([self])"
	TargetLabel string `json:"targetLabel,omitempty"`
	// Regular expression against which the extracted value is matched. Defaults to '(.*)'.
	// +kubebuilder:validation:MaxLength=10000
	Regex string `json:"regex,omitempty"`
	// Modulus to take of the hash of the source label values.
	Modulus uint64 `json:"modulus,omitempty"`
	// Replacement value against which a regex replace is performed if the
	// regular expression matches. Regex capture groups are available. Defaults to '$1'.
	Replacement string `json:"replacement,omitempty"`
	// Action to perform based on regex matching. Defaults to 'replace'.
	// +kubebuilder:validation:Enum=replace;lowercase;uppercase;keep;drop;keepequal;dropequal;hashmod;labeldrop;labelkeep
	Action string `json:"action,omitempty"`
}

RelabelingRule defines a single Prometheus relabeling rule. +kubebuilder:validation:XValidation:rule="!has(self.action) || self.action != 'labeldrop' || has(self.regex)"

func (*RelabelingRule) DeepCopy

func (in *RelabelingRule) DeepCopy() *RelabelingRule

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RelabelingRule.

func (*RelabelingRule) DeepCopyInto

func (in *RelabelingRule) DeepCopyInto(out *RelabelingRule)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type Rule

type Rule struct {
	// Record the result of the expression to this metric name.
	// Only one of `record` and `alert` must be set.
	// +kubebuilder:validation:Pattern="^[a-zA-Z_:][a-zA-Z0-9_:]*$"
	Record string `json:"record,omitempty"`
	// Name of the alert to evaluate the expression as.
	// Only one of `record` and `alert` must be set.
	Alert string `json:"alert,omitempty"`
	// The PromQL expression to evaluate.
	Expr string `json:"expr"`
	// The duration to wait before a firing alert produced by this rule is sent to Alertmanager.
	// Only valid if `alert` is set.
	// +kubebuilder:validation:Format=duration
	For string `json:"for,omitempty"`
	// A set of labels to attach to the result of the query expression.
	Labels map[string]string `json:"labels,omitempty"`
	// A set of annotations to attach to alerts produced by the query expression.
	// Only valid if `alert` is set.
	Annotations map[string]string `json:"annotations,omitempty"`
}

Rule is a single rule in the Prometheus format: https://prometheus.io/docs/prometheus/latest/configuration/recording_rules/ +kubebuilder:validation:XValidation:rule="(has(self.record) ? 1 : 0) + (has(self.alert) ? 1 : 0) == 1",message="Must set exactly one of Record or Alert" +kubebuilder:validation:XValidation:rule="!has(self.annotations) || has(self.alert)",message="Annotations are only allowed for alerting rules"

func (*Rule) DeepCopy

func (in *Rule) DeepCopy() *Rule

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Rule.

func (*Rule) DeepCopyInto

func (in *Rule) DeepCopyInto(out *Rule)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type RuleGroup

type RuleGroup struct {
	// The name of the rule group.
	Name string `json:"name"`
	// The interval at which to evaluate the rules. Must be a valid Prometheus duration.
	// +kubebuilder:validation:Format=duration
	// +kubebuilder:default="1m"
	Interval string `json:"interval,omitempty"`
	// A list of rules that are executed sequentially as part of this group.
	// +kubebuilder:validation:MinItems=1
	Rules []Rule `json:"rules"`
}

RuleGroup declares rules in the Prometheus format: https://prometheus.io/docs/prometheus/latest/configuration/recording_rules/

func (*RuleGroup) DeepCopy

func (in *RuleGroup) DeepCopy() *RuleGroup

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RuleGroup.

func (*RuleGroup) DeepCopyInto

func (in *RuleGroup) DeepCopyInto(out *RuleGroup)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type Rules

type Rules struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	// Specification of rules to record and alert on.
	Spec RulesSpec `json:"spec"`
	// Most recently observed status of the resource.
	// +optional
	Status RulesStatus `json:"status"`
}

Rules defines Prometheus alerting and recording rules that are scoped to the namespace of the resource. Only metric data from this namespace is processed and all rule results have their project_id, cluster, and namespace label preserved for query processing. If the location label is not preserved by the rule, it defaults to the cluster's location.

+genclient +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +kubebuilder:subresource:status +kubebuilder:storageversion

func (*Rules) DeepCopy

func (in *Rules) DeepCopy() *Rules

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Rules.

func (*Rules) DeepCopyInto

func (in *Rules) DeepCopyInto(out *Rules)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*Rules) DeepCopyObject

func (in *Rules) DeepCopyObject() runtime.Object

DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.

type RulesList

type RulesList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []Rules `json:"items"`
}

RulesList is a list of Rules. +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

func (*RulesList) DeepCopy

func (in *RulesList) DeepCopy() *RulesList

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RulesList.

func (*RulesList) DeepCopyInto

func (in *RulesList) DeepCopyInto(out *RulesList)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*RulesList) DeepCopyObject

func (in *RulesList) DeepCopyObject() runtime.Object

DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.

type RulesSpec

type RulesSpec struct {
	// A list of Prometheus rule groups.
	Groups []RuleGroup `json:"groups"`
}

RulesSpec contains specification parameters for a Rules resource.

func (*RulesSpec) DeepCopy

func (in *RulesSpec) DeepCopy() *RulesSpec

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RulesSpec.

func (*RulesSpec) DeepCopyInto

func (in *RulesSpec) DeepCopyInto(out *RulesSpec)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type RulesStatus

type RulesStatus struct {
	MonitoringStatus `json:",inline"`
}

RulesStatus contains status information for a Rules resource.

func (*RulesStatus) DeepCopy

func (in *RulesStatus) DeepCopy() *RulesStatus

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RulesStatus.

func (*RulesStatus) DeepCopyInto

func (in *RulesStatus) DeepCopyInto(out *RulesStatus)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type SampleGroup

type SampleGroup struct {
	// Targets emitting the error message.
	SampleTargets []SampleTarget `json:"sampleTargets,omitempty"`
	// Total count of similar errors.
	// +optional
	Count *int32 `json:"count,omitempty"`
}

func (*SampleGroup) DeepCopy

func (in *SampleGroup) DeepCopy() *SampleGroup

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SampleGroup.

func (*SampleGroup) DeepCopyInto

func (in *SampleGroup) DeepCopyInto(out *SampleGroup)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type SampleTarget

type SampleTarget struct {
	// The label set, keys and values, of the target.
	Labels prommodel.LabelSet `json:"labels,omitempty"`
	// Error message.
	LastError *string `json:"lastError,omitempty"`
	// Scrape duration in seconds.
	LastScrapeDurationSeconds string `json:"lastScrapeDurationSeconds,omitempty"`
	// Health status.
	Health string `json:"health,omitempty"`
}

func (*SampleTarget) DeepCopy

func (in *SampleTarget) DeepCopy() *SampleTarget

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SampleTarget.

func (*SampleTarget) DeepCopyInto

func (in *SampleTarget) DeepCopyInto(out *SampleTarget)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type ScrapeEndpoint

type ScrapeEndpoint struct {
	// Name or number of the port to scrape.
	// The container metadata label is only populated if the port is referenced by name
	// because port numbers are not unique across containers.
	// +kubebuilder:validation:XIntOrString
	// +kubebuilder:validation:MinLength=1
	// +kubebuilder:validation:MaxLength=253
	// +kubebuilder:validation:XValidation:rule="self != 0",message="Port is required"
	// +required
	Port intstr.IntOrString `json:"port,omitempty"`
	// Protocol scheme to use to scrape.
	// +kubebuilder:validation:Enum=http;https
	Scheme string `json:"scheme,omitempty"`
	// HTTP path to scrape metrics from. Defaults to "/metrics".
	Path string `json:"path,omitempty"`
	// HTTP GET params to use when scraping.
	Params map[string][]string `json:"params,omitempty"`
	// Interval at which to scrape metrics. Must be a valid Prometheus duration.
	// +kubebuilder:validation:Format=duration
	// +required
	Interval string `json:"interval"`
	// Timeout for metrics scrapes. Must be a valid Prometheus duration.
	// Must not be larger than the scrape interval.
	// +kubebuilder:validation:Format=duration
	Timeout string `json:"timeout,omitempty"`
	// Relabeling rules for metrics scraped from this endpoint. Relabeling rules that
	// override protected target labels (project_id, location, cluster, namespace, job,
	// instance, top_level_controller, top_level_controller_type, or __address__) are
	// not permitted. The labelmap action is not permitted in general.
	// +kubebuilder:validation:MaxItems=250
	MetricRelabeling []RelabelingRule `json:"metricRelabeling,omitempty"`
	// Prometheus HTTP client configuration.
	HTTPClientConfig `json:",inline"`
}

ScrapeEndpoint specifies a Prometheus metrics endpoint to scrape. +kubebuilder:validation:XValidation:rule="!has(self.timeout) || self.timeout <= self.interval",messageExpression="'scrape timeout (%s) must not be greater than scrape interval (%s)'.format([self.timeout, self.interval])"

func (*ScrapeEndpoint) DeepCopy

func (in *ScrapeEndpoint) DeepCopy() *ScrapeEndpoint

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ScrapeEndpoint.

func (*ScrapeEndpoint) DeepCopyInto

func (in *ScrapeEndpoint) DeepCopyInto(out *ScrapeEndpoint)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type ScrapeEndpointStatus

type ScrapeEndpointStatus struct {
	// The name of the ScrapeEndpoint.
	Name string `json:"name"`
	// Total number of active targets.
	ActiveTargets int64 `json:"activeTargets,omitempty"`
	// Total number of active, unhealthy targets.
	UnhealthyTargets int64 `json:"unhealthyTargets,omitempty"`
	// Last time this status was updated.
	LastUpdateTime metav1.Time `json:"lastUpdateTime,omitempty"`
	// A fixed sample of targets grouped by error type.
	SampleGroups []SampleGroup `json:"sampleGroups,omitempty"`
	// Fraction of collectors included in status, bounded [0,1].
	// Ideally, this should always be 1. Anything less can
	// be considered a problem and should be investigated.
	CollectorsFraction string `json:"collectorsFraction,omitempty"`
}

func (*ScrapeEndpointStatus) DeepCopy

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ScrapeEndpointStatus.

func (*ScrapeEndpointStatus) DeepCopyInto

func (in *ScrapeEndpointStatus) DeepCopyInto(out *ScrapeEndpointStatus)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type ScrapeLimits

type ScrapeLimits struct {
	// Maximum number of samples accepted within a single scrape.
	// Uses Prometheus default if left unspecified.
	Samples uint64 `json:"samples,omitempty"`
	// Maximum number of labels accepted for a single sample.
	// Uses Prometheus default if left unspecified.
	Labels uint64 `json:"labels,omitempty"`
	// Maximum label name length.
	// Uses Prometheus default if left unspecified.
	LabelNameLength uint64 `json:"labelNameLength,omitempty"`
	// Maximum label value length.
	// Uses Prometheus default if left unspecified.
	LabelValueLength uint64 `json:"labelValueLength,omitempty"`
}

ScrapeLimits limits applied to scraped targets.

func (*ScrapeLimits) DeepCopy

func (in *ScrapeLimits) DeepCopy() *ScrapeLimits

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ScrapeLimits.

func (*ScrapeLimits) DeepCopyInto

func (in *ScrapeLimits) DeepCopyInto(out *ScrapeLimits)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type SecretKeySelector

type SecretKeySelector struct {
	// Name of the secret to select from.
	Name string `json:"name"`

	// Key of the secret to select from. Must be a valid secret key.
	Key string `json:"key"`

	// Namespace of the secret to select from.
	// If empty the parent resource namespace will be chosen.
	// +optional
	Namespace string `json:"namespace,omitempty"`
}

SecretKeySelector represents selector for Kubernetes secret. It's similar to k8s.io/api/core/v1.SecretKeySelector, but allows cross namespace selections.

func (*SecretKeySelector) DeepCopy

func (in *SecretKeySelector) DeepCopy() *SecretKeySelector

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecretKeySelector.

func (*SecretKeySelector) DeepCopyInto

func (in *SecretKeySelector) DeepCopyInto(out *SecretKeySelector)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type SecretSelector

type SecretSelector struct {
	// Secret represents reference to a given key from certain Secret in a given namespace.
	// +optional
	Secret *SecretKeySelector `json:"secret,omitempty"`
}

SecretSelector references a secret from a secret provider e.g. Kubernetes Secret. Only one provider can be used at a time.

func (*SecretSelector) DeepCopy

func (in *SecretSelector) DeepCopy() *SecretSelector

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecretSelector.

func (*SecretSelector) DeepCopyInto

func (in *SecretSelector) DeepCopyInto(out *SecretSelector)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type TLS

type TLS struct {
	// ServerName is used to verify the hostname for the targets.
	// +optional
	ServerName string `json:"serverName,omitempty"`
	// InsecureSkipVerify disables target certificate validation.
	// +optional
	InsecureSkipVerify bool `json:"insecureSkipVerify,omitempty"`
	// MinVersion is the minimum TLS version. Accepted values: TLS10 (TLS 1.0), TLS11 (TLS 1.1),
	// TLS12 (TLS 1.2), TLS13 (TLS 1.3).
	//
	// If unset, Prometheus will use Go default minimum version, which is TLS 1.2.
	// See MinVersion in https://pkg.go.dev/crypto/tls#Config.
	// +kubebuilder:validation:Enum=TLS10;TLS11;TLS12;TLS13
	// +optional
	MinVersion string `json:"minVersion,omitempty"`
	// MaxVersion is the maximum TLS version. Accepted values: TLS10 (TLS 1.0), TLS11 (TLS 1.1),
	// TLS12 (TLS 1.2), TLS13 (TLS 1.3).
	//
	// If unset, Prometheus will use Go default minimum version, which is TLS 1.2.
	// See MinVersion in https://pkg.go.dev/crypto/tls#Config.
	// +kubebuilder:validation:Enum=TLS10;TLS11;TLS12;TLS13
	// +optional
	MaxVersion string `json:"maxVersion,omitempty"`

	CA *SecretSelector `json:"ca,omitempty"`
	// Cert uses the secret as the certificate for client authentication to the server.
	// +optional
	Cert *SecretSelector `json:"cert,omitempty"`
	// Key uses the secret as the private key for client authentication to the server.
	// +optional
	Key *SecretSelector `json:"key,omitempty"`
}

TLS specifies TLS configuration used for HTTP requests. +kubebuilder:validation:XValidation:rule=has(self.cert) == has(self.key),message="client cert and client key must be provided together, when either is provided"

func (*TLS) DeepCopy

func (in *TLS) DeepCopy() *TLS

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TLS.

func (*TLS) DeepCopyInto

func (in *TLS) DeepCopyInto(out *TLS)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type TargetLabels

type TargetLabels struct {
	// Pod metadata labels that are set on all scraped targets.
	// Permitted keys are `container`, `node`, `pod`, `top_level_controller_name`,
	// and `top_level_controller_type`. The `container`
	// label is only populated if the scrape port is referenced by name.
	// Defaults to [container, pod, top_level_controller_name, top_level_controller_type].
	// If set to null, it will be interpreted as the empty list.
	// This is for backwards-compatibility only.
	// +kubebuilder:validation:items:Enum=container;node;pod;top_level_controller_name;top_level_controller_type
	// +listType=set
	// +kubebuilder:default=container;pod;top_level_controller_name;top_level_controller_type
	Metadata *[]string `json:"metadata,omitempty"`
	// Labels to transfer from the Kubernetes Pod to Prometheus target labels.
	// Mappings are applied in order.
	// +kubebuilder:validation:MaxItems=100
	FromPod []LabelMapping `json:"fromPod,omitempty"`
}

TargetLabels configures labels for the discovered Prometheus targets.

func (*TargetLabels) DeepCopy

func (in *TargetLabels) DeepCopy() *TargetLabels

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TargetLabels.

func (*TargetLabels) DeepCopyInto

func (in *TargetLabels) DeepCopyInto(out *TargetLabels)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

Jump to

Keyboard shortcuts

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