How do I alert on cost per trace for a single agent?
Rius lets you alert on cost per trace for one agent with a custom alert that filters on Agent and applies avg(Cost) over a rolling window. Cost aggregations in Rius are per trace, so avg(Cost) is the average cost of a trace in the window, not the workspace total. Set the threshold in US dollars, pick a window between 5 minutes and 24 hours, and attach a channel to get notified.
How it works
A custom alert is one or more rules, combined with AND, evaluated over one shared rolling window. You can scope the alert with filters. Filters pick which spans feed the rules, and they apply before any aggregation.
Two parts of the builder do the work for this question:
- The Agent filter. It matches the agent identity Rius derives, as each span carries it. Each filter matches a span’s own value, so Agent selects every span that carries the agent, not only root spans. Text filters offer
=,≠,inandnot_in, and values are suggested from your workspace’s live data. - The Cost metric. Cost is numeric and offers avg, min, max, p50, p95 and p99. These use per-trace semantics, so
p95(Cost)is the 95th percentile of cost per trace in the window.
Not every metric aggregates per trace. Time to first token, Context usage and LLM calls are measured per LLM call, so their aggregations run over calls. An LLM call is an inference call, a span the trace view badges as LLM. Agent, tool, retrieval and embedding spans never count as LLM calls, even when they carry a model. Error rate and LLM error rate are the share of spans, or of LLM calls, that errored in the window, and you compare them against a value between 0 and 1.
If you want a different agent, a different threshold or an either-or condition, create a second alert. Rules combine with AND only, with no OR and no nesting.
Set it up
- Open the custom alert builder from Alerts and start a new custom alert.
- Add a filter with the field Agent, the operator
=, and your agent’s name. Pick the name from the suggested values, which come from your workspace’s live data. To cover several agents with one alert, useinwith a list of values instead. - Add a rule on the Cost metric. Choose avg for the typical trace, or p95 or p99 to catch the most expensive traces. Choose
>and enter a threshold in USD. - Optionally add a second rule to cut noise. For example,
count(Traces) > 20makes the alert fire only when the agent has enough traffic in the window. Both rules must hold for the alert to fire. - Set the window, from 5 minutes to 24 hours. The window is shared by every rule in the alert.
- Check the plain-language preview of when the alert fires. That sentence becomes the alert’s description on its details page.
- Attach a webhook, email or Slack channel, and set the Renotify policy to off or every N minutes.
The finished alert reads like this in the rule grammar:
FILTERS Agent = checkout-agent (applied before aggregation)
RULES avg(Cost) > $0.50
AND count(Traces) > 20
WINDOW 15 minutes (shared by all rules)An alert takes up to 10 filters with up to 50 values each, up to 10 rules, and a window between 5 minutes and 24 hours. If you filter on Step, it matches span names exactly. You can narrow further with Model, Span kind, Operation, Session or Instance.
What you get
- An alert scoped to one agent that fires when its cost per trace crosses your threshold in the window.
- A details page with the generated description, the editable rule, the attached channels and the firings. Each firing records the observed value of every rule against its threshold, so you can see which condition tripped.
- Notifications through webhook, email or Slack, with optional renotify every N minutes.
- A custom alert you can edit or delete at any time. Deleting it removes its firing history after an explicit confirmation.
Cost values are list-price estimates in US dollars, priced from LiteLLM’s public model-price catalog, so treat the threshold as an estimate, not a billed amount. Spans whose model has no known price carry no cost, and an unknown model gets an empty cost, not zero. Firings on Cost show the coverage ratio, so you can tell a real reading from a partly covered one. Coverage is attached only to firings, and a rule held under its threshold by low coverage stays quiet. Check which models are priced on the usage and cost view before you rely on a cost alert.
When something else fits
- If you want a summary of cost by model or over time instead of a trigger, the Usage and cost view in Rius shows the same metrics on Home.
- If you want to be told about repeated errors, swallowed errors or tool loops without choosing a threshold, the pre-defined alerts cover them.
- If you need an either-or condition, such as cost or errors for the same agent, create two custom alerts, because rules in one alert combine with AND only.