CLI workflow

Search Logs Safely with a CLI

Constrain the time, service, file, and pattern first; then collect only the lines needed to explain the incident.

Operations and infrastructureLocal write

Prepare tools, authentication, and evidence first

Install the recommended tools, confirm minimum permissions, and keep compatibility separate from real execution records.

rgverified
Search source trees quickly with stable JSON, glob, type, and context controls.

Recommended install

$ shell
brew install ripgrep
Authentication
No authentication for the base operation
Tested agents
No agent-specific execution record
Evidence status
verified · Documentation checked 2026-07-10
Independent CLI execution
15.1.0 · 4 checks
pupdocs-verified
Query Datadog observability data through an agent-aware CLI with JSON output and a read-only mode.

Recommended install

$ shell
brew tap datadog-labs/pack && brew install datadog-labs/pack/pup
Authentication
OAuth2 PKCE, access token, API and application keys
Tested agents
No agent-specific execution record
Evidence status
docs-verified · Documentation checked 2026-07-10
Independent CLI execution
No independently executed version recorded
jqverified
Parse, filter, validate, and transform JSON locally with deterministic output.

Recommended install

$ shell
brew install jq
Authentication
No authentication for the base operation
Tested agents
No agent-specific execution record
Evidence status
verified · Documentation checked 2026-07-10
Independent CLI execution
jq-1.7.1-apple · 4 checks

Copy or download this workflow Skill

The Skill includes input and output contracts, recommended tools, approval points, rollback, and evidence boundaries. Review it against the active environment before saving.

search-logs-SKILL.md
---
name: search-logs-workflow
description: "Constrain the time, service, file, and pattern first; then collect only the lines needed to explain the incident."
---

# Search application logs

## Intended outcome

Find a relevant error sequence without exposing unrelated users, secrets, or an unbounded production log stream.

## Evidence boundary

- Tool status distinguishes `docs-verified` material from independent execution; the two are not interchangeable.
- The current registry does not attribute a tool execution to a particular agent, so compatible agents cannot be called tested agents.
- Reconfirm the target account, environment, version, and official documentation before execution.
- Never auto-execute an R2, R3, or confirmation-marked step; obtain explicit approval immediately before it runs.

## Recommended tools, installation, and authentication

- **ripgrep** (evidence: `verified`, docs checked: `2026-07-10`, independently tested version 15.1.0 recorded)
  - Install: `brew install ripgrep`
  - Authentication: not required for the base operation
  - Minimum permissions: No service credential is required; restrict filesystem and network access to the task.
- **Datadog Pup CLI** (evidence: `docs-verified`, docs checked: `2026-07-10`, no independently executed version recorded)
  - Install: `brew tap datadog-labs/pack && brew install datadog-labs/pack/pup`
  - Authentication: OAuth2 PKCE, access token, API and application keys
  - Minimum permissions: Prefer OAuth scopes or --read-only; never set DD_AUTO_APPROVE for an unattended write-capable session.
- **jq** (evidence: `verified`, docs checked: `2026-07-10`, independently tested version jq-1.7.1-apple recorded)
  - Install: `brew install jq`
  - Authentication: not required for the base operation
  - Minimum permissions: No service credential is required; restrict filesystem and network access to the task.

## Input contract

- Incident time window
- service or file scope
- request or trace identifier
- redaction rules

## Output contract

- Matching events with context
- search command
- timeline summary
- gaps and next checks

## Safe workflow

1. **Define a narrow query** — Start with a timestamp, service, request ID, or exact error token and bounded files.
   - Input: Incident clue and log locations
   - Output: Reviewable search boundary
   - Risk: `read-only`
   - Command: `rg -n -F "request-id" logs/ --glob "*.log"`
2. **Collect context** — Add limited surrounding lines or parse JSON fields without dumping the full log set.
   - Input: Initial matches
   - Output: Relevant event sequence
   - Risk: `read-only`
3. **Redact and summarize** — Remove tokens and personal data, preserve timestamps and IDs, and note missing evidence.
   - Input: Matched log window
   - Output: Incident timeline and sanitized evidence
   - Risk: `local-write`

## Ask before proceeding

- Querying production observability systems
- Broadening the time, service, tenant, or environment scope
- Downloading or sharing logs outside the approved location

## Rollback

- Delete temporary raw log exports after the task
- Revoke temporary observability credentials
- Keep only the sanitized evidence required for the incident record

## Official sources

- [ripgrep guide](https://github.com/BurntSushi/ripgrep/blob/master/GUIDE.md) — Project guide for search behavior, filters, file types, and output controls.
- [Datadog Pup repository](https://github.com/DataDog/pup) — Upstream command and authentication documentation for the Pup CLI.
- [jq manual](https://jqlang.github.io/jq/manual/) — Official filters, input modes, exit status, and JSON transformation reference.

Outcome, inputs, and outputs

Define the result and evidence before the agent selects a command.

Goal

Find a relevant error sequence without exposing unrelated users, secrets, or an unbounded production log stream.

Required inputs

  • Incident time window
  • service or file scope
  • request or trace identifier
  • redaction rules

Expected outputs

  • Matching events with context
  • search command
  • timeline summary
  • gaps and next checks

Search Logs Safely with a CLI: safe workflow

Run each step inside its stated boundary and verify the output before continuing.

Step 1Read only

Define a narrow query

Start with a timestamp, service, request ID, or exact error token and bounded files.
Input
Incident clue and log locations
Output
Reviewable search boundary
$ Define a narrow query
rg -n -F "request-id" logs/ --glob "*.log"
Step 2Read only

Collect context

Add limited surrounding lines or parse JSON fields without dumping the full log set.
Input
Initial matches
Output
Relevant event sequence
Step 3Local write

Redact and summarize

Remove tokens and personal data, preserve timestamps and IDs, and note missing evidence.
Input
Matched log window
Output
Incident timeline and sanitized evidence

Approval points and rollback

Pause at the listed decision points and keep recovery instructions beside the action.

Ask before these actions

  • Querying production observability systems
  • Broadening the time, service, tenant, or environment scope
  • Downloading or sharing logs outside the approved location

Recovery plan

  • Delete temporary raw log exports after the task
  • Revoke temporary observability credentials
  • Keep only the sanitized evidence required for the incident record

CLI, MCP, or API?

Choose the interface by execution location, identity, output contract, and permission boundary.

CLI

Best for local files and reproducible, tightly scoped observability queries.

MCP

Useful when production logs need centrally mediated, read-only tools.

API

Prefer for repeatable dashboards, scheduled detection, or high-volume queries.

Recommended approach

Use ripgrep locally; use a scoped service CLI or API for remote logs and keep the query bounded.

Official evidence and references

Use these primary or upstream sources to verify current command behavior before acting.

ripgrep guide

Project guide for search behavior, filters, file types, and output controls.

Datadog Pup repository

Upstream command and authentication documentation for the Pup CLI.

jq manual

Official filters, input modes, exit status, and JSON transformation reference.

Questions before you run it

How much context should an agent include?

Only enough to establish the sequence. Preserve timestamps and identifiers, and avoid unrelated sessions.

Can logs be pasted into a model?

Only when authorized and after removing credentials, personal data, and unrelated customer content.

Related tools and guides

Browse sibling guides and choose the next page that best matches the active task.

Continue with tool evidence, a workflow, or a decision guide related to this task.

Continue with tool evidence, a workflow, or a decision guide related to this task.

Continue with tool evidence, a workflow, or a decision guide related to this task.

Inspect installation, authentication, structured output, command risk, and official evidence.

Inspect installation, authentication, structured output, command risk, and official evidence.