shasha
shasha

Reputation: 19

New Relic alert when application stop

I have an application deployed on PCF and have a new relic service binded to it. In new relic I want to get an alert when my application is stopped . I don't know whether it is possible or not. If it is possible can someone tell me how?

Edit: I don't have access to New Relic Infrastructure

Upvotes: 0

Views: 1367

Answers (3)

holzkohlengrill
holzkohlengrill

Reputation: 1222

You could do something like this:

// ...
  aggregation_method   = "cadence"         // Use cadence for process monitoring otherwise it might not alert
// ...

  nrql {
    // Limitation: only works for processes with ONE instance; otherwise use just uniqueCount() and set a LoS (loss of signal)
    query       = "SELECT filter(uniqueCount(hostname), WHERE processDisplayName LIKE 'cdpmgr') OR -1 FROM ProcessSample WHERE GENERIC_CONDITIONS FACET hostname, entityGuid as 'entity.guid'"
  }
  
  critical {
    operator              = "below"
    threshold             = 0
    threshold_duration    = 5*60
    threshold_occurrences = "ALL"
  }

Previous solution - turned out it is not that robust:

// ...
critical {
  operator              = "below"
  threshold             = 0.0001
  threshold_duration    = 600
  threshold_occurrences = "ALL"
}
nrql {
  query             = "SELECT percentage(uniqueCount(entityAndPid), WHERE commandLine LIKE 'yourExecutable.exe') FROM ProcessSample FACET hostname"
}

This will calculate the fraction your process has against all other processes.

If the process is not running the percentage will turn to 0. If you have a system running a vast amount of processes it could fall below 0.0001 but this is very unprobable.


The advantage here is that you can still have an active alert even if the process slips out of your current time alert window after it stopped. Like this you prevent the alert from auto-recovering (compared to just filtering with WHERE).

Upvotes: 0

Gene Johnson
Gene Johnson

Reputation: 36

Although an 'app not reporting' alert condition is not built into New Relic Alerts, it's possible to rig one using NRQL alerts. Here are the steps:

  1. Go to New Relic Alerts and begin creating a NRQL alert condition:

  2. Query your app with:

    • SELECT count(*) FROM Transaction WHERE appName = 'foo'
  3. Set your threshold to :
    • Static
    • sum of query results is below x
    • at least once in y minutes

The query runs once per minute. If the app stops reporting then count will turn the null values into 0 and then we sum them. When the number goes below whatever your threshold is then you get a notification. I recommend using the preview graph to determine how low you want your transactions to get before receiving a notification. Here's some good information:

Upvotes: 1

Ori Marko
Ori Marko

Reputation: 58772

Basically you need to create a NewRelic Alert with conditions that check if application available, Specially you can use Host not reporting alert condition

The Host not reporting event triggers when data from the Infrastructure agent does not reach the New Relic collector within the time frame you specify.

Upvotes: 0

Related Questions