[Go] Invalid License Key 410 error on Go APM, but key works when used manually

Hello, I’ve an application that uses golang’s agent “github.com/newrelic/go-agent/v3/newrelic” but has the following error:

{"level":"info","msg":"application created","context":{"app":"APP NAME","enabled":true,"grpc-version":"1.27.0","version":"3.15.0"}}

{"level":"debug","msg":"rpm request","context":{"command":"preconnect","payload":[{"high_security":false}],"url":"https://collector.newrelic.com/agent_listener/invoke_raw_method?license_key=39..AL\u0026marshal_format=json\u0026method=preconnect\u0026protocol_version=17"}}

{"level":"debug","msg":"rpm failure","context":{"command":"preconnect","error":"response code: 410","response":"{\"exception\":{\"message\":\"Invalid license key\",\"error_type\":\"NewRelic::Agent::LicenseException\"}}","url":"https://collector.newrelic.com/agent_listener/invoke_raw_method?license_key=39..AL\u0026marshal_format=json\u0026method=preconnect\u0026protocol_version=17"}}

I use the same license key to send custom logs and it works there. (I POST to https://log-api.newrelic.com/log/v1)

The code to create the app is the same as mentioned on the newrelic page:

app, err := newrelic.NewApplication(
		newrelic.ConfigAppName("APP NAME"),
		newrelic.ConfigLicense(os.Getenv("NEW_RELIC_LICENSE_KEY")), //this is working, I also tried it hardcoded
		newrelic.ConfigDebugLogger(os.Stdout),
	)

And then it has a

router.HandleFunc(newrelic.WrapHandleFunc(app, endpoint, controller)).Methods(methodType)

For every endpoint

License key is of type
INGEST - LICENSE
Original account license key

Any Idea what could be the problem?

Hello @franco.primerano. Welcome to the Explorers Hub!

While the Go agent is out of my scope, I wanted to reach out and let you know I am looping in a support engineer to assist in answering your questions. I was also unable to access the link you provided to Github, so I would like to provide you with our Go agent documentation: https://docs.newrelic.com/docs/apm/agents/go-agent/get-started/introduction-new-relic-go/.

Please note that our support engineers will reach out here when available, but do reach out with any other questions you may have.

1 Like

Hi @franco.primerano

My name is Brian from NR support. Could you share with us the entire log file and the key that os.Getenv("NEW_RELIC_LICENSE_KEY") is pulling? It does appear you’re using the correct key, but without being able to check the entire thing I can’t be sure if this is just a typo or an unclear error. Feel free to send me the log in a DM and I’ll look it over for you.

Let me know if you have any questions.

Thank you for answering, I’ll send the full log in a DM.

Hi @franco.primerano, I got the logs, thanks for sending them.

This is interesting because a 410 error could mean other things. You’re specifically getting a message about the key being an issue, but it also appears your key is correct. Could you try an experiment for me?

  • Go to your API keys: https://onenr.io/0ERPemAADjW
  • Click Create a Key and choose an INGEST - LICENSE type
  • Then try hard coding the new key directly into your newrelic.ConfigLicense("NEW_KEY")

Do you get the same message? Please send the logs again if you have any problems.

-Brian

Hello @bhensley , thank you for the feedback.

I tried what you said and the error is the same.

2022/11/22 11:01:51.667652 {"level":"debug","msg":"rpm request","context":{"command":"preconnect","payload":[{"high_security":false}],"url":"https://collector.newrelic.com/agent_listener/invoke_raw_method?license_key=23..AL\u0026marshal_format=json\u0026method=preconnect\u0026protocol_version=17"}}
2022/11/22 11:01:52.459377 {"level":"debug","msg":"rpm failure","context":{"command":"preconnect","error":"response code: 410","response":"{\"exception\":{\"message\":\"Invalid license key\",\"error_type\":\"NewRelic::Agent::LicenseException\"}}","url":"https://collector.newrelic.com/agent_listener/invoke_raw_method?license_key=23..AL\u0026marshal_format=json\u0026method=preconnect\u0026protocol_version=17"}}
(27338) 2022/11/22 11:01:52.459429 {"level":"error","msg":"application disconnected","context":{"app":"falcon-app-sandbox-eu-west-1"}}

I can see on the logs the license key corresponds to the new one.

By the way: I tried to manually do a POST HTTP request to:

https://collector.newrelic.com/agent_listener/invoke_raw_method?license_key=LICENSEKEY&marshal_format=json&method=preconnect&protocol_version=17

With the license keys and I’m getting the same error

Hey @franco.primerano, thanks for running that test.

I’m looked into this with the backend team to see if there are any problems or bugs happening on your account. It looks like this is an issue caused by your account being cancelled and then made active again so the DB thinks your keys are also cancelled. The backend team are looking into how to correct your account but it might take a couple days to push any changes.

Thanks for your patience!

-Brian

2 Likes

Thanks for letting me know. I’ll wait then.

Do reach out if there is anything else we can assist with, @franco.primerano.