I’m developing a nerdpack to analyze users with session problems. First, I need a list of the users that use our website the most. But then, from those users I need to filter those with problems. I can identify them because they have to login too many times in a day.
The data is in Insights, in the UserEvent table. So I first need to query UserEvent to get a list of the users with the most events for one of our websites. Then I need to query for each user to get a list of how many login events has that user per day. If they login more than, say, 5 times in a day, that’s a problem.
So I thought that maybe I can just use the Insights API to get some json (instead of a
NerdGraphQuery, because I don’t want to display the result of my first query). I have created an Insights Query Key and I have tested the query to the API using Postman and I get the expected results. But when I do the same query from the nerdpack (using
fetch()) I get an error. I have tried using the parameter “mode: ‘cors’” (and also “mode: ‘no-cors’”), but I always get the same error:
Access to fetch at 'https://insights-api.newrelic.com/v1/accounts/ACCOUNT-ID/query?nrql=SOME-QUERY from origin 'https://0f5409a8-48da-47cd-95b4-0d788fcf8230.g0.nr-ext.net' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
So, is maybe the Insights API configured to not accept this kind of request and I’m screwed?