Used memory percentage of pod running in K8s

Get Total Memory or Used memory percentage of a DotNet process running in K8S contrainer

I can use the following request to retrieve the used memory of my dotnet process running in K8S container

curl -X GET 'https://api.newrelic.com/v2/applications/$APP_ID/hosts/$HOST_ID/metrics/data.json' \
     -H 'X-Api-Key:$API_KEY' -i \
     -G -d 'names[]=Memory/Physical&names[]=Memory/WorkingSet&period=60' 

I also need the pertentage of used memory.
Because the application is running in container, if there is a limitation configured for Pod’s RAM, then that’s the total RAM size available for the pod.

Percentage = Used RAM Size / POD RAM Size max limit

Otherwise all the host RAM is available to the container

Percentage = Used RAM Size / Host RAM Size

This information is available in Kubernetes, not sure if it can be seen from NewRelic via API.

Hi @jerry.wang

Thanks for reaching out, I hope you are well.

I had a look at the app in APM UI, for an app I believe New Relic display the memory consumed.

I will need to do a little more digging as I am not an expert in this area , and see if having a percentage option is possible. Please allow me some time to loop in with some K8’s experts and provide feedback here.

1 Like

@jerry.wang - I don’t believe that data is available from the APM API endpoint. However, you can use Nerdgraph to run a NRQL query for that data.

can you please provide an example

Hi @jerry.wang

Normally New Relic support doesn’t support creating queries for users. However i will go ahead and create a case to get this looked at and perhaps see if there are any additional work arounds.

Please note the team will reach out via email soon.