pup
Purpose
Use this skill when you need to query Datadog for observability data: searching logs, querying time-series metrics, aggregating log statistics, listing available metrics, or inspecting metric metadata. pup is a CLI wrapper around Datadog APIs.
When to use what
Metrics
pup metrics query: Query time-series metric data with aggregation, filtering, and grouping. Primary command for metric analysis.pup metrics search: Same query syntax asquerybut uses the simpler v1 API. Use when you don't need v2 timeseries formula semantics.pup metrics list: Discover available metric names. Use with--filterto narrow by pattern.pup metrics metadata get: Read metadata (description, unit, type) for a specific metric.pup metrics tags list: List available tags for a specific metric.
Logs
pup logs query: Query logs using the v2 API (recommended). Supports timezone and flexible sorting.pup logs search: Search logs using the v1 API. Simpler but less capable thanquery.pup logs list: List logs with basic filtering. Lightest-weight log retrieval.pup logs aggregate: Statistical analysis on logs -- count, avg, percentile, cardinality, grouped by field.
Core concepts
- Output format: Use
-o tablefor human-readable output,-o jsonfor machine-readable. Default isjson. - Time ranges:
--fromand--toaccept relative values (1h,30m,7d,1w,1M) or absolute unix timestamps.--todefaults tonow. - Metric query syntax:
<aggregation>:<metric_name>{<filter>} [by {<group>}]- Aggregations:
avg,sum,min,max,count - Filters: tag key-value pairs like
{env:prod},{host:web-*}, or{*}for all - Grouping:
by {service},by {host,env}
- Aggregations:
- Log query syntax: Uses Datadog search syntax
- By field:
status:error,service:web-app,host:i-* - By attribute:
@http.status_code:500,@user.id:12345 - Boolean:
AND,OR,NOT, negation with-status:info - Phrase:
"exact phrase" - Wildcard:
host:i-*
- By field:
Recommended workflow
Investigating a metric
- Discover metrics:
pup metrics list --filter="<pattern>"to find relevant metric names. - Inspect metadata:
pup metrics metadata get <metric>to understand unit and type. - Check tags:
pup metrics tags list <metric>to see available dimensions. - Query data:
pup metrics query --query="avg:<metric>{<filter>} by {<group>}" --from="1h"
Investigating logs
- Start broad:
pup logs search --query="status:error" --from="1h" --limit=10to see recent errors. - Narrow down: Add filters like
service:X AND @http.status_code:500. - Aggregate for patterns:
pup logs aggregate --query="status:error" --from="1h" --compute="count" --group-by="service"to find which services are failing. - Deep dive:
pup logs query --query="service:failing-svc AND status:error" --from="1h" --limit=100for full log details.
Important tips
- Prefer
-o jsonwhen processing output programmatically; use-o tablewhen presenting to users. - For log searches,
--limitdefaults to 50 (max 1000 for search, configurable for query/list). - Metric queries return time-series arrays with timestamps -- the data points are in the
seriesfield of the JSON output. - Log aggregate
--computesupports:count,avg(@field),sum(@field),min(@field),max(@field),cardinality(@field),percentile(@field, N). - Use
--group-bywith aggregate to break down results by any log field or attribute. - Time ranges are relative to now:
1hmeans "1 hour ago to now",7dmeans "7 days ago to now".
More from arjunmahishi/dotfiles
acli-jira
Use acli to manage Jira tickets -- search, view, create, edit, transition, assign, comment, and more from the command line.
147tsq
Use tsq to extract structured code information with tree-sitter queries, symbols, outlines, and references across languages.
8excalidraw-obsidian
Create or update Excalidraw diagrams in the Obsidian vault as .md files compatible with the obsidian-excalidraw-plugin.
6tmux
>
2playwright-cli
Automates browser interactions for web testing, form filling, screenshots, and data extraction. Use when the user needs to navigate websites, interact with web pages, fill forms, take screenshots, test web applications, or extract information from web pages.
2