mirror of
https://github.com/prometheus-operator/prometheus-operator.git
synced 2025-04-21 11:48:53 +00:00
pkg/apis/monitoring: Add query field to prom spec
This commit is contained in:
parent
a174c8b128
commit
9dc7b527cd
4 changed files with 130 additions and 1 deletions
pkg
|
@ -45,6 +45,7 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA
|
|||
"github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1.PrometheusRuleSpec": schema_pkg_apis_monitoring_v1_PrometheusRuleSpec(ref),
|
||||
"github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1.PrometheusSpec": schema_pkg_apis_monitoring_v1_PrometheusSpec(ref),
|
||||
"github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1.PrometheusStatus": schema_pkg_apis_monitoring_v1_PrometheusStatus(ref),
|
||||
"github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1.QuerySpec": schema_pkg_apis_monitoring_v1_QuerySpec(ref),
|
||||
"github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1.QueueConfig": schema_pkg_apis_monitoring_v1_QueueConfig(ref),
|
||||
"github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1.RelabelConfig": schema_pkg_apis_monitoring_v1_RelabelConfig(ref),
|
||||
"github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1.RemoteReadSpec": schema_pkg_apis_monitoring_v1_RemoteReadSpec(ref),
|
||||
|
@ -1336,6 +1337,12 @@ func schema_pkg_apis_monitoring_v1_PrometheusSpec(ref common.ReferenceCallback)
|
|||
Format: "",
|
||||
},
|
||||
},
|
||||
"query": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "QuerySpec defines the query command line flags when starting Prometheus.",
|
||||
Ref: ref("github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1.QuerySpec"),
|
||||
},
|
||||
},
|
||||
"storage": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "Storage spec to specify how storage shall be used.",
|
||||
|
@ -1527,7 +1534,7 @@ func schema_pkg_apis_monitoring_v1_PrometheusSpec(ref common.ReferenceCallback)
|
|||
},
|
||||
},
|
||||
Dependencies: []string{
|
||||
"github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1.APIServerConfig", "github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1.AlertingSpec", "github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1.RemoteReadSpec", "github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1.RemoteWriteSpec", "github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1.StorageSpec", "github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1.ThanosSpec", "k8s.io/api/core/v1.Affinity", "k8s.io/api/core/v1.Container", "k8s.io/api/core/v1.LocalObjectReference", "k8s.io/api/core/v1.PodSecurityContext", "k8s.io/api/core/v1.ResourceRequirements", "k8s.io/api/core/v1.SecretKeySelector", "k8s.io/api/core/v1.Toleration", "k8s.io/apimachinery/pkg/apis/meta/v1.LabelSelector", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"},
|
||||
"github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1.APIServerConfig", "github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1.AlertingSpec", "github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1.QuerySpec", "github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1.RemoteReadSpec", "github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1.RemoteWriteSpec", "github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1.StorageSpec", "github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1.ThanosSpec", "k8s.io/api/core/v1.Affinity", "k8s.io/api/core/v1.Container", "k8s.io/api/core/v1.LocalObjectReference", "k8s.io/api/core/v1.PodSecurityContext", "k8s.io/api/core/v1.ResourceRequirements", "k8s.io/api/core/v1.SecretKeySelector", "k8s.io/api/core/v1.Toleration", "k8s.io/apimachinery/pkg/apis/meta/v1.LabelSelector", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1580,6 +1587,40 @@ func schema_pkg_apis_monitoring_v1_PrometheusStatus(ref common.ReferenceCallback
|
|||
}
|
||||
}
|
||||
|
||||
func schema_pkg_apis_monitoring_v1_QuerySpec(ref common.ReferenceCallback) common.OpenAPIDefinition {
|
||||
return common.OpenAPIDefinition{
|
||||
Schema: spec.Schema{
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "QuerySpec defines the query command line flags when starting Prometheus.",
|
||||
Properties: map[string]spec.Schema{
|
||||
"lookbackDelta": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "The delta difference allowed for retrieving metrics during expression evaluations.",
|
||||
Type: []string{"string"},
|
||||
Format: "",
|
||||
},
|
||||
},
|
||||
"maxConcurrency": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "Number of concurrent queries that can be run at once.",
|
||||
Type: []string{"integer"},
|
||||
Format: "int32",
|
||||
},
|
||||
},
|
||||
"timeout": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "Maximum time a query may take before being aborted.",
|
||||
Type: []string{"string"},
|
||||
Format: "",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Dependencies: []string{},
|
||||
}
|
||||
}
|
||||
|
||||
func schema_pkg_apis_monitoring_v1_QueueConfig(ref common.ReferenceCallback) common.OpenAPIDefinition {
|
||||
return common.OpenAPIDefinition{
|
||||
Schema: spec.Schema{
|
||||
|
|
|
@ -125,6 +125,8 @@ type PrometheusSpec struct {
|
|||
// and the actual ExternalURL is still true, but the server serves requests
|
||||
// under a different route prefix. For example for use with `kubectl proxy`.
|
||||
RoutePrefix string `json:"routePrefix,omitempty"`
|
||||
// QuerySpec defines the query command line flags when starting Prometheus.
|
||||
Query *QuerySpec `json:"query,omitempty"`
|
||||
// Storage spec to specify how storage shall be used.
|
||||
Storage *StorageSpec `json:"storage,omitempty"`
|
||||
// A selector to select which PrometheusRules to mount for loading alerting
|
||||
|
@ -265,6 +267,17 @@ type StorageSpec struct {
|
|||
VolumeClaimTemplate v1.PersistentVolumeClaim `json:"volumeClaimTemplate,omitempty"`
|
||||
}
|
||||
|
||||
// QuerySpec defines the query command line flags when starting Prometheus.
|
||||
// +k8s:openapi-gen=true
|
||||
type QuerySpec struct {
|
||||
// The delta difference allowed for retrieving metrics during expression evaluations.
|
||||
LookbackDelta *string `json:"lookbackDelta,omitempty"`
|
||||
// Number of concurrent queries that can be run at once.
|
||||
MaxConcurrency *int32 `json:"maxConcurrency,omitempty"`
|
||||
// Maximum time a query may take before being aborted.
|
||||
Timeout *string `json:"timeout,omitempty"`
|
||||
}
|
||||
|
||||
// ThanosSpec defines parameters for a Prometheus server within a Thanos deployment.
|
||||
// +k8s:openapi-gen=true
|
||||
type ThanosSpec struct {
|
||||
|
|
|
@ -623,6 +623,15 @@ func (in *PrometheusSpec) DeepCopyInto(out *PrometheusSpec) {
|
|||
(*out)[key] = val
|
||||
}
|
||||
}
|
||||
if in.Query != nil {
|
||||
in, out := &in.Query, &out.Query
|
||||
if *in == nil {
|
||||
*out = nil
|
||||
} else {
|
||||
*out = new(QuerySpec)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
}
|
||||
if in.Storage != nil {
|
||||
in, out := &in.Storage, &out.Storage
|
||||
if *in == nil {
|
||||
|
@ -797,6 +806,49 @@ func (in *PrometheusStatus) DeepCopy() *PrometheusStatus {
|
|||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *QuerySpec) DeepCopyInto(out *QuerySpec) {
|
||||
*out = *in
|
||||
if in.LookbackDelta != nil {
|
||||
in, out := &in.LookbackDelta, &out.LookbackDelta
|
||||
if *in == nil {
|
||||
*out = nil
|
||||
} else {
|
||||
*out = new(string)
|
||||
**out = **in
|
||||
}
|
||||
}
|
||||
if in.MaxConcurrency != nil {
|
||||
in, out := &in.MaxConcurrency, &out.MaxConcurrency
|
||||
if *in == nil {
|
||||
*out = nil
|
||||
} else {
|
||||
*out = new(int32)
|
||||
**out = **in
|
||||
}
|
||||
}
|
||||
if in.Timeout != nil {
|
||||
in, out := &in.Timeout, &out.Timeout
|
||||
if *in == nil {
|
||||
*out = nil
|
||||
} else {
|
||||
*out = new(string)
|
||||
**out = **in
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new QuerySpec.
|
||||
func (in *QuerySpec) DeepCopy() *QuerySpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(QuerySpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *QueueConfig) DeepCopyInto(out *QueueConfig) {
|
||||
*out = *in
|
||||
|
|
|
@ -50,6 +50,7 @@ const (
|
|||
|
||||
var (
|
||||
minReplicas int32 = 1
|
||||
defaultMaxConcurrency int32 = 20
|
||||
managedByOperatorLabel = "managed-by"
|
||||
managedByOperatorLabelValue = "prometheus-operator"
|
||||
managedByOperatorLabels = map[string]string{
|
||||
|
@ -342,10 +343,32 @@ func makeStatefulSetSpec(p monitoringv1.Prometheus, c *Config, ruleConfigMapName
|
|||
"-web.enable-lifecycle",
|
||||
"-storage.tsdb.no-lockfile",
|
||||
)
|
||||
|
||||
if p.Spec.Query != nil && p.Spec.Query.LookbackDelta != nil {
|
||||
promArgs = append(promArgs,
|
||||
fmt.Sprintf("-query.lookback-delta=%s", *p.Spec.Query.LookbackDelta),
|
||||
)
|
||||
}
|
||||
default:
|
||||
return nil, errors.Errorf("unsupported Prometheus major version %s", version)
|
||||
}
|
||||
|
||||
if p.Spec.Query != nil {
|
||||
if p.Spec.Query.MaxConcurrency != nil {
|
||||
if *p.Spec.Query.MaxConcurrency < 1 {
|
||||
p.Spec.Query.MaxConcurrency = &defaultMaxConcurrency
|
||||
}
|
||||
promArgs = append(promArgs,
|
||||
fmt.Sprintf("-query.max-concurrency=%d", *p.Spec.Query.MaxConcurrency),
|
||||
)
|
||||
}
|
||||
if p.Spec.Query.Timeout != nil {
|
||||
promArgs = append(promArgs,
|
||||
fmt.Sprintf("-query.timeout=%s", *p.Spec.Query.Timeout),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
var securityContext *v1.PodSecurityContext = nil
|
||||
if p.Spec.SecurityContext != nil {
|
||||
securityContext = p.Spec.SecurityContext
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue