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

Add container metrics fields from ECS #87

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
97 changes: 97 additions & 0 deletions semantic_conventions/metrics/container.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
groups:
- id: metric.container.cpu.usage
type: metric
metric_name: container.cpu.usage
Copy link
Member

@trask trask Aug 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this needed separate from system.cpu.*?

(there was some related discussion in open-telemetry/opentelemetry-specification#2388)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank's @trask! That's interesting one and it's quite similar to open-telemetry/opentelemetry-specification#2388 (comment).

I will try to share my view on this :).
So, from infrastructure's observability point of view, container metrics would be collected from outside the containers themselves (as a best practice).
For example by using the Docker runtime's APIs or Kubelet's API's.

So the point here is that it does not make a lot of sense to treat a container as a host and collect its metrics by running a collector inside the container.

So for metrics collected through the runtime/orchastrator APIs I think we need to be specific and have a resource specific namespace like container.cpu, pod.cpu etc.

In many cases the CPU/Memory resources are limited as well:

In very specific usecases, if someone wants to treat a container as a host (kind uses containers' as hosts) then the collector should be running on the container/host directly and report metrics under the system.* namespace. In that case the resource is a "host" not a container from the observation/collection point of view.

Also related to #226 (comment).

brief: "Recent CPU utilization for the container."
note: >
CPU usage percentage normalized by the number of CPU cores.
The value range is [0.0,1.0].
instrument: gauge
unit: "1"
attributes:
- ref: container.name
- ref: container.id
- ref: container.runtime
- ref: container.image.name
- ref: container.image.tag
- id: metric.container.memory.usage
type: metric
metric_name: container.memory.usage
brief: "Recent memory utilization for the container."
note: >
Memory usage percentage.
The value range is [0.0,1.0].
instrument: gauge
unit: "1"
attributes:
- ref: container.name
- ref: container.id
- ref: container.runtime
- ref: container.image.name
- ref: container.image.tag
- id: metric.container.disk.read.bytes
type: metric
metric_name: container.disk.read.bytes
brief: "Disk read bytes for the container."
note: >
The total number of bytes read
successfully (aggregated from all disks)
since the last metric collection.
instrument: gauge
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here: it's a counter

unit: "By"
attributes:
- ref: container.name
- ref: container.id
- ref: container.runtime
- ref: container.image.name
- ref: container.image.tag
- id: metric.container.disk.write.bytes
type: metric
metric_name: container.disk.write.bytes
brief: "Disk write bytes for the container."
note: >
The total number of bytes written
successfully (aggregated from all disks)
since the last metric collection
instrument: gauge
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unit: "By"
attributes:
- ref: container.name
- ref: container.id
- ref: container.runtime
- ref: container.image.name
- ref: container.image.tag
- id: metric.container.network.ingress.bytes
type: metric
metric_name: container.network.ingress.bytes
brief: "Network ingress bytes for the container."
note: >
The number of bytes received
on all network interfaces
by the container since
the last metric collection.
instrument: gauge
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should it be a counter?

unit: "By"
attributes:
- ref: container.name
- ref: container.id
- ref: container.runtime
- ref: container.image.name
- ref: container.image.tag
- id: metric.container.network.egress.bytes
type: metric
metric_name: container.network.egress.bytes
brief: "Network egress bytes for the container."
note: >
The number of bytes sent out
on all network interfaces
by the container since
the last metric collection.
instrument: gauge
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unit: "By"
attributes:
- ref: container.name
- ref: container.id
- ref: container.runtime
- ref: container.image.name
- ref: container.image.tag
129 changes: 129 additions & 0 deletions specification/metrics/semantic_conventions/container.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
<!--- Hugo front matter used to generate the website version of this page:
linkTitle: HTTP
--->

# Semantic Conventions for Container Metrics

**Status**: [Experimental][DocumentStatus]

## HTTP Server

### Metric: `metric.container.cpu.usage`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name should just be container.cpu.usage

The metric. classifier is for our YAML database, not the metric name. (Sorry for confusion)

Same comment for all other metrics.


This metric is optional.

<!-- semconv metric.container.cpu.usage(metric_table) -->
| Name | Instrument Type | Unit (UCUM) | Description |
| -------- | --------------- | ----------- | -------------- |
| `container.cpu.usage` | Gauge | `1` | Recent CPU utilization for the container. |
<!-- endsemconv -->

<!-- semconv metric.container.cpu.usage(full) -->
| Attribute | Type | Description | Examples | Requirement Level |
|---|---|---|---|---|
| [`container.id`](../../resource/semantic_conventions/container.md) | string | Container ID. Usually a UUID, as for example used to [identify Docker containers](https://docs.docker.com/engine/reference/run/#container-identification). The UUID might be abbreviated. | `a3bf90e006b2` | Recommended |
| [`container.image.name`](../../resource/semantic_conventions/container.md) | string | Name of the image the container was built on. | `gcr.io/opentelemetry/operator` | Recommended |
| [`container.image.tag`](../../resource/semantic_conventions/container.md) | string | Container image tag. | `0.1` | Recommended |
| [`container.name`](../../resource/semantic_conventions/container.md) | string | Container name used by container runtime. | `opentelemetry-autoconf` | Recommended |
| [`container.runtime`](../../resource/semantic_conventions/container.md) | string | The container runtime managing this container. | `docker`; `containerd`; `rkt` | Recommended |
<!-- endsemconv -->

### Metric: `metric.container.memory.usage`

This metric is optional.

<!-- semconv metric.container.memory.usage(metric_table) -->
| Name | Instrument Type | Unit (UCUM) | Description |
| -------- | --------------- | ----------- | -------------- |
| `container.memory.usage` | Gauge | `1` | Recent memory utilization for the container. |
<!-- endsemconv -->

<!-- semconv metric.container.memory.usage(full) -->
| Attribute | Type | Description | Examples | Requirement Level |
|---|---|---|---|---|
| [`container.id`](../../resource/semantic_conventions/container.md) | string | Container ID. Usually a UUID, as for example used to [identify Docker containers](https://docs.docker.com/engine/reference/run/#container-identification). The UUID might be abbreviated. | `a3bf90e006b2` | Recommended |
| [`container.image.name`](../../resource/semantic_conventions/container.md) | string | Name of the image the container was built on. | `gcr.io/opentelemetry/operator` | Recommended |
| [`container.image.tag`](../../resource/semantic_conventions/container.md) | string | Container image tag. | `0.1` | Recommended |
| [`container.name`](../../resource/semantic_conventions/container.md) | string | Container name used by container runtime. | `opentelemetry-autoconf` | Recommended |
| [`container.runtime`](../../resource/semantic_conventions/container.md) | string | The container runtime managing this container. | `docker`; `containerd`; `rkt` | Recommended |
<!-- endsemconv -->

### Metric: `metric.container.disk.read.bytes`

This metric is optional.

<!-- semconv metric.container.disk.read.bytes(metric_table) -->
| Name | Instrument Type | Unit (UCUM) | Description |
| -------- | --------------- | ----------- | -------------- |
| `container.disk.read.bytes` | Gauge | `By` | Disk read bytes for the container. |
<!-- endsemconv -->

<!-- semconv metric.container.disk.read.bytes(full) -->
| Attribute | Type | Description | Examples | Requirement Level |
|---|---|---|---|---|
| [`container.id`](../../resource/semantic_conventions/container.md) | string | Container ID. Usually a UUID, as for example used to [identify Docker containers](https://docs.docker.com/engine/reference/run/#container-identification). The UUID might be abbreviated. | `a3bf90e006b2` | Recommended |
| [`container.image.name`](../../resource/semantic_conventions/container.md) | string | Name of the image the container was built on. | `gcr.io/opentelemetry/operator` | Recommended |
| [`container.image.tag`](../../resource/semantic_conventions/container.md) | string | Container image tag. | `0.1` | Recommended |
| [`container.name`](../../resource/semantic_conventions/container.md) | string | Container name used by container runtime. | `opentelemetry-autoconf` | Recommended |
| [`container.runtime`](../../resource/semantic_conventions/container.md) | string | The container runtime managing this container. | `docker`; `containerd`; `rkt` | Recommended |
<!-- endsemconv -->

### Metric: `metric.container.disk.write.bytes`

This metric is optional.

<!-- semconv metric.container.disk.write.bytes(metric_table) -->
| Name | Instrument Type | Unit (UCUM) | Description |
| -------- | --------------- | ----------- | -------------- |
| `container.disk.write.bytes` | Gauge | `By` | Disk write bytes for the container. |
<!-- endsemconv -->

<!-- semconv metric.container.disk.write.bytes(full) -->
| Attribute | Type | Description | Examples | Requirement Level |
|---|---|---|---|---|
| [`container.id`](../../resource/semantic_conventions/container.md) | string | Container ID. Usually a UUID, as for example used to [identify Docker containers](https://docs.docker.com/engine/reference/run/#container-identification). The UUID might be abbreviated. | `a3bf90e006b2` | Recommended |
| [`container.image.name`](../../resource/semantic_conventions/container.md) | string | Name of the image the container was built on. | `gcr.io/opentelemetry/operator` | Recommended |
| [`container.image.tag`](../../resource/semantic_conventions/container.md) | string | Container image tag. | `0.1` | Recommended |
| [`container.name`](../../resource/semantic_conventions/container.md) | string | Container name used by container runtime. | `opentelemetry-autoconf` | Recommended |
| [`container.runtime`](../../resource/semantic_conventions/container.md) | string | The container runtime managing this container. | `docker`; `containerd`; `rkt` | Recommended |
<!-- endsemconv -->

### Metric: `metric.container.network.ingress.bytes`

This metric is optional.

<!-- semconv metric.container.network.ingress.bytes(metric_table) -->
| Name | Instrument Type | Unit (UCUM) | Description |
| -------- | --------------- | ----------- | -------------- |
| `container.network.ingress.bytes` | Gauge | `By` | Network ingress bytes for the container. |
<!-- endsemconv -->

<!-- semconv metric.container.network.ingress.bytes(full) -->
| Attribute | Type | Description | Examples | Requirement Level |
|---|---|---|---|---|
| [`container.id`](../../resource/semantic_conventions/container.md) | string | Container ID. Usually a UUID, as for example used to [identify Docker containers](https://docs.docker.com/engine/reference/run/#container-identification). The UUID might be abbreviated. | `a3bf90e006b2` | Recommended |
| [`container.image.name`](../../resource/semantic_conventions/container.md) | string | Name of the image the container was built on. | `gcr.io/opentelemetry/operator` | Recommended |
| [`container.image.tag`](../../resource/semantic_conventions/container.md) | string | Container image tag. | `0.1` | Recommended |
| [`container.name`](../../resource/semantic_conventions/container.md) | string | Container name used by container runtime. | `opentelemetry-autoconf` | Recommended |
| [`container.runtime`](../../resource/semantic_conventions/container.md) | string | The container runtime managing this container. | `docker`; `containerd`; `rkt` | Recommended |
<!-- endsemconv -->

### Metric: `metric.container.network.egress.bytes`

This metric is optional.

<!-- semconv metric.container.network.egress.bytes(metric_table) -->
| Name | Instrument Type | Unit (UCUM) | Description |
| -------- | --------------- | ----------- | -------------- |
| `container.network.egress.bytes` | Gauge | `By` | Network egress bytes for the container. |
<!-- endsemconv -->

<!-- semconv metric.container.network.egress.bytes(full) -->
| Attribute | Type | Description | Examples | Requirement Level |
|---|---|---|---|---|
| [`container.id`](../../resource/semantic_conventions/container.md) | string | Container ID. Usually a UUID, as for example used to [identify Docker containers](https://docs.docker.com/engine/reference/run/#container-identification). The UUID might be abbreviated. | `a3bf90e006b2` | Recommended |
| [`container.image.name`](../../resource/semantic_conventions/container.md) | string | Name of the image the container was built on. | `gcr.io/opentelemetry/operator` | Recommended |
| [`container.image.tag`](../../resource/semantic_conventions/container.md) | string | Container image tag. | `0.1` | Recommended |
| [`container.name`](../../resource/semantic_conventions/container.md) | string | Container name used by container runtime. | `opentelemetry-autoconf` | Recommended |
| [`container.runtime`](../../resource/semantic_conventions/container.md) | string | The container runtime managing this container. | `docker`; `containerd`; `rkt` | Recommended |
<!-- endsemconv -->