l4 tags preview
l4 tags preview runs a tag file against your recent costs and prints what each value would take. It saves nothing, so you can try a rule, read the result and edit the file as many times as you like before l4 tags apply.
l4 tags preview -f <file> [--start <date> --end <date>]The command posts the file to /api/v1/tags/virtual/preview. It reads the same file format as apply, and name may be empty.
effective_from has no effect here: the window is --start to --end, or the last 30 complete days, and Limits caps its length.Flags
| Flag | Description |
|---|---|
-f <file> | Tag file to evaluate. Required |
--start <date> / --end <date> | Window. See Dates |
Global flags apply. See CLI overview.
Examples
l4 tags preview -f teams.yaml
l4 tags preview -f teams.yaml --start 2026-08-01 --end 2026-08-31
l4 tags preview -f teams.yaml --jq '.data.unallocated_spend'
l4 tags preview -f teams.yaml --jq '.data.values[] | [.name, .spend]'Output
Default output is a table of values with their spend and resource count, followed by the unallocated and shadowed spend. With --json the whole API envelope is printed. The fields it carries:
.data.window.start
.data.window.end
.data.total_spend
.data.unallocated_spend
.data.shadowed_spend # spend a lower config also matches, already taken by a higher one
.data.values[].name
.data.values[].spend
.data.values[].resource_count
.data.values[].sample_resources[]shadowed_spend points at order problems. A config you expected to claim spend, showing little of it while shadowed_spend is high, sits below a broader config that takes its lines first. Move it up.
Errors
| Exit | Symptom | Cause |
|---|---|---|
4 | Authentication required | No token resolvable; run l4 auth login or set LEVELFOUR_TOKEN |
1 | The file does not parse, or has an unknown field | Fix the file. File format lists the fields |
1 | 401 authentication failed | Token revoked, expired, or from the wrong environment |
1 | 422 validation_failed | The file breaks a rule. Validation problems lists the codes |
Related
l4 tags apply: save the file once the preview looks right- Virtual tags: the rules the preview evaluates
l4 tags costs
Spend per value of a provider or virtual tag key, with each value's share, its split across service categories, and the spend that carries no value.
l4 tags apply
Create or replace a virtual tag key from a YAML file. Prints the difference against the saved key first, then reprocesses the key's costs from its backfill month.