Skip to content

Commit a64d189

Browse files
authored
feat: add standalone prometheus monitor (#333)
* feat: add generate standalone prometheus monitor Signed-off-by: liyang <[email protected]> * add standalone prometheue monitor example Signed-off-by: liyang <[email protected]> --------- Signed-off-by: liyang <[email protected]>
1 parent a859c70 commit a64d189

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

controllers/greptimedbstandalone/deployer.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ func (d *StandaloneDeployer) Generate(crdObject client.Object) ([]client.Object,
8080
BuildService().
8181
BuildConfigMap().
8282
BuildStatefulSet().
83+
BuildPodMonitor().
8384
SetControllerAndAnnotation().
8485
Generate()
8586

@@ -279,6 +280,30 @@ func (b *standaloneBuilder) BuildStatefulSet() deployer.Builder {
279280
return b
280281
}
281282

283+
func (b *standaloneBuilder) BuildPodMonitor() deployer.Builder {
284+
if b.Err != nil {
285+
return b
286+
}
287+
288+
if b.standalone == nil {
289+
return b
290+
}
291+
292+
if b.standalone.Spec.PrometheusMonitor == nil || !b.standalone.Spec.PrometheusMonitor.Enabled {
293+
return b
294+
}
295+
296+
pm, err := common.GeneratePodMonitor(b.standalone.Namespace, common.ResourceName(b.standalone.Name, v1alpha1.StandaloneRoleKind), b.standalone.Spec.PrometheusMonitor)
297+
if err != nil {
298+
b.Err = err
299+
return b
300+
}
301+
302+
b.Objects = append(b.Objects, pm)
303+
304+
return b
305+
}
306+
282307
func (b *standaloneBuilder) generatePodTemplateSpec() corev1.PodTemplateSpec {
283308
template := common.GeneratePodTemplateSpec(v1alpha1.StandaloneRoleKind, b.standalone.Spec.Base)
284309

examples/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,4 @@ The following examples suppose that you have installed the etcd cluster in the `
3535
- [OSS](./standalone/oss/standalone.yaml): Create a GreptimeDB standalone with Aliyun OSS storage.
3636
- [AZBlob](./standalone/azblob/standalone.yaml): Create a GreptimeDB standalone with Azure Blob storage.
3737
- [Configure Tracing](./standalone/configure-tracing/standalone.yaml): Create a GreptimeDB standalone with custom tracing configuration.
38+
- [Prometheus Monitoring](./standalone/prometheus-monitor/standalone.yaml): Create a GreptimeDB standalone with Prometheus monitoring. Please ensure you have already installed prometheus-operator and created a Prometheus instance with the label `release=prometheus`.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: greptime.io/v1alpha1
2+
kind: GreptimeDBStandalone
3+
metadata:
4+
name: basic
5+
spec:
6+
base:
7+
main:
8+
image: greptime/greptimedb:latest
9+
prometheusMonitor: # Make sure you have already installed prometheus-operator and created a Prometheus instance with the label `release=prometheus`.
10+
enabled: true
11+
interval: "30s"
12+
labels:
13+
release: prometheus

0 commit comments

Comments
 (0)