• Log inStart now

NerdGraph tutorial: Mobile agent monitoring examples

You can create mobile applications in the NerdGraph API instead of using the UI. The advantage to this is that when it's time to instrument your mobile application with New Relic, you can programmatically create and retrieve the application token to copy and paste into your mobile application.

Create a new mobile application

Here is an example mutation to create a new mobile application. You must provide an account id and a name for the application.

Mutation:

mutation CreateExampleMobileApplication($accountId: Int!, $name: String!) {
agentApplicationCreateMobile(accountId: $accountId, name: $name) {
accountId
applicationToken
guid
name
}
}

Variables:

{
"accountId": Int!,
"name": String!
}

Retrieving the application token

You can retrieve a mobile application token with the following query.

Query:

query FetchMobileApplicationToken($guid: EntityGuid!) {
actor {
entity(guid: "") {
... on MobileApplicationEntity {
guid
name
mobileProperties {
applicationToken
}
}
}
}
}

Variables:

{
"guid": EntityGuid!
}

Change a mobile app name

Here's an example mutation that changes the name of your mobile app in New Relic:

Mutation:

mutation UpdateMobileApplicationAlias($guid: EntityGuid!, $settings: $AgentApplicationSettingsUpdateInput) {
agentApplicationSettingsUpdate(guid: $guid, settings: $settings) {
alias
guid
errors {
description
errorClass
field
}
}
}

Variables:

{
"guid": EntityGuid!,
"settings": {
"alias": String
}
}

Examples of configuring mobile monitoring

Here's an example of how to configure mobile settings via NerdGraph:

Mutation:

mutation UpdateMobileSettingsExample(
$guid: EntityGuid!
$settings: AgentApplicationSettingsUpdateInput!
) {
agentApplicationSettingsUpdate(guid: $guid, settings: $settings) {
guid
errors {
description
errorClass
field
}
alias
mobileSettings {
networkSettings {
aliases {
alias
hosts
}
filterMode
hideList
ignoredStatusCodeRules {
hosts
statusCodes
}
showList
}
useCrashReports
}
}
}

Variables:

{
"guid": EntityGuid!,
"settings": {
"alias": String,
"mobileSettings": {
"networkSettings": {
"aliases": [
{
"alias": String!,
"hosts": [String!]!
}
],
"filterMode": AgentApplicationSettingsNetworkFilterMode,
"hideList": [String!],
"ignoredStatusCodeRules": [
{
"hosts": [String!]!,
"statusCodes": [String!]!
}
],
"showList": [String!]
},
"useCrashReports": Boolean
}
}
}
Copyright © 2023 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.