How and where to set newrelic.config.file

Hello Everyone,

I will try to explain my problem first, please bear with me.

I am trying to monitor three JVMS(containers) residing on a single virtual machine.
I would like to use single new relic.jar for this. I have copied it in local VM storage and mounted it in docker containers of all three JVMs.

Now i would like to expose JMX metrics from these JVMs and i understand i need to write extensions for the same and mention the path in new relic.yml.

I will need to write three different extension files i presume.

I was wondering if i could create different config file for different agents , may be i can mention different extension folder in those config files.

So i was trying to figure out how to set config file for new relic agent at runtime.
I hope i have given complete context of my problem , feel free to give any feedback.

Sample docker-compose:

restproxy:
image: kafka-rest-mr-service
network_mode: host
depends_on:
- zookeeper
ports:
- ‘8082:8082’
environment:
KAFKA_REST_ZOOKEEPER_CONNECT: localhost:32181
KAFKA_REST_LISTENERS: XXXXXXX
KAFKA_REST_SCHEMA_REGISTRY_URL: XXXXXXXXX
KAFKA_REST_HOST_NAME: localhost
KAFKA_REST_ID: inst1
KAFKAREST_JMX_OPTS: “-Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=10.102.53.22 -Dcom.sun.management.jmxremote.rmi.port=1098”
JMX_PORT: 1098
KAFKA_JVM_PERFORMANCE_OPTS: “-server -XX:+UseG1GC -XX:MaxGCPauseMillis=20 -XX:InitiatingHeapOccupancyPercent=35 -XX:+DisableExplicitGC -Djava.awt.headless=true -javaagent:/root/newrelic/newrelic/newrelic.jar”
volumes:
- /root/newrelic/newrelic/:/root/newrelic/newrelic/

Please vote for my feature request: https://discuss.newrelic.com/t/feature-idea-specify-extensions-dir-as-url/49972?u=wkinewrelic I think this would also help in your scenario.

1 Like

@wkiNewRelic Your feature request is indeed useful , I will vote for it. However its not what i am looking for. I read your request details and you mentioned you are using custom.yml file for all those web applications. My question was more about how to make your application use that custom.yml instead of the default one: newrelic.yml. In documentations its mentioned we can use newrelic.config.file but i couldn’t understand where i need to set this option.

Please help if possible. My applications are container based and i am using docker-compose to spawn them , please advise.

Thanks.

Hi, @mail.yogesh.gupta: You may override the default config file location by setting the newrelic.config.file system property. For more information about setting Java system properties, you may find this article helpful: http://www.avajava.com/tutorials/lessons/how-do-i-set-system-properties.html.

@philweber Thanks for taking time to respond. I figured it out myself. We need to set it in docker compose like this:

KAFKA_JVM_PERFORMANCE_OPTS: “-server -XX:+UseG1GC -XX:MaxGCPauseMillis=20 -XX:InitiatingHeapOccupancyPercent=35 -XX:+DisableExplicitGC -Djava.awt.headless=true -javaagent:/newrelic/newrelic.jar -Dnewrelic.config.file=/home/ubuntu/newrelic/zk_newrelic.yml”

@mail.yogesh.gupta Thanks for sharing your solution! We are glad to hear you were able to figure it out.