Skip to content

Commit

Permalink
feat: Add a selector for runtime volume metrics (#1486)
Browse files Browse the repository at this point in the history
  • Loading branch information
shorim authored Oct 11, 2024
1 parent eadeaaa commit 7adb021
Show file tree
Hide file tree
Showing 34 changed files with 798 additions and 148 deletions.
6 changes: 5 additions & 1 deletion apis/telemetry/v1alpha1/metricpipeline_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ type MetricPipelineRuntimeInput struct {
Namespaces *MetricPipelineInputNamespaceSelector `json:"namespaces,omitempty"`
// Describes the Kubernetes resources for which runtime metrics are scraped.
// +optional
// +kubebuilder:default={pod: {enabled: true}, container: {enabled: true}, node: {enabled: false}}
// +kubebuilder:default={pod: {enabled: true}, container: {enabled: true}, node: {enabled: false}, volume: {enabled: false}}
Resources *MetricPipelineRuntimeInputResources `json:"resources,omitempty"`
}

Expand All @@ -121,6 +121,10 @@ type MetricPipelineRuntimeInputResources struct {
// +optional
// +kubebuilder:default={enabled: false}
Node *MetricPipelineRuntimeInputResourceDisabledByDefault `json:"node,omitempty"`
// Configures Volume runtime metrics scraping.
// +optional
// +kubebuilder:default={enabled: false}
Volume *MetricPipelineRuntimeInputResourceDisabledByDefault `json:"volume,omitempty"`
}

// MetricPipelineRuntimeInputResourceEnabledByDefault defines if the scraping of runtime metrics is enabled for a specific resource. The scraping is enabled by default.
Expand Down
5 changes: 5 additions & 0 deletions apis/telemetry/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion apis/telemetry/v1beta1/metricpipeline_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ type MetricPipelineRuntimeInput struct {
Namespaces *MetricPipelineInputNamespaceSelector `json:"namespaces,omitempty"`
// Describes the Kubernetes resources for which runtime metrics are scraped.
// +optional
// +kubebuilder:default={pod: {enabled: true}, container: {enabled: true}, node: {enabled: false}}
// +kubebuilder:default={pod: {enabled: true}, container: {enabled: true}, node: {enabled: false}, volume: {enabled: false}}
Resources *MetricPipelineRuntimeInputResources `json:"resources,omitempty"`
}

Expand All @@ -108,6 +108,10 @@ type MetricPipelineRuntimeInputResources struct {
// +optional
// +kubebuilder:default={enabled: false}
Node *MetricPipelineRuntimeInputResourceDisabledByDefault `json:"node,omitempty"`
// Configures Volume runtime metrics scraping.
// +optional
// +kubebuilder:default={enabled: false}
Volume *MetricPipelineRuntimeInputResourceDisabledByDefault `json:"volume,omitempty"`
}

// MetricPipelineRuntimeInputResourceEnabledByDefault defines if the scraping of runtime metrics is enabled for a specific resource. The scraping is enabled by default.
Expand Down
5 changes: 5 additions & 0 deletions apis/telemetry/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions config/busola/metricpipeline_busola_extension_cm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ data:
- name: Node
visibility: $exists(spec.input.runtime.resources.node)
source: spec.input.runtime.resources.node.enabled
- name: Volume
visibility: $exists(spec.input.runtime.resources.volume)
source: spec.input.runtime.resources.volume.enabled
- name: OTLP
widget: Panel
visibility: $exists(spec.input.otlp)
Expand Down Expand Up @@ -344,6 +347,9 @@ data:
- name: Enable Node Metrics
path: node.enabled
simple: true
- name: Enable Volume Metrics
path: volume.enabled
simple: true
- name: OTLP
path: otlp
widget: FormGroup
Expand Down
13 changes: 13 additions & 0 deletions config/crd/bases/telemetry.kyma-project.io_metricpipelines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ spec:
enabled: false
pod:
enabled: true
volume:
enabled: false
description: Describes the Kubernetes resources for which
runtime metrics are scraped.
properties:
Expand Down Expand Up @@ -259,6 +261,17 @@ spec:
resource are scraped. The default is `true`.
type: boolean
type: object
volume:
default:
enabled: false
description: Configures Volume runtime metrics scraping.
properties:
enabled:
default: false
description: If enabled, the runtime metrics for the
resource are scraped. The default is `false`.
type: boolean
type: object
type: object
type: object
type: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ spec:
enabled: false
pod:
enabled: true
volume:
enabled: false
description: Describes the Kubernetes resources for which
runtime metrics are scraped.
properties:
Expand Down Expand Up @@ -259,6 +261,17 @@ spec:
resource are scraped. The default is `true`.
type: boolean
type: object
volume:
default:
enabled: false
description: Configures Volume runtime metrics scraping.
properties:
enabled:
default: false
description: If enabled, the runtime metrics for the
resource are scraped. The default is `false`.
type: boolean
type: object
type: object
type: object
type: object
Expand Down Expand Up @@ -825,6 +838,8 @@ spec:
enabled: false
pod:
enabled: true
volume:
enabled: false
description: Describes the Kubernetes resources for which
runtime metrics are scraped.
properties:
Expand Down Expand Up @@ -861,6 +876,17 @@ spec:
resource are scraped. The default is `true`.
type: boolean
type: object
volume:
default:
enabled: false
description: Configures Volume runtime metrics scraping.
properties:
enabled:
default: false
description: If enabled, the runtime metrics for the
resource are scraped. The default is `false`.
type: boolean
type: object
type: object
type: object
type: object
Expand Down
1 change: 1 addition & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ rules:
- namespaces/status
- nodes
- nodes/metrics
- nodes/proxy
- nodes/spec
- nodes/stats
- pods
Expand Down
13 changes: 11 additions & 2 deletions docs/user/04-metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Optionally, the Telemetry module provides a DaemonSet of an OTel Collector actin
1. An application (exposing metrics in OTLP) sends metrics to the central metric gateway service.
2. An application (exposing metrics in Prometheus protocol) activates the agent to scrape the metrics with an annotation-based configuration.
3. Additionally, you can activate the agent to pull metrics of each Istio sidecar.
4. The agent supports collecting container metrics from the Kubelet and Kubernetes APIServer.
4. The agent supports collecting metrics from the Kubelet and Kubernetes APIServer.
5. The agent converts and sends all collected metric data to the gateway in OTLP.
6. The gateway discovers the metadata and enriches all received data with typical metadata of the source by communicating with the Kubernetes APIServer. Furthermore, it filters data according to the pipeline configuration.
7. Telemetry Manager configures the agent and gateway according to the `MetricPipeline` resource specification, including the target backend for the metric gateway. Also, it observes the metrics flow to the backend and reports problems in the MetricPipeline status.
Expand Down Expand Up @@ -414,13 +414,15 @@ The following example collects only the Pod metrics:
enabled: false
node:
enabled: false
volume:
enabled: false
output:
otlp:
endpoint:
value: https://backend.example.com:4317
```

If you enable Pod metrics, the following metrics are collected:
If Pod metrics are enabled, the following metrics are collected:

- From the [kubletstatsreceiver](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/kubeletstatsreceiver):
- `k8s.pod.cpu.capacity`
Expand Down Expand Up @@ -470,6 +472,13 @@ If Node metrics are enabled, the following metrics are collected:
- `k8s.node.memory.rss`
- `k8s.node.memory.working_set`

If Volume metrics are enabled, the following metrics are collected:
- From the [kubletstatsreceiver](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/kubeletstatsreceiver):
- `k8s.volume.available`
- `k8s.volume.capacity`
- `k8s.volume.inodes`
- `k8s.volume.inodes.free`
- `k8s.volume.inodes.used`

### 7. Activate Istio Metrics

Expand Down
2 changes: 1 addition & 1 deletion docs/user/assets/metrics-arch.drawio.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions docs/user/resources/05-metricpipeline.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ For details, see the [MetricPipeline specification file](https://github.com/kyma
| **input.​runtime.​resources.​node.​enabled** | boolean | If enabled, the runtime metrics for the resource are scraped. The default is `false`. |
| **input.​runtime.​resources.​pod** | object | Configures Pod runtime metrics scraping. |
| **input.​runtime.​resources.​pod.​enabled** | boolean | If enabled, the runtime metrics for the resource are scraped. The default is `true`. |
| **input.​runtime.​resources.​volume** | object | Configures Volume runtime metrics scraping. |
| **input.​runtime.​resources.​volume.​enabled** | boolean | If enabled, the runtime metrics for the resource are scraped. The default is `false`. |
| **output** | object | Configures the metric gateway. |
| **output.​otlp** (required) | object | Defines an output using the OpenTelemetry protocol. |
| **output.​otlp.​authentication** | object | Defines authentication options for the OTLP output |
Expand Down
15 changes: 9 additions & 6 deletions internal/otelcollector/config/metric/agent/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ type Receivers struct {
}

type KubeletStatsReceiver struct {
CollectionInterval string `yaml:"collection_interval"`
AuthType string `yaml:"auth_type"`
Endpoint string `yaml:"endpoint"`
InsecureSkipVerify bool `yaml:"insecure_skip_verify"`
MetricGroups []MetricGroupType `yaml:"metric_groups"`
Metrics KubeletStatsMetricsConfig `yaml:"metrics"`
CollectionInterval string `yaml:"collection_interval"`
AuthType string `yaml:"auth_type"`
Endpoint string `yaml:"endpoint"`
InsecureSkipVerify bool `yaml:"insecure_skip_verify"`
MetricGroups []MetricGroupType `yaml:"metric_groups"`
Metrics KubeletStatsMetricsConfig `yaml:"metrics"`
ExtraMetadataLabels []string `yaml:"extra_metadata_labels,omitempty"`
}

type MetricConfig struct {
Expand All @@ -55,6 +56,7 @@ const (
MetricGroupTypeContainer MetricGroupType = "container"
MetricGroupTypePod MetricGroupType = "pod"
MetricGroupTypeNode MetricGroupType = "node"
MetricGroupTypeVolume MetricGroupType = "volume"
)

type PrometheusReceiver struct {
Expand Down Expand Up @@ -128,6 +130,7 @@ type Processors struct {
SetInstrumentationScopePrometheus *metric.TransformProcessor `yaml:"transform/set-instrumentation-scope-prometheus,omitempty"`
SetInstrumentationScopeIstio *metric.TransformProcessor `yaml:"transform/set-instrumentation-scope-istio,omitempty"`
InsertSkipEnrichmentAttribute *metric.TransformProcessor `yaml:"transform/insert-skip-enrichment-attribute,omitempty"`
DropNonPVCVolumesMetrics *FilterProcessor `yaml:"filter/drop-non-pvc-volumes-metrics,omitempty"`
}

type Exporters struct {
Expand Down
Loading

0 comments on commit 7adb021

Please sign in to comment.