Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clarify how to collect host.id for non-containerized systems #3173

Merged
merged 3 commits into from
Feb 28, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ release.

### Resource

- Clarify how to collect `host.id` for non-containerized systems.
([#3173](https://github.com/open-telemetry/opentelemetry-specification/pull/3173))

### Semantic Conventions

- Enable semantic convention tooling for metrics in spec
Expand Down
3 changes: 2 additions & 1 deletion semantic_conventions/resource/host.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ groups:
type: string
brief: >
Unique host ID. For Cloud, this must be the instance_id assigned by the cloud provider.
For non-containerized Linux systems, the `machine-id` located in `/etc/machine-id` or `/var/lib/dbus/machine-id` may be used.
For non-containerized systems, this should be the `machine-id`. See the table below for
the sources to use to determine the `machine-id` based on operating system.
examples: ['fdbf79e8af94cb7f9e8df36789187052']
- id: name
type: string
Expand Down
28 changes: 27 additions & 1 deletion specification/resource/semantic_conventions/host.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<!-- semconv host -->
| Attribute | Type | Description | Examples | Requirement Level |
|---|---|---|---|---|
| `host.id` | string | Unique host ID. For Cloud, this must be the instance_id assigned by the cloud provider. For non-containerized Linux systems, the `machine-id` located in `/etc/machine-id` or `/var/lib/dbus/machine-id` may be used. | `fdbf79e8af94cb7f9e8df36789187052` | Recommended |
| `host.id` | string | Unique host ID. For Cloud, this must be the instance_id assigned by the cloud provider. For non-containerized systems, this should be the `machine-id`. See the table below for the sources to use to determine the `machine-id` based on operating system. | `fdbf79e8af94cb7f9e8df36789187052` | Recommended |
| `host.name` | string | Name of the host. On Unix systems, it may contain what the hostname command returns, or the fully qualified hostname, or another name specified by the user. | `opentelemetry-test` | Recommended |
| `host.type` | string | Type of host. For Cloud, this must be the machine type. | `n1-standard-1` | Recommended |
| `host.arch` | string | The CPU architecture the host system is running on. | `amd64` | Recommended |
Expand All @@ -30,3 +30,29 @@
| `s390x` | IBM z/Architecture |
| `x86` | 32-bit x86 |
<!-- endsemconv -->

## Collecting host.id from non-containerized systems

### Non-privileged Machine ID Lookup

When collecting `host.id` for non-containerized systems non-privileged lookups
of the machine id are preferred. SDK detector implementations MUST use the
arminru marked this conversation as resolved.
Show resolved Hide resolved
sources listed below to obtain the machine id.

| OS | Primary | Fallback |
|---------|-------------------------------------------------------------------------------------|----------------------------------------|
| Linux | contents of `/etc/machine-id` | contents of `/var/lib/dbus/machine-id` |
| BSD | contents of `/etc/hostid` | output of `kenv -q smbios.system.uuid` |
| MacOS | `IOPlatformUUID` line from the output of `ioreg -rd1 -c "IOPlatformExpertDevice"` | - |
| Windows | `MachineGuid` from registry `HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography` | - |

### Privileged Machine ID Lookup

The `host.id` can be looked up using privileged sources. For example, Linux
systems can use the output of `dmidecode -t system`, `dmidecode -t baseboard`,
`dmidecode -t chassis`, or read the corresponding data from the filesystem
(e.g. `cat /sys/devices/virtual/dmi/id/product_id`,
`cat /sys/devices/virtual/dmi/id/product_uuid`, etc), however, SDK resource
detector implementations MUST not collect `host.id` from privileged sources. If
privileged lookup of `host.id` is required, the value should be injected via the
`OTEL_RESOURCE_ATTRIBUTES` environment variable.