Every 5 minutes
Get a Slack alert when error rate passes 2%
If your app's error rate climbs above your limit, #ops hears once, and again only after it recovers and spikes again.
- Runs
- Every 5 minutes
- Apps
- New Relic
- AI
- Not needed
- Access
- read
Send this to your assistant
Create a ClickRuntime automation: every 5 minutes check the error rate of my checkout-api app in New Relic and post to #ops in Slack if it goes over 2%.
First time? Adding ClickRuntime to your assistant takes about two minutes.
Why use it
Why teams use this automation
A deploy goes out at 14:30 and the checkout service starts throwing errors on 3 percent of requests. Each failure is a customer who did not complete a purchase. New Relic can alert on this, but many teams have conditions that notify an email list nobody reads, or that fire so often that people mute them. The result is that real regressions are noticed through support tickets rather than monitoring.
Every five minutes ClickRuntime runs an NRQL query for the current error rate, compares it with your 2 percent limit, and posts to Slack when the limit is crossed. It alerts once, then stays quiet until the rate has fallen below the line, at which point it resets so the next breach is announced again.
It fits small teams that want a direct alert in Slack without maintaining a full set of alert policies.
What you get out of it
Regressions are caught while the deploy is fresh
A message within five minutes of the error rate passing 2 percent points straight at the release. Rolling back takes minutes, compared with the hour it takes to be told by customers.
Alerts mean something
Because it fires once per breach and resets when things recover, the channel is not flooded. People respond to the message because it has never cried wolf. People respond to the message because it has never raised a false alarm or repeated itself needlessly.
The threshold is yours
A rate of 2 percent suits one service, while another might need 0.5. Choosing the number yourself avoids the defaults that either drown you in alerts or miss real problems.
Revenue-impacting errors get priority
Errors on the checkout or login path directly cost money. A fast alert limits the number of failed purchases or sign-ins to a few minutes' worth. A fast alert limits failed purchases or sign-ins to a few minutes' worth of traffic.
Recovery is announced as well
Knowing the error rate dropped below the line tells the team the fix worked. Incident channels get a clear end, and the time of recovery is recorded. The recovery time is recorded, which helps when writing up how long customers were affected.
How it works
What happens, step by step
Every five minutes, ClickRuntime checks your app's error rate in New Relic.
It compares the rate with the limit you set, 2% by default.
The first time the rate goes over, a message goes to #ops with the current rate and the limit.
It stays quiet while the problem continues, and only alerts again after the rate has dropped back and climbed over the limit a second time.
Before it runs live
- Connect New Relic
What you get
Build your own
Need it to work differently?
Your own rules
Conditions, thresholds, filters and exceptions, written the way you'd explain them to a colleague.
Any number of apps
One automation can read from one app and update several others. Over 248 apps are ready, and anything with an API works too.
AI where it helps
Summaries, classification, extraction and drafts use ClickRuntime's built-in AI, with no extra key.
On a schedule or on each event
Runs as often as every 5 minutes, or the moment an app sends an event, and keeps track of what it already handled.
Changes you can ask for
- Run it at a different time, more or less often, or only on weekdays
- Add an AI step, for example to summarize, sort or draft a reply
- Add another app, for example also send it to Slack
- Combine it with other New Relic steps into one automation
Under the hood
The code that runs this automation
from clickruntime import on_trigger, credentials, http, notify, state
ACCOUNT_ID = 1234567
APP = "checkout-api"
THRESHOLD = 2.0
@on_trigger
def run(event):
nrql = (f"SELECT percentage(count(*), WHERE error IS true) AS rate FROM Transaction "
f"WHERE appName = '{APP}' SINCE 5 minutes ago")
query = '{ actor { account(id: %d) { nrql(query: "%s") { results } } } }' % (ACCOUNT_ID, nrql)
resp = http.post("https://api.newrelic.com/graphql", json={"query": query},
headers={"API-Key": credentials.secret("NEW_RELIC_USER_KEY")})
resp.raise_for_status()
rate = resp.json()["data"]["actor"]["account"]["nrql"]["results"][0]["rate"] or 0
was_alerting = state.get("alerting") or False
if rate > THRESHOLD and not was_alerting:
notify.slack(f":rotating_light: {APP} error rate is {rate:.2f}% (limit {THRESHOLD}%)", channel="#ops")
elif rate <= THRESHOLD and was_alerting:
notify.slack(f"{APP} error rate back to {rate:.2f}%", channel="#ops")
state.set("alerting", rate > THRESHOLD)
return {"rate": rate}FAQ
Common questions
How is the error rate calculated?
Will it alert repeatedly during a long incident?
Can I use a different threshold or time window?
What permissions does it need?
Does it need AI?
How many runs does it use?
Can I change how it works?
Related
You might also like
Get a morning list of open alert issues
Each day starts with an email of the New Relic alert issues still open, sorted by priority.
See how it worksGet a weekly performance report for your apps
Every Monday you see throughput, error rate and response time per app, next to the week before.
See how it worksHear when a synthetic monitor starts failing
When one of your New Relic synthetic checks fails, you get one Slack message per monitor until it passes again.
See how it worksKeep exploring
Set up “Get a Slack alert when error rate passes 2%” from your assistant
Copy the prompt above, or connect your assistant first. Free plan, no credit card.