Grep an Octopus task activity log
grep_task_logSearch task activity logs for specific patterns using grep-style filtering. Return only matching lines with optional surrounding context.
Instructions
Search a server task's activity log with grep-style semantics. Returns only matching lines (with optional symmetric context windows). This is the canonical way to inspect task logs — there is no full-log resource URI, because exposing one would tempt callers to inhale multi-megabyte bodies when grep is almost always the better primitive.
Use this when you know what to look for (a specific error string, a step name, a pattern). For structured access to the activity tree (step hierarchy, categories, timing) use the octopus://spaces/{spaceName}/tasks/{taskId}/details resource instead.
Parameter conventions mirror GNU grep so the schema is self-explanatory:
pattern (regex by default; set fixedString:true for literal text)
caseInsensitive (-i)
invertMatch (-v)
fixedString (-F)
beforeContext (-B)
afterContext (-A)
maxCount (-m)
Response includes totalMatches (true count across the whole log), totalLines, the matched lines with 1-indexed lineNumber, optional before/after context arrays, and a taskDetailsResourceUri for the structured fall-through.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| spaceName | Yes | Octopus space name. Case-sensitive. | |
| taskId | Yes | ServerTasks-XXXX ID. Use find_releases or list_deployments to discover task IDs from their parent entities. | |
| pattern | Yes | Regex (default) or literal substring (when fixedString=true). Anchors and groups behave as in JavaScript RegExp. Tested against each log line independently — the same model as `grep`. | |
| caseInsensitive | No | Equivalent to grep -i. Default false. | |
| invertMatch | No | Equivalent to grep -v: return lines that do NOT match. Default false. | |
| fixedString | No | Equivalent to grep -F: treat pattern as a literal substring, not a regex. Use this when grepping for text containing regex metacharacters. Default false. | |
| beforeContext | No | Equivalent to grep -B: lines of preceding context to include with each match. Capped at 50. | |
| afterContext | No | Equivalent to grep -A: lines of trailing context to include with each match. Capped at 50. | |
| maxCount | No | Equivalent to grep -m: stop returning matches after this many. totalMatches in the response still reflects the true count across the whole log. Hard cap 500. | |
| stripPrefixes | No | Strip the timestamp/level prefix (e.g. `04:36:40 Fatal | `) from each line before pattern matching AND in the returned line/context text. Default false. Turn this on when greping for words that collide with level names (Fatal, Error, Warn) or when you want clean message-only output. Note: when on, your pattern will not match against the prefix — searching for `Fatal` won't find Fatal-level lines. |