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

How to configure .net application running in kubernetes pod to see the APM data of app in the newrelic APM tab? #1072

Open
Amit-limbasiya opened this issue Jun 20, 2024 · 1 comment
Labels
bug Categorizes issue or PR as related to a bug.

Comments

@Amit-limbasiya
Copy link

I have the application running inside the kubernetes pod.

I have installed the newrelic dotnet agent in the kubernetes daemonset via helm command shown in the offical documentation.

Now I want that this .net agent will identify the dotnet application running inside the pod and forward its log as well as APM data like avg response time, % of error etc.

Currently when the application starts i.e. pod is up and running, it is sending the logs in the kubernetes section in newrelic account. where I can see the logs and filter them by pod name or container name. But I cant see the APM data or application in the APM tab. How/what to configure to see the APM data of the application.

New relic dotnet agent installed in the kubernetes daemonset.

I have added two nuget packages in the application:

<PackageReference Include="Serilog.AspNetCore" Version="8.0.1" />
<PackageReference Include="Serilog.Sinks.NewRelic" Version="2.0.0" />

In the launchSettings.json I have added the following environment variables:

"ASPNETCORE_ENVIRONMENT": "Development",
"CORECLR_ENABLE_PROFILING": "1"

I have configured the serilog as following in the appsettings.json:

"Serilog": {
"Properties": {
"app": "test_api",
"Application": "test_api"
},
"WriteTo": {
"NewRelicLogsSink": {
"Name": "NewRelic",
"Args": {
"applicationName": "test_api"
}
}
}
},

Create and Use the log in program.cs:
Creation:

var logger = new LoggerConfiguration()
.ReadFrom.Configuration(builder.Configuration, "Serilog")
.Enrich.FromLogContext()
.CreateLogger();

builder.Logging.ClearProviders();
builder.Logging.AddSerilog(logger);

Use:
Log.Information("This is get endpoint from test api");

pod.yaml file

apiVersion: v1
kind: Pod
metadata:
  name: test-api-serilog-pod
  labels:
    app: test-api-serilog
spec:
  containers:
    - name: test-api-serilog-container
      image: test-api-serilog:latest
      imagePullPolicy: Never
      ports:
      - containerPort: 8080
      env:
      - name: ASPNETCORE_ENVIRONMENT
        value: "Development"
      - name: CORECLR_ENABLE_PROFILING
        value: "1"
      - name: NEW_RELIC_APP_NAME
        value: "A new test api serilog 2"        
      - name: NEW_RELIC_LOG
        value: "stdout"
      - name: NEW_RELIC_APPLICATION_LOGGING_ENABLED
        value: "true"
      - name: NEW_RELIC_APPLICATION_LOGGING_FORWARDING_ENABLED
        value: "true"
      - name: NEW_RELIC_LICENSE_KEY
        valueFrom:
          secretKeyRef: 
            name: newrelic-bundle-newrelic-logging-config
            key: license

I am able to get logs on the newrelic cloud, which I can filter by pod_name or container_name.

Expecting:
Now I want the APM Data in the newrelic cloud like avg.response time or % of error, type of error etc.
APM ss
Can't see the A new test api serilog 2 (Value of NEW_RELIC_APP_NAME) in the APM tag.
Additionally Inside the newrelic cloud Kubernetes->pods->test-api-serilog-pod I can see the logs of the pod but can't see the APM data.

Doubt:
Is it necessary to have the dotnet agent installed inside the application running container, Or can we configure the dotnet agent running in daemonset to send the APM data to newrelic as well?

@Amit-limbasiya Amit-limbasiya added the bug Categorizes issue or PR as related to a bug. label Jun 20, 2024
@workato-integration
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

No branches or pull requests

1 participant