Skip to content

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%.

Paste it into your assistant. It tells you what it will send or change before it runs live.

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

  1. Every five minutes, ClickRuntime checks your app's error rate in New Relic.

  2. It compares the rate with the limit you set, 2% by default.

  3. The first time the rate goes over, a message goes to #ops with the current rate and the limit.

  4. 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

RunsEvery 5 minutes
Get a Slack alert when error rate passes 2%today, 9:00Succeeded
Slack · #ops:rotating_light: checkout-api error rate is 3.17% (limit 2.0%)

Build your own

Need it to work differently?

This template is a starting point. Copy the prompt and change it, or describe a different automation from scratch, with your own conditions, more apps or an AI step. Your assistant writes it, tests it and runs it on ClickRuntime.
  • 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

This is the Python script that runs each time the automation starts. Your AI assistant writes it for you when you send the prompt, and you allow each step in your assistant. To change how the automation works, describe the change to your assistant and it updates the script for you. For every function it can use, see the script reference.
get_alerted_on_an_error_rate_threshold.pyexample
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?
It is the NRQL result for your chosen query, typically percentage(count(*), WHERE error IS true) over a recent window from Transaction data. You can scope it to one application, route or environment. The query decides what counts, so errors you consider normal can be excluded.
Will it alert repeatedly during a long incident?
No. It sends one alert when the rate first exceeds 2 percent and stays silent until it falls back under, then resets. If you want reminders every hour, a repeat interval can be added. Many teams add a second, stricter level for pages.
Can I use a different threshold or time window?
Yes. Both are plain settings, such as 5 percent over the last 10 minutes. A longer window smooths out short spikes, while a shorter one reacts faster but may fire more often. Pick the pair that matches how quickly your service normally recovers.
What permissions does it need?
read. Nothing else in your accounts is used.
Does it need AI?
No. It runs without AI, so it doesn't use your plan's AI allowance.
How many runs does it use?
One run each time it runs (every 5 minutes). Checks that find nothing to do and stop right away aren't counted.
Can I change how it works?
Yes. Describe the change to your AI assistant, for example a different schedule, channel or filter. It updates the automation, tests it and tells you what changed.

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.