apm-agent-dotnet icon indicating copy to clipboard operation
apm-agent-dotnet copied to clipboard

[BUG] Can't parse container ID when running on AWS ECS/Fargate

Open fruffin opened this issue 2 years ago • 0 comments

APM Agent version

Elastic.Apm.NetCoreAll 1.16.1

Environment

Operating system and version: Debian 11 on AWS ECS/Fargate

.NET Framework/Core name and version (e.g. .NET 4.6.1, NET Core 3.1.100) : ASP.Net 6

Application Target Framework(s) (e.g. net461, netcoreapp3.1): net6.0

Describe the bug

When running on a linux container on Amazon ECS/Fargate, APM fails to parse the container ID correctly due to AWS very specific cgroup format.

When querying /proc/self/cgroup on ECS/Fargate containers, each line looks something like this: 1:name=systemd:/ecs/03752a671e744971a862edcee6195646/03752a671e744971a862edcee6195646-4015103728

The container ID is whatever is after the last forward slash but doesn't match the Regex expected by the SystemInfoHelper class of Elastic.Apm. This causes the library to think it is not running in a container, causing issues gathering CPU/memory metrics, which then cause errors in Kibana: search_phase_execution_exception: [script_exception] Reason: runtime error (500) URL

To Reproduce

Steps to reproduce the behavior:

  1. Create a new asp.net core application
  2. Add Elastic AP
  3. Run on AWS ECS/Fargate

Expected behavior

The container ID should be correctly parsed so that metrics can be collected.

Actual behavior

This causes the library to think it is not running in a container, causing issues gathering CPU/memory metrics, which then cause errors in Kibana: search_phase_execution_exception: [script_exception] Reason: runtime error (500) URL

Pull request to fix this issue coming shortly.

fruffin avatar Aug 10 '22 02:08 fruffin