Skip to content

Commit

Permalink
feat: Add serviceMonitor resource (#537)
Browse files Browse the repository at this point in the history
* feat: Add serviceMonitor resource

Signed-off-by: Shubham Gupta <[email protected]>
Signed-off-by: VILJkid <[email protected]>

* fix: metrics path

Signed-off-by: Shubham Gupta <[email protected]>
Signed-off-by: VILJkid <[email protected]>

* (lint) : trailing newline

Signed-off-by: VILJkid <[email protected]>

* (update) : readme and changelog with comments

Signed-off-by: VILJkid <[email protected]>

* (add) : opensearch-dashboard for serviceMonitor

Signed-off-by: VILJkid <[email protected]>

* (chore) : bump changelog version

Signed-off-by: VILJkid <[email protected]>

* (chore) : bump version

Signed-off-by: VILJkid <[email protected]>

* (lint) : add newline

Signed-off-by: VILJkid <[email protected]>

* (fix) : changelog compare versions

Signed-off-by: VILJkid <[email protected]>

* (fix) : bump minor versions instead of patch

Signed-off-by: VILJkid <[email protected]>

---------

Signed-off-by: Shubham Gupta <[email protected]>
Signed-off-by: VILJkid <[email protected]>
Co-authored-by: Shubham Gupta <[email protected]>
Co-authored-by: VILJkid <[email protected]>
  • Loading branch information
3 people authored Aug 22, 2024
1 parent 4ca8bfd commit 4253842
Show file tree
Hide file tree
Showing 10 changed files with 310 additions and 180 deletions.
13 changes: 12 additions & 1 deletion charts/opensearch-dashboards/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
Expand All @@ -13,6 +14,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
### Security
---
## [2.21.0]
### Added
- Added `ServiceMonitor` support for Prometheus monitoring
### Changed
### Deprecated
### Removed
### Fixed
### Security
---
## [2.20.0]
### Added
- Updated OpenSearch Dashboards appVersion to 2.16.0
Expand Down Expand Up @@ -358,7 +368,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
### Security

[Unreleased]: https://github.com/opensearch-project/helm-charts/compare/opensearch-dashboards-2.20.0...HEAD
[Unreleased]: https://github.com/opensearch-project/helm-charts/compare/opensearch-dashboards-2.21.0...HEAD
[2.21.0]: https://github.com/opensearch-project/helm-charts/compare/opensearch-dashboards-2.20.0...opensearch-dashboards-2.21.0
[2.20.0]: https://github.com/opensearch-project/helm-charts/compare/opensearch-dashboards-2.19.1...opensearch-dashboards-2.20.0
[2.19.1]: https://github.com/opensearch-project/helm-charts/compare/opensearch-dashboards-2.19.0...opensearch-dashboards-2.19.1
[2.19.0]: https://github.com/opensearch-project/helm-charts/compare/opensearch-dashboards-2.18.0...opensearch-dashboards-2.19.0
Expand Down
2 changes: 1 addition & 1 deletion charts/opensearch-dashboards/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 2.20.0
version: 2.21.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
191 changes: 115 additions & 76 deletions charts/opensearch-dashboards/README.md

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions charts/opensearch-dashboards/templates/serviceMonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{- if .Values.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ template "opensearch-dashboards.fullname" . }}-service-monitor
namespace: {{ .Release.Namespace }}
labels:
{{- include "opensearch-dashboards.labels" . | nindent 4 }}
spec:
selector:
matchLabels:
{{- include "opensearch-dashboards.selectorLabels" . | nindent 6 }}
endpoints:
- port: {{ .Values.metricsPort }}
interval: {{ .Values.serviceMonitor.interval }}
path: {{ .Values.serviceMonitor.path }}
{{- end }}
18 changes: 18 additions & 0 deletions charts/opensearch-dashboards/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -276,3 +276,21 @@ plugins:
enabled: false
installList: []
# - example-fake-plugin-downloadable-url

# ServiceMonitor Configuration for Prometheus
# Enabling this option will create a ServiceMonitor resource that allows Prometheus to scrape metrics from the OpenSearch service.
serviceMonitor:
# Set to true to enable the ServiceMonitor resource for OpenSearch Dashboards
enabled: false

# HTTP path where metrics are exposed by OpenSearch Dashboards.
# Ensure this path is correctly set in your service.
path: /_prometheus/metrics

# Frequency at which Prometheus will scrape metrics.
# Modify as needed for your monitoring requirements.
interval: 10s

# Port configuration for metrics.
# This should match the port exposed by the OpenSearch Dashboards service.
metricsPort: 9601
13 changes: 12 additions & 1 deletion charts/opensearch/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
Expand All @@ -13,6 +14,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
### Security
---
## [2.23.0]
### Added
- Added `ServiceMonitor` support for Prometheus monitoring
### Changed
### Deprecated
### Removed
### Fixed
### Security
---
## [2.22.1]
### Added
### Changed
Expand Down Expand Up @@ -440,7 +450,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Security


[Unreleased]: https://github.com/opensearch-project/helm-charts/compare/opensearch-2.22.1...HEAD
[Unreleased]: https://github.com/opensearch-project/helm-charts/compare/opensearch-2.23.0...HEAD
[2.23.0]: https://github.com/opensearch-project/helm-charts/compare/opensearch-2.22.1...opensearch-2.23.0
[2.22.1]: https://github.com/opensearch-project/helm-charts/compare/opensearch-2.22.0...opensearch-2.22.1
[2.22.0]: https://github.com/opensearch-project/helm-charts/compare/opensearch-2.21.0...opensearch-2.22.0
[2.21.0]: https://github.com/opensearch-project/helm-charts/compare/opensearch-2.20.0...opensearch-2.21.0
Expand Down
2 changes: 1 addition & 1 deletion charts/opensearch/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 2.22.1
version: 2.23.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
Loading

2 comments on commit 4253842

@schroedermatthias
Copy link

@schroedermatthias schroedermatthias commented on 4253842 Aug 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we cannot use the port number here, specified in metricsPort. My helm release is failing.

2024-08-26T12:35:54.739649021Z: warning: Upgrade "opensearch" failed: failed to create resource: ServiceMonitor.monitoring.coreos.com "opensearch-cluster-master-service-monitor" is invalid: spec.endpoints[0].port: Invalid value: "integer": spec.endpoints[0].port in body must be of type string: "integer"

When you see the definition of a serviceMonitor, it states:

                  port:
                    description: Name of the service port this endpoint refers to.
                      Mutually exclusive with targetPort.

So a name is expected in port. If we want to use the port number, targetPort would be the right field, see:
https://github.com/helm/charts/blob/390ee6614b4bb0da96b397f9b382e3ddca9f59a4/stable/prometheus-operator/crds/crd-servicemonitor.yaml#L177

@VILJkid
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @schroedermatthias, you're correct!
I've created #581 PR to fix the same.

Please sign in to comment.