Skip to content

Commit

Permalink
Add ZooKeeper Resource Metrics
Browse files Browse the repository at this point in the history
Signed-off-by: Shaad7 <[email protected]>
  • Loading branch information
AbdullahAlShaad committed Feb 14, 2024
1 parent 3750fe7 commit 58656be
Show file tree
Hide file tree
Showing 2 changed files with 203 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
apiVersion: metrics.appscode.com/v1alpha1
kind: MetricsConfiguration
metadata:
name: catalog-kubedb-com-zookeeperversion
spec:
targetRef:
apiVersion: catalog.kubedb.com/v1alpha1
kind: ZooKeeperVersion
metrics:
- name: created
help: "Unix creation timestamp"
type: gauge
field:
path: .metadata.creationTimestamp
type: DateTime
metricValue:
valueFromPath: .metadata.creationTimestamp

- name: info
help: "ZooKeeper versions info"
type: gauge
labels:
- key: db_image
valuePath: .spec.db.image
- key: deprecated
valuePath: .spec.deprecated
- key: exporter_image
valuePath: .spec.exporter.image
metricValue:
value: 1
173 changes: 173 additions & 0 deletions charts/kubedb-metrics/templates/zookeeper/kubedb-com-zookeeper.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
apiVersion: metrics.appscode.com/v1alpha1
kind: MetricsConfiguration
metadata:
name: kubedb-com-zookeeper
spec:
targetRef:
apiVersion: kubedb.com/v1alpha2
kind: ZooKeeper
commonLabels:
- key: app
valuePath: .metadata.name
- key: app_namespace
valuePath: .metadata.namespace
metrics:
- name: created
help: "Unix creation timestamp"
type: gauge
field:
path: .metadata.creationTimestamp
type: DateTime
metricValue:
valueFromPath: .metadata.creationTimestamp

- name: status_phase
help: "ZooKeeper instance current phase"
type: gauge
field:
path: .status.phase
type: String
params:
- key: phase
valuePath: .status.phase
states:
labelKey: phase
values:
- labelValue: Ready
metricValue:
valueFromExpression: "int(phase == 'Ready')"
- labelValue: Halted
metricValue:
valueFromExpression: "int(phase == 'Halted')"
- labelValue: Provisioning
metricValue:
valueFromExpression: "int(phase == 'Provisioning')"
- labelValue: Critical
metricValue:
valueFromExpression: "int(phase == 'Critical')"
- labelValue: NotReady
metricValue:
valueFromExpression: "int(phase == 'NotReady')"
- labelValue: DataRestoring
metricValue:
valueFromExpression: "int(phase == 'DataRestoring')"

- name: info
help: "ZooKeeper instance information"
type: gauge
labels:
- key: storageType
valuePath: .spec.storageType
- key: terminationPolicy
valuePath: .spec.terminationPolicy
- key: version
valuePath: .spec.version
metricValue:
value: 1

- name: status_conditions
help: "ZooKeeper instance status condition"
type: gauge
field:
path: .status.conditions
type: Array
labels:
- key: type
valuePath: .status.conditions[*].type
- key: status
valuePath: .status.conditions[*].status
metricValue:
value: 1

- name: resource_request_cpu
help: "Requested CPU by ZooKeeper in core"
type: gauge
labels:
- key: unit
value: core
params:
- key: obj
valuePath: .
- key: resourceType
value: cpu
metricValue:
valueFromExpression: total_resource_requests(obj, resourceType)

- name: resource_request_memory
help: "Requested memory by ZooKeeper in byte"
type: gauge
labels:
- key: unit
value: byte
params:
- key: obj
valuePath: .
- key: resourceType
value: memory
metricValue:
valueFromExpression: total_resource_requests(obj, resourceType)

- name: resource_request_storage
help: "Requested storage by ZooKeeper in byte"
type: gauge
labels:
- key: unit
value: byte
params:
- key: obj
valuePath: .
- key: resourceType
value: storage
metricValue:
valueFromExpression: total_resource_requests(obj, resourceType)

- name: resource_limit_cpu
help: "CPU limit for ZooKeeper in core"
type: gauge
labels:
- key: unit
value: core
params:
- key: obj
valuePath: .
- key: resourceType
value: cpu
metricValue:
valueFromExpression: total_resource_limits(obj, resourceType)

- name: resource_limit_memory
help: "Memory limit for ZooKeeper in byte"
type: gauge
labels:
- key: unit
value: byte
params:
- key: obj
valuePath: .
- key: resourceType
value: memory
metricValue:
valueFromExpression: total_resource_limits(obj, resourceType)

- name: resource_limit_storage
help: "Storage limit for ZooKeeper in byte"
type: gauge
labels:
- key: unit
value: byte
params:
- key: obj
valuePath: .
- key: resourceType
value: storage
metricValue:
valueFromExpression: total_resource_limits(obj, resourceType)

- name: replicas
help: "Number of replicas in the ZooKeeper"
type: gauge
field:
path: .spec.replicas
type: Integer
metricValue:
valueFromPath: .spec.replicas

0 comments on commit 58656be

Please sign in to comment.