Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(prometheusMonitor): prometheus monitor configure #122

Merged
merged 3 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 6 additions & 18 deletions apis/v1alpha1/greptimedbcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down
14 changes: 7 additions & 7 deletions apis/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 1 addition & 7 deletions config/crd/resources/greptime.io_greptimedbclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions config/samples/cluster-with-monitor/cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ spec:
replicas: 3
prometheusMonitor:
enabled: true
path: "/metrics"
port: "http"
interval: "20s"
honorLabels: true
interval: "30s"
labelsSelector:
release: prometheus
8 changes: 4 additions & 4 deletions controllers/greptimedbcluster/deployers/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
8 changes: 1 addition & 7 deletions manifests/greptimedb-operator-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 1 addition & 7 deletions manifests/greptimedb-operator-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading