Skip to content

Commit

Permalink
Add container imageID and command optional resource attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
marcsanmi committed Jun 26, 2023
1 parent a7045cb commit 5efda2c
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 3 deletions.
2 changes: 2 additions & 0 deletions receiver/dockerstatsreceiver/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -718,8 +718,10 @@ Time elapsed since container start time.

| Name | Description | Values | Enabled |
| ---- | ----------- | ------ | ------- |
| container.command | The command executed by the container. | Any Str | false |
| container.hostname | The hostname of the container. | Any Str | true |
| container.id | The ID of the container. | Any Str | true |
| container.image.id | The ID of the container image. | Any Str | false |
| container.image.name | The name of the docker image in use by the container. | Any Str | true |
| container.name | The name of the container. | Any Str | true |
| container.runtime | The runtime of the container. For this receiver, it will always be 'docker'. | Any Str | true |

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.

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 @@ -136,10 +136,14 @@ all_set:
container.uptime:
enabled: true
resource_attributes:
container.command:
enabled: true
container.hostname:
enabled: true
container.id:
enabled: true
container.image.id:
enabled: true
container.image.name:
enabled: true
container.name:
Expand Down Expand Up @@ -283,10 +287,14 @@ none_set:
container.uptime:
enabled: false
resource_attributes:
container.command:
enabled: false
container.hostname:
enabled: false
container.id:
enabled: false
container.image.id:
enabled: false
container.image.name:
enabled: false
container.name:
Expand Down
8 changes: 8 additions & 0 deletions receiver/dockerstatsreceiver/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ resource_attributes:
description: "The hostname of the container."
type: string
enabled: true
container.image.id:
description: "The ID of the container image."
type: string
enabled: false
container.command:
description: "The command executed by the container."
type: string
enabled: false

attributes:
core:
Expand Down
5 changes: 4 additions & 1 deletion receiver/dockerstatsreceiver/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,10 @@ func (r *receiver) recordContainerStats(now pcommon.Timestamp, containerStats *d
metadata.WithContainerHostname(container.Config.Hostname),
metadata.WithContainerID(container.ID),
metadata.WithContainerImageName(container.Config.Image),
metadata.WithContainerName(strings.TrimPrefix(container.Name, "/")))
metadata.WithContainerName(strings.TrimPrefix(container.Name, "/")),
metadata.WithContainerImageID(container.Image),
metadata.WithContainerCommand(strings.Join(container.Config.Cmd, ",")),
)

for k, label := range r.config.EnvVarsToMetricLabels {
label := label
Expand Down

0 comments on commit 5efda2c

Please sign in to comment.