Skip to content

Commit

Permalink
Add Microsoft SQL Server MetricsConfiguration (#1117)
Browse files Browse the repository at this point in the history
* Add Microsoft SQL Server MetricsConfiguration

Signed-off-by: Neaj Morshad <[email protected]>

* Add more spec for mssqlserver

Signed-off-by: Neaj Morshad <[email protected]>

* Update exporter images

Signed-off-by: Neaj Morshad <[email protected]>

* Add appscode images for exporter

Signed-off-by: Neaj Morshad <[email protected]>

---------

Signed-off-by: Neaj Morshad <[email protected]>
  • Loading branch information
Neaj-Morshad-101 authored Aug 22, 2024
1 parent 6e00b4d commit f49b6ee
Show file tree
Hide file tree
Showing 4 changed files with 207 additions and 2 deletions.
2 changes: 1 addition & 1 deletion catalog/kubedb/raw/mssqlserver/mssqlserver-2022.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ spec:
db:
image: mcr.microsoft.com/mssql/server:2022-CU12-ubuntu-22.04
exporter:
image: neajmorshad/mssqlserver_exporter:kubedb
image: ghcr.io/kubedb/mssql-exporter:1.0.0
initContainer:
image: ghcr.io/kubedb/mssql-init:2022-ubuntu-22-v2
securityContext:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ spec:
db:
image: '{{ include "image.microsoft" (merge (dict "_repo" "mssql/server") $) }}:2022-CU12-ubuntu-22.04'
exporter:
image: '{{ include "image.dockerHub" (merge (dict "_repo" "neajmorshad/mssqlserver_exporter") $) }}:kubedb'
image: '{{ include "image.ghcr" (merge (dict "_repo" "kubedb/mssql-exporter") $) }}:1.0.0'
initContainer:
image: '{{ include "image.ghcr" (merge (dict "_repo" "kubedb/mssql-init") $) }}:2022-ubuntu-22-v2'
securityContext:
Expand Down
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-mssqlserverversion
spec:
targetRef:
apiVersion: catalog.kubedb.com/v1alpha1
kind: MSSQLServerVersion
metrics:
- name: created
help: "Unix creation timestamp"
type: gauge
field:
path: .metadata.creationTimestamp
type: DateTime
metricValue:
valueFromPath: .metadata.creationTimestamp

- name: info
help: "MSSQLServer versions info"
type: gauge
labels:
- key: deprecated
valuePath: .spec.deprecated
- key: mssqlserver_image
valuePath: .spec.db.image
- key: exporter_image
valuePath: .spec.exporter.image
metricValue:
value: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
apiVersion: metrics.appscode.com/v1alpha1
kind: MetricsConfiguration
metadata:
name: kubedb-com-mssqlserver
spec:
targetRef:
apiVersion: kubedb.com/v1alpha2
kind: MSSQLServer
commonLabels:
- key: app
valuePath: .metadata.name
- key: app_namespace
valuePath: .metadata.namespace
metrics:
- name: created
help: "Unix creation time stamp"
type: gauge
field:
path: .metadata.creationTimestamp
type: DateTime
metricValue:
valueFromPath: .metadata.creationTimestamp

- name: replicas
help: "Number of replicas of mssqlserver instance"
type: gauge
params:
- key: obj
valuePath: .
metricValue:
valueFromExpression: resource_replicas(obj)

- name: status_phase
help: "MSSQLServer 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: "MSSQLServer instance information"
type: gauge
labels:
- key: version
valuePath: .spec.version
- key: storageType
valuePath: .spec.storageType
- key: deletionPolicy
valuePath: .spec.deletionPolicy
- key: clientTLS
valuePath: .spec.tls.clientTLS
metricValue:
value: 1

- name: status_conditions
help: "MSSQLServer 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 mssqlserver 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 MSSQLServer 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 MSSQLServer 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 MSSQLServer 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 MSSQLServer 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 MSSQLServer in byte"
type: gauge
labels:
- key: unit
value: byte
params:
- key: obj
valuePath: .
- key: resourceType
value: storage
metricValue:
valueFromExpression: total_resource_limits(obj, resourceType)

0 comments on commit f49b6ee

Please sign in to comment.