Your data. Anywhere you go.

New Relic for iOS or Android


Download on the App Store    Android App on Google play


New Relic Insights App for iOS


Download on the App Store


Learn more

Close icon

Alert on Application Health Count

restapi
nrql
insights
synthetics

#1

Problem -
We have our application in 5 instances, and would like to create a alert based on application health count. if count(healthy available instances) < 5 then trigger alert.

We tried with NRQL using Transaction/TransactionError in insights but does not solve our problem. Also found a rest api which meets our need but not sure how to hook up alerting policy using it.

curl -X GET ‘https://api.newrelic.com/v2/applications/${NR_APPLICATION_ID}/hosts.json
-H ‘X-Api-Key:${NR_TOKEN}’ -i

Refer - https://rpm.newrelic.com/api/explore/application_hosts/list

It list application instances with its health. I can use synthetics to bake in alert but there has to be an easy way.

What is the best way to create a alert policy for this case?


#2

Hi @bachandr, I wonder if you could send a permalink to the application?

Just using another of your applications, something like the following NRQL query should report on the unique hosts:

SELECT uniqueCount(host) FROM Transaction where appId = **APP-ID** since 1 day ago timeseries

Hope this helps :slight_smile:


#3

Hi @rdouglas

We do have dashboard to spit out instance count based on same methodology, but some of our instance does not need to emit NR msg all the time. This is causing false alerts. I feel this is still a workaround, is there a better solution NR offers? Even plugins would do.

Thanks!


#4

@bachandr - Unfortunately alerting on the existence of Transaction events does require that each of your hosts is processing active Transactions events or it would alert. Have you considered using Synthetics to drive traffic to each of your hosts? A free Synthetics subscription comes with up to 50 free ping monitors that can be used to drive traffic to your servers.

Alternatively, with Synthetics Pro you can use an API monitor to query the REST API and alert if it does not return at least 5 instances.


#5

Hi, I’m wondering the same, in the Infrastructure tab (https://infrastructure.newrelic.com/accounts/{ACCOUNT_ID}/hosts), we are able to see the total number of applications per host, :face_with_raised_eyebrow: is there a way for us to monitor on that number directly?

:thinking:The Transaction table does not seem to return the actual total number of applications per host.

:disappointed_relieved:The issue with Synthetics is, we might be able to use it for PROD applications, but will be unable to access lower environments thru external Internet.

Many thanks!


#6

Hi @Euphoria1878, you could use something like the following to get a count of applications reporting on a host:

SELECT uniqueCount(apmApplicationNames) FROM SystemSample SINCE 30 MINUTES AGO WHERE hostname = 'hostname'

apmApplicationIds is also a useful attribute.

In terms of your Synthetics question, you could use a Private Synthetics Minion which will allow you to monitor any internal sites you have :slight_smile: