exporter: move config to cluster CRD

allows to set prio-limit and stats-period options to ceph exporter

Signed-off-by: Artem Torubarov <artem.torubarov@clyso.com>
This commit is contained in:
Artem Torubarov committed 2024-09-16 14:51:49 +02:00
1 parent 45cdbb6767
commit b2c39ace25
8 files changed
+135 -3

No files matched your search

@@ -52,6 +52,9 @@ If this value is empty, each pod will get an ephemeral directory to store their
* `externalMgrPrometheusPort`: external prometheus manager module port. See [external cluster configuration](./external-cluster/external-cluster.md) for more details.
* `port`: The internal prometheus manager module port where the prometheus mgr module listens. The port may need to be configured when host networking is enabled.
* `interval`: The interval for the prometheus module to to scrape targets.
* `exporter`: Ceph exporter metrics config.
* `perfCountersPrioLimit`: Specifies which performance counters are exported. Corresponds to `--prio-limit` Ceph exporter flag. `0` - all counters are exported, default is `5`.
* `statsPeriodSeconds`: Time to wait before sending requests again to exporter server (seconds). Corresponds to `--stats-period` Ceph exporter flag. Default is `5`.
* `network`: For the network settings for the cluster, refer to the [network configuration settings](#network-configuration-settings)
* `mon`: contains mon related options [mon settings](#mon-settings)
For more details on the mons and when to choose a number other than `3`, see the [mon health doc](../../Storage-Configuration/Advanced/ceph-mon-health.md).
+53
View File
@@ -3686,6 +3686,45 @@ map[string]int
</tr>
</tbody>
</table>
<h3 id="ceph.rook.io/v1.CephExporterSpec">CephExporterSpec
</h3>
<p>
(<em>Appears on:</em><a href="#ceph.rook.io/v1.MonitoringSpec">MonitoringSpec</a>)
</p>
<div>
</div>
<table>
<thead>
<tr>
<th>Field</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code>perfCountersPrioLimit</code><br/>
<em>
int64
</em>
</td>
<td>
<p>Only performance counters greater than or equal to this option are fetched</p>
</td>
</tr>
<tr>
<td>
<code>statsPeriodSeconds</code><br/>
<em>
int64
</em>
</td>
<td>
<p>Time to wait before sending requests again to exporter server (seconds)</p>
</td>
</tr>
</tbody>
</table>
<h3 id="ceph.rook.io/v1.CephFilesystemStatus">CephFilesystemStatus
</h3>
<p>
@@ -8527,6 +8566,20 @@ Kubernetes meta/v1.Duration
<p>Interval determines prometheus scrape interval</p>
</td>
</tr>
<tr>
<td>
<code>exporter</code><br/>
<em>
<a href="#ceph.rook.io/v1.CephExporterSpec">
CephExporterSpec
</a>
</em>
</td>
<td>
<em>(Optional)</em>
<p>Ceph exporter configuration</p>
</td>
</tr>
</tbody>
</table>
<h3 id="ceph.rook.io/v1.MultiClusterServiceSpec">MultiClusterServiceSpec
@@ -2341,6 +2341,20 @@ spec:
Enabled determines whether to create the prometheus rules for the ceph cluster. If true, the prometheus
types must exist or the creation will fail. Default is false.
type: boolean
exporter:
description: Ceph exporter configuration
properties:
perfCountersPrioLimit:
default: 5
description: Only performance counters greater than or equal to this option are fetched
format: int64
type: integer
statsPeriodSeconds:
default: 5
description: Time to wait before sending requests again to exporter server (seconds)
format: int64
type: integer
type: object
externalMgrEndpoints:
description: ExternalMgrEndpoints points to an existing Ceph prometheus exporter endpoint
items:
+9
View File
@@ -85,6 +85,15 @@ spec:
# Whether to disable the metrics reported by Ceph. If false, the prometheus mgr module and Ceph exporter are enabled.
# If true, the prometheus mgr module and Ceph exporter are both disabled. Default is false.
metricsDisabled: false
# Ceph exporter metrics config.
exporter:
# Specifies which performance counters are exported.
# Corresponds to --prio-limit Ceph exporter flag
# 0 - all counters are exported
perfCountersPrioLimit: 5
# Time to wait before sending requests again to exporter server (seconds)
# Corresponds to --stats-period Ceph exporter flag
statsPeriodSeconds: 5
network:
connections:
# Whether to encrypt the data in transit across the wire to prevent eavesdropping the data on the network.
+14
View File
@@ -2339,6 +2339,20 @@ spec:
Enabled determines whether to create the prometheus rules for the ceph cluster. If true, the prometheus
types must exist or the creation will fail. Default is false.
type: boolean
exporter:
description: Ceph exporter configuration
properties:
perfCountersPrioLimit:
default: 5
description: Only performance counters greater than or equal to this option are fetched
format: int64
type: integer
statsPeriodSeconds:
default: 5
description: Time to wait before sending requests again to exporter server (seconds)
format: int64
type: integer
type: object
externalMgrEndpoints:
description: ExternalMgrEndpoints points to an existing Ceph prometheus exporter endpoint
items:
+14
View File
@@ -406,6 +406,20 @@ type MonitoringSpec struct {
// Interval determines prometheus scrape interval
// +optional
Interval *metav1.Duration `json:"interval,omitempty"`
// Ceph exporter configuration
// +optional
Exporter *CephExporterSpec `json:"exporter,omitempty"`
}
type CephExporterSpec struct {
// Only performance counters greater than or equal to this option are fetched
// +kubebuilder:default=5
PerfCountersPrioLimit int64 `json:"perfCountersPrioLimit,omitempty"`
// Time to wait before sending requests again to exporter server (seconds)
// +kubebuilder:default=5
StatsPeriodSeconds int64 `json:"statsPeriodSeconds,omitempty"`
}
// ClusterStatus represents the status of a Ceph cluster
@@ -42,8 +42,8 @@ const (
monitoringPath = "/etc/ceph-monitoring/"
serviceMonitorFile = "exporter-service-monitor.yaml"
sockDir = "/run/ceph"
perfCountersPrioLimit = "5"
statsPeriod = "5"
defaultPrioLimit = "5"
defaultStatsPeriod = "5"
DefaultMetricsPort uint16 = 9926
exporterServiceMetricName = "ceph-exporter-http-metrics"
exporterKeyringUsername = "client.ceph-exporter"
@@ -179,10 +179,15 @@ func getCephExporterDaemonContainer(cephCluster cephv1.CephCluster, cephVersion
exporterEnvVar := generateExporterEnvVar()
envVars := append(controller.DaemonEnvVars(&cephCluster.Spec), exporterEnvVar)
prioLimit, statsPeriod := defaultPrioLimit, defaultStatsPeriod
if cephCluster.Spec.Monitoring.Exporter != nil {
prioLimit = strconv.Itoa(int(cephCluster.Spec.Monitoring.Exporter.PerfCountersPrioLimit))
statsPeriod = strconv.Itoa(int(cephCluster.Spec.Monitoring.Exporter.StatsPeriodSeconds))
}
args := []string{
"--sock-dir", sockDir,
"--port", strconv.Itoa(int(DefaultMetricsPort)),
"--prio-limit", perfCountersPrioLimit,
"--prio-limit", prioLimit,
"--stats-period", statsPeriod,
}
@@ -121,6 +121,26 @@ func TestCreateOrUpdateCephExporter(t *testing.T) {
assert.Equal(t, tolerations, podSpec.Spec.Tolerations)
assert.Equal(t, true, podSpec.Spec.HostNetwork)
assert.Equal(t, "test-priority-class", podSpec.Spec.PriorityClassName)
t.Run("exporter config", func(t *testing.T) {
cephCluster.Spec.Monitoring.Exporter = &cephv1.CephExporterSpec{
PerfCountersPrioLimit: 3,
StatsPeriodSeconds: 7,
}
res, err := r.createOrUpdateCephExporter(node, tolerations, cephCluster, cephVersion)
assert.NoError(t, err)
assert.Equal(t, controllerutil.OperationResult("updated"), res)
err = r.client.Get(ctx, types.NamespacedName{Namespace: "rook-ceph", Name: name}, &deploy)
assert.NoError(t, err)
podSpec := deploy.Spec.Template
args := podSpec.Spec.Containers[0].Args
assert.Equal(t, "--prio-limit", args[4])
assert.Equal(t, "3", args[5])
assert.Equal(t, "--stats-period", args[6])
assert.Equal(t, "7", args[7])
})
}
func TestCephExporterBindAddress(t *testing.T) {