Closed stevesonnenbergmd closed 2 years ago
Hi @stevesonnenbergmd this is not a bug. These NR1 apps are just front end apps that do the processing, no backend stores them. So there is no API exposed to programmatically get the recommendations without opening the application and exporting the CSV. This button is top right of the table.
We could write the results to nerdstorage and then they could be accessed over graphql, but that would still require someone running the application.
There has been some brief discussions about doing the processing on a backend service, or splitting the processing logic into a lambda that the user could run. This would probably get closer to solving this requirement.
cc/ @aso1124
This has been implemented in the V3 release #106.
Direct queries can be made to nerdgraph nerdstorage with a user api key, the nerdpack uuid, and the relevant collections that contain the data.
eg. for jobStatus (update the accountId)
curl 'https://api.newrelic.com/graphql' \
-H 'API-Key: NRAK-.....' \
-H 'content-type: application/json' \
-H 'newrelic-package-id: 7e874b6e-c010-4933-a15d-ea5b2e54d029' \
--data-raw $'{"query":"query PlatformCollectionAccountStorageQuery($accountId: Int\u0021, $collection: String\u0021) { actor { account(id: $accountId) { id nerdStorage { collection(collection: $collection) { id document __typename } __typename } __typename } __typename } }","variables":{"accountId":11111111,"collection":"jobStatus"}}' \
--compressed
eg. results for a workload guid the documentId is from a jobId you would find from the prior query and ends with _1 as results can be sharded over multiple documents.
--data-raw $'{"query":"query PlatformDocumentAccountStorageQuery($entityGuid: EntityGuid\u0021, $collection: String\u0021, $documentId: String\u0021, $scopeByActor: Boolean\u0021) { actor { entity(guid: $entityGuid) { guid nerdStorage { document(collection: $collection, documentId: $documentId, scopeByActor: $scopeByActor) __typename } __typename } __typename } }","variables":{"entityGuid":"MTYwNjg2MnxOUjF8V09SS0xPQUR8NDkyMjg","collection":"optimizerResults","documentId":"108a7314-28b0-48f0-9c78-7e7ee14b9b43_1","scopeByActor":false}}' \
--compressed
more info here: https://github.com/newrelic/nr1-cloud-optimize/tree/main/backend
[NOTE]: # Can the information be obtained via API?
I don't see a documented way to programmatically obtain the recommendations