Skip to content

Commit

Permalink
[receiver/podman] Add container.disk.io
Browse files Browse the repository at this point in the history
  • Loading branch information
tosuke committed Jul 6, 2024
1 parent 8804082 commit 9f7128a
Show file tree
Hide file tree
Showing 10 changed files with 146 additions and 4 deletions.
18 changes: 17 additions & 1 deletion receiver/podmanreceiver/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,22 @@ Total CPU time consumed.
| ---- | ----------- | ---------- | ----------------------- | --------- |
| s | Sum | Int | Cumulative | true |
### container.disk.io
Disk bytes for the container.
[More docs](https://www.kernel.org/doc/Documentation/cgroup-v1/blkio-controller.txt).
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
| ---- | ----------- | ---------- | ----------------------- | --------- |
| By | Sum | Int | Cumulative | true |
#### Attributes
| Name | Description | Values |
| ---- | ----------- | ------ |
| direction | The direction data is moving. | Str: ``transmit``, ``receive``, ``read``, ``write`` |
### container.memory.percent
Percentage of memory used.
Expand Down Expand Up @@ -128,7 +144,7 @@ Network bytes for the container.
| Name | Description | Values |
| ---- | ----------- | ------ |
| direction | The direction data is moving. | Str: ``transmit``, ``receive`` |
| direction | The direction data is moving. | Str: ``transmit``, ``receive``, ``read``, ``write`` |
### container.network.io.usage.rx_bytes
Expand Down
3 changes: 2 additions & 1 deletion receiver/podmanreceiver/generated_package_test.go

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

4 changes: 4 additions & 0 deletions receiver/podmanreceiver/internal/metadata/generated_config.go

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

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

69 changes: 69 additions & 0 deletions receiver/podmanreceiver/internal/metadata/generated_metrics.go

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

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

Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ all_set:
enabled: true
container.cpu.usage.total:
enabled: true
container.disk.io:
enabled: true
container.memory.percent:
enabled: true
container.memory.usage:
Expand Down Expand Up @@ -54,6 +56,8 @@ none_set:
enabled: false
container.cpu.usage.total:
enabled: false
container.disk.io:
enabled: false
container.memory.percent:
enabled: false
container.memory.usage:
Expand Down
13 changes: 12 additions & 1 deletion receiver/podmanreceiver/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ attributes:
direction:
description: "The direction data is moving."
type: string
enum: [transmit, receive]
enum: [transmit, receive, read, write]

metrics:
# CPU
Expand Down Expand Up @@ -144,6 +144,17 @@ metrics:
monotonic: true
aggregation_temporality: cumulative
# BlockIO
container.disk.io:
enabled: true
description: "Disk bytes for the container."
extended_documentation: "[More docs](https://www.kernel.org/doc/Documentation/cgroup-v1/blkio-controller.txt)."
unit: By
sum:
value_type: int
monotonic: true
aggregation_temporality: cumulative
attributes:
- direction
container.blockio.io_service_bytes_recursive.read:
enabled: true
description: "Number of bytes transferred from the disk by the container"
Expand Down
3 changes: 3 additions & 0 deletions receiver/podmanreceiver/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ func (r *metricsReceiver) recordMemoryMetrics(now pcommon.Timestamp, stats *cont
func (r *metricsReceiver) recordIOMetrics(now pcommon.Timestamp, stats *containerStats) {
r.mb.RecordContainerBlockioIoServiceBytesRecursiveReadDataPoint(now, int64(stats.BlockInput))
r.mb.RecordContainerBlockioIoServiceBytesRecursiveWriteDataPoint(now, int64(stats.BlockOutput))

r.mb.RecordContainerDiskIoDataPoint(now, int64(stats.BlockInput), metadata.AttributeDirectionRead)
r.mb.RecordContainerDiskIoDataPoint(now, int64(stats.BlockOutput), metadata.AttributeDirectionWrite)
}

// nanoseconds to seconds conversion truncating the fractional part
Expand Down
13 changes: 12 additions & 1 deletion receiver/podmanreceiver/record_metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func assertStatsEqualToMetrics(t *testing.T, podmanStats *containerStats, md pme
assert.Equal(t, rsm.ScopeMetrics().Len(), 1)

metrics := rsm.ScopeMetrics().At(0).Metrics()
assert.Equal(t, metrics.Len(), 14)
assert.Equal(t, metrics.Len(), 15)

for i := 0; i < metrics.Len(); i++ {
m := metrics.At(i)
Expand Down Expand Up @@ -70,6 +70,17 @@ func assertStatsEqualToMetrics(t *testing.T, podmanStats *containerStats, md pme
},
})

case "container.disk.io":
assertMetricEqual(t, m, pmetric.MetricTypeSum, []point{
{
intVal: podmanStats.BlockInput,
attributes: map[string]string{"direction": metadata.AttributeDirectionRead.String()},
},
{
intVal: podmanStats.BlockOutput,
attributes: map[string]string{"direction": metadata.AttributeDirectionWrite.String()},
},
})
case "container.blockio.io_service_bytes_recursive.write":
assertMetricEqual(t, m, pmetric.MetricTypeSum, []point{{intVal: podmanStats.BlockOutput}})
case "container.blockio.io_service_bytes_recursive.read":
Expand Down

0 comments on commit 9f7128a

Please sign in to comment.