microsoft / ApplicationInsights-Kubernetes

Enrich the telemetry data for .NET applications running inside containers that are managed by Kubernetes.
Other
135 stars 57 forks source link

Warning in pod logs re failed to get container id #361

Open LyndonHills opened 4 months ago

LyndonHills commented 4 months ago

Package version is Microsoft.ApplicationInsights.Kubernetes 6.1.1. Service is aspnetcore net 8.0.

docker images are

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base WORKDIR /app EXPOSE 8080

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build

Deployed a service to Kubernetes, then run kubectl logs

See this in the pod logs: [Warning] [2024-02-16T12:05:18.2071256Z] [CGroupContainerIdProvider] Can't figure out container id. [Warning] [2024-02-16T12:05:18.2093841Z] [ContainerDMountInfoContainerIdProvider] Can't figure out container id. [Warning] [2024-02-16T12:05:18.2103865Z] [DockerEngineMountInfoContainerIdProvider] Can't figure out container id. [Information] [2024-02-16T12:05:18.2107327Z] No container id found by container id providers. [Warning] [2024-02-16T12:05:18.2108244Z] Can't fetch container id. Container id info will be missing. Please file an issue at https://github.com/microsoft/ApplicationInsights-Kubernetes/issues. [Information] [2024-02-16T12:05:18.2122355Z] Selected container container id: containerd://895d944a53c65a1e91c72e36f3ffeb699f62d225ca06020a4675d1c4620e8bc0

Only warnings so not a 'problem' logging issue per the message in the logs.

xiaomi7732 commented 4 months ago

Hmm, that is interesting because from the last line of the log, it looks like the container id is eventually available. Is it too early a conclusion that throws the warning off? I'll check the implementations. Thanks for the report.

xiaomi7732 commented 3 months ago

Hey @LyndonHills, can you confirm is the container id picked (895d944a53c65a1e91c72e36f3ffeb699f62d225ca06020a4675d1c4620e8bc0) the correct container id?

LyndonHills commented 3 months ago

@xiaomi7732 I had to do another deploy, but yes the container id in the last log message starting with Selected container container id is the correct containerid.

Today's deploy

...

[Warning] [2024-03-26T10:25:55.0156710Z] Can't fetch container id. Container id info will be missing. Please file an issue at https://github.com/microsoft/ApplicationInsights-Kubernetes/issues. [Information] [2024-03-26T10:25:55.0172299Z] Selected container email-microservice container id: containerd://8e17c2e0e2fcc362f646bab90b567cf013735cc1bac85e93961376dfb0b61913

the container id 8e17... is correct.

xiaomi7732 commented 3 months ago

@LyndonHills Thanks for the confirming. It then points the direction to the over aggressive logging. I'll make a fix for that.

xiaomi7732 commented 3 weeks ago

@LyndonHills There has been some tricky cases getting container id reliably. The reason you have it is because you only have 1 container in a pod and thus we are able to use that. I'll, for now, update the logging to disclose more details, and keep looking for ways to improve the detection.

xiaomi7732 commented 2 weeks ago

The change is in. See the PR above for details. Since this is logging only, considering roll it together with some other changes.