diff --git a/apis/v1alpha1/greptimedbcluster_types.go b/apis/v1alpha1/greptimedbcluster_types.go index 24b139c7..d0932eaf 100644 --- a/apis/v1alpha1/greptimedbcluster_types.go +++ b/apis/v1alpha1/greptimedbcluster_types.go @@ -500,7 +500,7 @@ type GreptimeDBClusterSpec struct { EnableInfluxDBProtocol bool `json:"enableInfluxDBProtocol,omitempty"` // +optional - PrometheusMonitor *PrometheusMonitor `json:"prometheusMonitor,omitempty"` + PrometheusMonitor *PrometheusMonitorSpec `json:"prometheusMonitor,omitempty"` // +optional // The version of greptimedb. @@ -515,31 +515,19 @@ type GreptimeDBClusterSpec struct { // More cluster settings can be added here. } -// PrometheusMonitor defines the PodMonitor configuration. -type PrometheusMonitor struct { - // Enable a prometheus PodMonitor +// PrometheusMonitorSpec defines the PodMonitor configuration. +type PrometheusMonitorSpec struct { + // Enable a Prometheus PodMonitor // +optional Enabled bool `json:"enabled,omitempty"` - // HTTP path to scrape for metrics. + // Prometheus PodMonitor labels. // +optional - Path string `json:"path,omitempty"` - - // Name of the pod port this endpoint refers to. Mutually exclusive with targetPort. - // +optional - Port string `json:"port,omitempty"` + Labels map[string]string `json:"labels,omitempty"` // Interval at which metrics should be scraped // +optional Interval string `json:"interval,omitempty"` - - // HonorLabels chooses the metrics labels on collisions with target labels. - // +optional - HonorLabels bool `json:"honorLabels,omitempty"` - - // Prometheus PodMonitor selector. - // +optional - LabelsSelector map[string]string `json:"labelsSelector,omitempty"` } // GreptimeDBClusterStatus defines the observed state of GreptimeDBCluster diff --git a/apis/v1alpha1/zz_generated.deepcopy.go b/apis/v1alpha1/zz_generated.deepcopy.go index 34fe1b7f..9116971f 100644 --- a/apis/v1alpha1/zz_generated.deepcopy.go +++ b/apis/v1alpha1/zz_generated.deepcopy.go @@ -219,7 +219,7 @@ func (in *GreptimeDBClusterSpec) DeepCopyInto(out *GreptimeDBClusterSpec) { } if in.PrometheusMonitor != nil { in, out := &in.PrometheusMonitor, &out.PrometheusMonitor - *out = new(PrometheusMonitor) + *out = new(PrometheusMonitorSpec) (*in).DeepCopyInto(*out) } if in.Initializer != nil { @@ -450,10 +450,10 @@ func (in *PodTemplateSpec) DeepCopy() *PodTemplateSpec { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *PrometheusMonitor) DeepCopyInto(out *PrometheusMonitor) { +func (in *PrometheusMonitorSpec) DeepCopyInto(out *PrometheusMonitorSpec) { *out = *in - if in.LabelsSelector != nil { - in, out := &in.LabelsSelector, &out.LabelsSelector + if in.Labels != nil { + in, out := &in.Labels, &out.Labels *out = make(map[string]string, len(*in)) for key, val := range *in { (*out)[key] = val @@ -461,12 +461,12 @@ func (in *PrometheusMonitor) DeepCopyInto(out *PrometheusMonitor) { } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PrometheusMonitor. -func (in *PrometheusMonitor) DeepCopy() *PrometheusMonitor { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PrometheusMonitorSpec. +func (in *PrometheusMonitorSpec) DeepCopy() *PrometheusMonitorSpec { if in == nil { return nil } - out := new(PrometheusMonitor) + out := new(PrometheusMonitorSpec) in.DeepCopyInto(out) return out } diff --git a/config/crd/resources/greptime.io_greptimedbclusters.yaml b/config/crd/resources/greptime.io_greptimedbclusters.yaml index c165ba8a..c37974b2 100644 --- a/config/crd/resources/greptime.io_greptimedbclusters.yaml +++ b/config/crd/resources/greptime.io_greptimedbclusters.yaml @@ -10700,18 +10700,12 @@ spec: properties: enabled: type: boolean - honorLabels: - type: boolean interval: type: string - labelsSelector: + labels: additionalProperties: type: string type: object - path: - type: string - port: - type: string type: object prometheusServicePort: format: int32 diff --git a/config/samples/cluster-with-monitor/cluster.yaml b/config/samples/cluster-with-monitor/cluster.yaml index b55673ee..2b4803ec 100644 --- a/config/samples/cluster-with-monitor/cluster.yaml +++ b/config/samples/cluster-with-monitor/cluster.yaml @@ -31,9 +31,6 @@ spec: replicas: 3 prometheusMonitor: enabled: true - path: "/metrics" - port: "http" - interval: "20s" - honorLabels: true + interval: "30s" labelsSelector: release: prometheus diff --git a/controllers/greptimedbcluster/deployers/common.go b/controllers/greptimedbcluster/deployers/common.go index 93b688f5..186f3e49 100644 --- a/controllers/greptimedbcluster/deployers/common.go +++ b/controllers/greptimedbcluster/deployers/common.go @@ -183,15 +183,15 @@ func (c *CommonBuilder) GeneratePodMonitor() (*monitoringv1.PodMonitor, error) { ObjectMeta: metav1.ObjectMeta{ Name: ResourceName(c.Cluster.Name, c.ComponentKind), Namespace: c.Cluster.Namespace, - Labels: c.Cluster.Spec.PrometheusMonitor.LabelsSelector, + Labels: c.Cluster.Spec.PrometheusMonitor.Labels, }, Spec: monitoringv1.PodMonitorSpec{ PodMetricsEndpoints: []monitoringv1.PodMetricsEndpoint{ { - Path: c.Cluster.Spec.PrometheusMonitor.Path, - Port: c.Cluster.Spec.PrometheusMonitor.Port, + Path: "/metrics", + Port: "http", Interval: c.Cluster.Spec.PrometheusMonitor.Interval, - HonorLabels: c.Cluster.Spec.PrometheusMonitor.HonorLabels, + HonorLabels: true, }, }, Selector: metav1.LabelSelector{ diff --git a/manifests/greptimedb-operator-crd.yaml b/manifests/greptimedb-operator-crd.yaml index 5b520902..7c7eccd2 100644 --- a/manifests/greptimedb-operator-crd.yaml +++ b/manifests/greptimedb-operator-crd.yaml @@ -10699,18 +10699,12 @@ spec: properties: enabled: type: boolean - honorLabels: - type: boolean interval: type: string - labelsSelector: + labels: additionalProperties: type: string type: object - path: - type: string - port: - type: string type: object prometheusServicePort: format: int32 diff --git a/manifests/greptimedb-operator-deployment.yaml b/manifests/greptimedb-operator-deployment.yaml index 02852d68..f0dd6cd5 100644 --- a/manifests/greptimedb-operator-deployment.yaml +++ b/manifests/greptimedb-operator-deployment.yaml @@ -10706,18 +10706,12 @@ spec: properties: enabled: type: boolean - honorLabels: - type: boolean interval: type: string - labelsSelector: + labels: additionalProperties: type: string type: object - path: - type: string - port: - type: string type: object prometheusServicePort: format: int32