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 service name as attribute #31409

Closed
dhilgarth opened this issue Feb 26, 2024 · 3 comments
Closed

Add service name as attribute #31409

dhilgarth opened this issue Feb 26, 2024 · 3 comments
Labels
enhancement New feature or request needs triage New item requiring triage receiver/dockerstats

Comments

@dhilgarth
Copy link

dhilgarth commented Feb 26, 2024

Component(s)

receiver/dockerstats

Is your feature request related to a problem? Please describe.

In Docker Swarm, the unit of aggregation I often care about is the total usage of a service per host.
This is currently not possible.

Describe the solution you'd like

Add a new attribute for the service name

Describe alternatives you've considered

  • grouping by container_image_name, host_name (from OTEL_RESOURCE_ATTRIBUTES): Close, but I could have different services using the same image and also, I am looking for the service name, so I would need to deduct the service name from the image name
  • Derive from container_name, e.g. via label_replace in PromQL: Works, but is quite a handful which I would need to use in each query instead of simply selecting the label. For reference: label_replace(container_memory_usage_total, "container_service_name", "$1", "container_name", "^([^.]+)\\..*")

Additional context

No response

@dhilgarth dhilgarth added enhancement New feature or request needs triage New item requiring triage labels Feb 26, 2024
Copy link
Contributor

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@jamesmoessis
Copy link
Contributor

@dhilgarth have you considered using the resourceprocessor to add the service name attribute?

@dhilgarth
Copy link
Author

dhilgarth commented Feb 29, 2024

@jamesmoessis Thanks, this works beautifully

receivers:
  ...
  docker_stats:
    ...

processors:
  ...
  resource:
    attributes:
      - key: container.name
        pattern: ^(?P<container_service_name>[^.]+)\..*
        action: extract

exporters:
  ...

service:
  pipelines:
    ...
    metrics/generic:
      receivers: [ docker_stats, ... ]
      processors: [ resource, ... ]
      exporters: [ ... ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs triage New item requiring triage receiver/dockerstats
Projects
None yet
Development

No branches or pull requests

2 participants