How do I alert on cost per trace for one service?
Rius lets you create a custom alert with a Service filter and the rule avg(Cost) greater than your threshold. Cost aggregations in Rius are per trace, so avg(Cost) is the average cost per trace in the window, not the workspace total. The Service filter limits the rule to spans from one service before anything is averaged. Rius computes cost from the model and token counts, so you never send a cost value.
How it works
A custom alert has three parts: optional filters, one or more rules, and one rolling window shared by all rules. Rules always combine with AND. For an either-or condition, create a second alert.
- Filters run first. They select which spans feed the rules, before any aggregation. The Service filter matches the
service.nameyour instrumentation sets. - Cost is a per-trace metric. Cost is a numeric metric in USD. It offers avg, min, max, p50, p95 and p99. These aggregations use per-trace semantics.
p95(Cost)is the cost of the trace at the 95th percentile in the window. - Some metrics are per call. Time to first token, Context usage and LLM calls are measured per LLM call, so their aggregations run over calls, not traces. An LLM call is an inference call, a span the trace view badges as LLM. Agent, tool, retrieval and embedding spans never count, even when they carry a model.
- Other metric types. Error rate and LLM error rate are ratios. You compare them with a value between 0 and 1. Errors, Traces and LLM calls are counts, with count and ucount (distinct traces).
The builder shows a plain-language preview of when the alert fires. That sentence becomes the alert’s description on its details page.
Cost is a list-price estimate in US dollars. A span whose model has no known price carries no cost, so it adds nothing to the average. Check which models are priced on the Usage and cost page before you rely on a cost alert.
Set it up
- Open the custom alert builder in the Rius console. You need traces from your service already arriving. To start sending traces, see the Quickstart.
- Add a filter: field Service, operator
=, and the service name. Values are suggested from your workspace’s live data. To cover several services with one alert, useinwith a list of names. Usenot_into exclude services. - Add a rule: metric Cost, aggregation avg, operator
>, and your threshold in USD. The comparison operators are<,<=,>,>=and==. - Set the window. It can be anywhere from 5 minutes to 24 hours. A short window reacts quickly. A longer one smooths out a few expensive traces.
- Attach a channel (webhook, email or Slack) and choose a Renotify policy, off or every N minutes.
The builder expresses the alert like this:
FILTERS Service = checkout-agent (optional, applied before aggregation)
RULES avg(Cost) > $0.50
AND count(Errors) > 10
WINDOW 15 minutes (shared by all rules)For a cost-only alert, keep the Service filter and the first rule, and drop the count(Errors) rule. Keep it if you want the alert to fire only when expensive traces and errors happen together in the same window.
An alert accepts up to 10 filters with up to 50 values each, and up to 10 rules.
To catch a few very expensive traces rather than a rising average, change the aggregation to p95 or max. The filter stays the same.
What you get
- An alert scoped to one service. Spans from other services do not feed the rule.
- A threshold on cost per trace, in USD, over a rolling window you choose.
- 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.
- Coverage information on firings. Cost is only as complete as pricing coverage, so a firing shows the coverage ratio and you can tell a real reading from a partly covered one.
- A custom alert you can delete later. Deleting it removes its firing history after you confirm.
Coverage is attached only to firings. If low coverage holds the average under your threshold, the alert stays quiet.
When something else fits
- If you want the total spend rather than the cost of each trace, look at the Usage and cost page, which shows the same metrics as a summary instead of a trigger.
- If you need to narrow further, add filters such as Agent, Model or Step on top of the Service filter. Step matches span names exactly.
- If you want a threshold on a value per LLM call, such as Time to first token or Context usage, use those metrics. They aggregate over calls, not traces.