Skip to content

Commit 8be8e95

Browse files
committed
feat: add parameter enableAdminAPI to prometheus configuration
Signed-off-by: morenod <[email protected]>
1 parent ed8af0f commit 8be8e95

File tree

7 files changed

+38
-2
lines changed

7 files changed

+38
-2
lines changed

bundle/manifests/monitoring.rhobs_monitoringstacks.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,11 @@ spec:
199199
replicas: 2
200200
description: Define prometheus config
201201
properties:
202+
enableAdminAPI:
203+
description: |-
204+
Enable Prometheus Admin API
205+
Default to the value of `false`.
206+
type: boolean
202207
enableOtlpHttpReceiver:
203208
description: |-
204209
Enable Prometheus to accept OpenTelemetry Metrics via the otlp/http protocol.

deploy/crds/common/monitoring.rhobs_monitoringstacks.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,15 @@ spec:
199199
replicas: 2
200200
description: Define prometheus config
201201
properties:
202+
enableAdminAPI:
203+
description: |-
204+
Enable Prometheus Admin API.
205+
Defaults to the value of `false`.
206+
WARNING: Enabling the admin APIs enables mutating endpoints, to delete data,
207+
shutdown Prometheus, and more. Enabling this should be done with care and the
208+
user is advised to add additional authentication authorization via a proxy to
209+
ensure only clients authorized to perform these actions can do so.
210+
type: boolean
202211
enableOtlpHttpReceiver:
203212
description: |-
204213
Enable Prometheus to accept OpenTelemetry Metrics via the otlp/http protocol.

docs/api.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,18 @@ Define prometheus config
470470
</tr>
471471
</thead>
472472
<tbody><tr>
473+
<td><b>enableAdminAPI</b></td>
474+
<td>boolean</td>
475+
<td>
476+
Enable Prometheus Admin API.
477+
Defaults to the value of `false`.
478+
WARNING: Enabling the admin APIs enables mutating endpoints, to delete data,
479+
shutdown Prometheus, and more. Enabling this should be done with care and the
480+
user is advised to add additional authentication authorization via a proxy to
481+
ensure only clients authorized to perform these actions can do so.<br/>
482+
</td>
483+
<td>false</td>
484+
</tr><tr>
473485
<td><b>enableOtlpHttpReceiver</b></td>
474486
<td>boolean</td>
475487
<td>

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,8 +438,6 @@ github.com/rhobs/obo-prometheus-operator/pkg/apis/monitoring v0.86.1-rhobs1 h1:T
438438
github.com/rhobs/obo-prometheus-operator/pkg/apis/monitoring v0.86.1-rhobs1/go.mod h1:l986kUrEUzfrbYEsqRvSAJThNbF4SUKkM5eZR+L3uf0=
439439
github.com/rhobs/obo-prometheus-operator/pkg/client v0.86.1-rhobs1 h1:hKGd+NRtZkrTBFcoApy/3IkKJJprjwE3zsF4bZZxG7Y=
440440
github.com/rhobs/obo-prometheus-operator/pkg/client v0.86.1-rhobs1/go.mod h1:Ad3ru/JHiOZNEwAsaPMxzUq5Ft/qRs2kzBQXhw/9yJc=
441-
github.com/rhobs/observability-operator/pkg/apis v0.0.0-20251009091129-76135c924ed6 h1:f+J6l48RMDomN9YrDxd0cZVo7+L+a/TCzH6ycat5tMI=
442-
github.com/rhobs/observability-operator/pkg/apis v0.0.0-20251009091129-76135c924ed6/go.mod h1:bNP815/mCv8ydNQ2Q3a9gqlx9b2XouWa6hws9vthq78=
443441
github.com/rhobs/perses v0.0.0-20250612171017-5d7686af9ae4 h1:IxpxGJ/fbnRkZZYFm17NMedFyEuOKuf4TS23g+6jMvU=
444442
github.com/rhobs/perses v0.0.0-20250612171017-5d7686af9ae4/go.mod h1:Mxs4sXawWiV50qokKG1UZCV9NJEdJWsALY71/z38NKA=
445443
github.com/rhobs/perses-operator v0.1.10-0.20250612173146-78eb619430df h1:rwtqpvrowEF6EjSiO3PPcqC6s2jo7NU3VsGU6yrpxTg=

pkg/apis/monitoring/v1alpha1/types.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,14 @@ type PrometheusConfig struct {
236236
// Configure TLS options for the Prometheus web server.
237237
// +optional
238238
WebTLSConfig *WebTLSConfig `json:"webTLSConfig,omitempty"`
239+
// Enable Prometheus Admin API.
240+
// Defaults to the value of `false`.
241+
// WARNING: Enabling the admin APIs enables mutating endpoints, to delete data,
242+
// shutdown Prometheus, and more. Enabling this should be done with care and the
243+
// user is advised to add additional authentication authorization via a proxy to
244+
// ensure only clients authorized to perform these actions can do so.
245+
// +optional
246+
EnableAdminAPI bool `json:"enableAdminAPI,omitempty"`
239247
}
240248

241249
type AlertmanagerConfig struct {

pkg/controllers/monitoring/monitoring-stack/components.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ func newPrometheus(
209209
return []monv1.EnableFeature{}
210210
}(),
211211
},
212+
EnableAdminAPI: config.EnableAdminAPI,
212213
Retention: ms.Spec.Retention,
213214
RuleSelector: prometheusSelector,
214215
RuleNamespaceSelector: ms.Spec.NamespaceSelector,

test/e2e/monitoring_stack_controller_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,8 @@ func assertPrometheusManagedFields(t *testing.T) {
758758
},
759759
},
760760
}
761+
ms.Spec.PrometheusConfig.EnableAdminAPI = true
762+
761763
ms.Spec.NamespaceSelector = &metav1.LabelSelector{
762764
MatchLabels: map[string]string{
763765
"label": "label-value",
@@ -947,6 +949,7 @@ const oboManagedFieldsJson = `
947949
"f:alertmanagers": {}
948950
},
949951
"f:arbitraryFSAccessThroughSMs": {},
952+
"f:enableAdminAPI": {},
950953
"f:enableRemoteWriteReceiver": {},
951954
"f:externalLabels": {
952955
"f:key": {}

0 commit comments

Comments
 (0)