How it works
Log line actions run as AppSignal ingests your logs, in an order you set. There are three types:- metrics: records a metric from matching lines.
- filter: drops matching lines so they are never stored.
- trigger: fires an alert and incident when the query matches.
Log line actions only affect lines ingested after you create them. They do not change logs that are already stored.
Record the metric as logs arrive
Recording the metric at ingestion is what makes the drop safe. A log-based metric built from the Logs page reads stored log lines, so once you drop the lines there is nothing left to read. A metrics log line action records the value from each line as it arrives, before the filter drops it, so the number survives.Before you start, you will need
- AppSignal MCP set up in your AI agent, with write access to the logging tools
- A log source that receives the lines you want to measure
- A query that matches those lines
Step 1: Record a metric from the lines
Ask your agent to add a metrics action. For example, to count how often shoppers search your catalog:On MyStore production, add a metrics log line action that counts log lines matchingThis callsmessage:searchas a counter namedlog.catalog_searches, scoped to the application log source.
manage_log_line_action:
- Write the query in AppSignal’s log query syntax, the same syntax as the Logs page.
message:searchmatches lines whose message containssearch. See query syntax. - Choose which sources it applies to. List them in
source_ids, or omitsource_idsto apply the action to every source. - Pick the metric type. A
countercounts matching lines and needs no field. Agaugeordistributionreads a number from each line, so it needs afieldnaming which value to read.
Step 2: Check the metric before you drop anything
Wait for a few matching lines, then read the metric back:
Show me the log.catalog_searches counter for MyStore production over the last 15 minutes.
Step 3: Drop the matching lines
Add a filter action with the same query:
On MyStore production, add a filter log line action that drops log lines matching message:search.
Step 4: Keep the metrics action before the filter
New actions are added at the end of the order, so the filter already runs after the metrics action. Confirm the order:List the log line actions on MyStore production, and keep the metrics action before the filter.This uses
get_app_resources to read the order, and reorder_log_line_actions only if the filter is ahead of the metrics action. If the filter ran first, it would drop the lines before the metrics action counted them.
Verify it works
Give the actions a few minutes to take effect, then confirm both halves on a small sample:- Read the metric. The counter keeps rising as matching lines arrive.
- Search your logs for the same lines. New ones no longer appear, because the filter drops them.
Behavior and limitations
- Actions are not retroactive. They act on new lines only. Logs stored before you created the action stay as they are.
- Allow a few minutes. A new or changed action takes a short time to take effect. Lines that arrive in the first moments may not be processed by it.
- Dropped lines cannot be recovered. Keep the metric, and a trigger action if you want alerts, so the filter never removes the only record of an event.
- The two queries are independent. Count one set of lines and drop another if that fits your goal. To count and drop the same lines, use the same query for both.
Related
- AppSignal MCP and the MCP tool reference
- Log-based metrics, built from stored log lines
- Ignore logs, to stop sending lines from your integration in the first place