Skip to content

Commit c15f1c6

Browse files
authored
[kubernetes] Add hostmetrics recevier doc (#3118)
1 parent 8e5cc50 commit c15f1c6

File tree

1 file changed

+94
-1
lines changed

1 file changed

+94
-1
lines changed

content/en/docs/kubernetes/collector/components.md

Lines changed: 94 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Important Components for Kubernetes
33
linkTitle: Components
44
# prettier-ignore
5-
cSpell:ignore: alertmanagers containerd crio filelog gotime horizontalpodautoscalers iostream k8sattributes kubelet kubeletstats logtag replicasets replicationcontrollers resourcequotas statefulsets varlibdockercontainers varlogpods
5+
cSpell:ignore: alertmanagers containerd crio filelog gotime horizontalpodautoscalers hostfs hostmetrics iostream k8sattributes kubelet kubeletstats logtag replicasets replicationcontrollers resourcequotas statefulsets varlibdockercontainers varlogpods
66
---
77

88
The [OpenTelemetry Collector](/docs/collector/) supports many different
@@ -24,6 +24,8 @@ Components covered in this page:
2424
such as events, from the Kubernetes API server.
2525
- [Prometheus Receiver](#prometheus-receiver): receives metrics in
2626
[Prometheus](https://prometheus.io/) format.
27+
- [Host Metrics Receiver](#host-metrics-receiver): scrapes host metrics from
28+
Kubernetes nodes.
2729

2830
For application traces, metrics, or logs, we recommend the
2931
[OTLP receiver](https://github.com/open-telemetry/opentelemetry-collector/tree/main/receiver/otlpreceiver),
@@ -708,3 +710,94 @@ to tell a collector which Prometheus endpoints it should scrape.
708710

709711
For more information on the design of the receiver, see
710712
[Design](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/receiver/prometheusreceiver/DESIGN.md).
713+
714+
## Host Metrics Receiver
715+
716+
| Deployment Pattern | Usable |
717+
| -------------------- | -------------------------------------------------------------- |
718+
| DaemonSet (Agent) | Preferred |
719+
| Deployment (Gateway) | Yes, but only collects metrics from the node it is deployed on |
720+
| Sidecar | No |
721+
722+
The Host Metrics Receiver collects metrics from a host using a variety of
723+
scrapers. There is some overlap with the
724+
[Kubeletstats Receiver](#kubeletstats-receiver) so if you decide to use both, it
725+
may be worth it to disable these duplicate metrics.
726+
727+
In Kubernetes, the receiver needs access to the `hostfs` volume to work
728+
properly. If you're using the
729+
[OpenTelemetry Collector Helm chart](../../helm/collector/) you can use the
730+
[`hostMetrics` preset](../../helm/collector/#host-metrics-preset) to get
731+
started.
732+
733+
The available scrapers are:
734+
735+
| Scraper | Supported OSs | Description |
736+
| ---------- | ------------------- | ------------------------------------------------------ |
737+
| cpu | All except Mac[^1] | CPU utilization metrics |
738+
| disk | All except Mac[^1] | Disk I/O metrics |
739+
| load | All | CPU load metrics |
740+
| filesystem | All | File System utilization metrics |
741+
| memory | All | Memory utilization metrics |
742+
| network | All | Network interface I/O metrics & TCP connection metrics |
743+
| paging | All | Paging/Swap space utilization and I/O metrics |
744+
| processes | Linux, Mac | Process count metrics |
745+
| process | Linux, Windows, Mac | Per process CPU, Memory, and Disk I/O metrics |
746+
747+
[^1]:
748+
Not supported on Mac when compiled without cgo, which is the default for the
749+
images released by the Collector SIG.
750+
751+
For specific details about which metrics are collected and specific
752+
configuration details, see
753+
[Host Metrics Receiver](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/hostmetricsreceiver).
754+
755+
If you need to configure the component yourself, make sure to mount the `hostfs`
756+
volume if you want to collect the node's metrics and not the container's.
757+
758+
```yaml
759+
---
760+
apiVersion: apps/v1
761+
kind: DaemonSet
762+
...
763+
spec:
764+
...
765+
template:
766+
...
767+
spec:
768+
...
769+
containers:
770+
- name: opentelemetry-collector
771+
...
772+
volumeMounts:
773+
...
774+
- name: hostfs
775+
mountPath: /hostfs
776+
readOnly: true
777+
mountPropagation: HostToContainer
778+
volumes:
779+
...
780+
- name: hostfs
781+
hostPath:
782+
path: /
783+
...
784+
```
785+
786+
and then configure the Host Metrics Receiver to use the `volumeMount`:
787+
788+
```yaml
789+
receivers:
790+
hostmetrics:
791+
root_path: /hostfs
792+
collection_interval: 10s
793+
scrapers:
794+
cpu:
795+
load:
796+
memory:
797+
disk:
798+
filesystem:
799+
network:
800+
```
801+
802+
For more details about using the receiver in a container, see
803+
[Collecting host metrics from inside a container (Linux only)](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/hostmetricsreceiver#collecting-host-metrics-from-inside-a-container-linux-only)

0 commit comments

Comments
 (0)