Summary
pup metrics list --filter always returns empty results regardless of the filter value. The --filter flag is documented as filtering by metric name pattern, but the implementation passes the value to the Datadog API's tag_filter parameter, which filters by Datadog tags (e.g., env:prod) — not metric names.
Steps to Reproduce
# List all metrics — works, returns 221k+ metrics
pup metrics list | python3 -c "import sys,json; d=json.load(sys.stdin); print(len(d['metrics']))"
# Output: 221561
# Filter by metric name — returns empty
pup metrics list --filter="system.cpu"
# Output: {"from": "...", "metrics": []}
# Even an exact metric name returns empty
pup metrics list --filter="system.cpu.user"
# Output: {"from": "...", "metrics": []}
# But these metrics exist in the unfiltered list
pup metrics list | python3 -c "
import sys, json
d = json.load(sys.stdin)
matches = [m for m in d['metrics'] if 'system.cpu' in m]
print(f'system.cpu matches: {len(matches)}')
"
# Output: system.cpu matches: 241
Every filter value produces empty results: kafka_index, system.*, *cpu*, bare strings, wildcards — all return {"metrics": []}.
Root Cause
In cmd/metrics.go, the runMetricsList function passes the --filter value as WithTagFilter():
opts := datadogV1.NewListActiveMetricsOptionalParameters()
if filterPattern != "" {
opts = opts.WithTagFilter(filterPattern)
}
The Datadog v1 ListActiveMetrics API's tag_filter parameter filters by Datadog tags (comma-separated, e.g., env:prod,service:api) — not by metric name patterns. Since kafka_index, system.cpu, etc. are not valid tags, the API returns no matching metrics.
Expected Behavior
pup metrics list --filter="kafka_index" should return metrics whose names contain or match kafka_index, consistent with the help text:
FILTERING:
Use the --filter flag to search for metrics matching a pattern:
• system.* - All system metrics
• *.cpu.* - All CPU-related metrics
• custom.* - All custom metrics
Suggested Fix
The v1 ListActiveMetrics API doesn't support metric name filtering server-side. Options:
- Client-side name filtering: Fetch all metrics and filter names locally (simplest, matches documented behavior)
- Add
--tag-filter flag: Expose the actual tag_filter API parameter under its correct name, and use --filter for client-side name matching
- Use v2 API: The v2
ListMetricAssets or metric search APIs may support name-based filtering
Environment
- pup version:
dev (unknown)
- Installed via:
go install github.com/DataDog/pup@latest
- OS: macOS (Darwin 24.6.0)
Summary
pup metrics list --filteralways returns empty results regardless of the filter value. The--filterflag is documented as filtering by metric name pattern, but the implementation passes the value to the Datadog API'stag_filterparameter, which filters by Datadog tags (e.g.,env:prod) — not metric names.Steps to Reproduce
Every filter value produces empty results:
kafka_index,system.*,*cpu*, bare strings, wildcards — all return{"metrics": []}.Root Cause
In
cmd/metrics.go, therunMetricsListfunction passes the--filtervalue asWithTagFilter():The Datadog v1
ListActiveMetricsAPI'stag_filterparameter filters by Datadog tags (comma-separated, e.g.,env:prod,service:api) — not by metric name patterns. Sincekafka_index,system.cpu, etc. are not valid tags, the API returns no matching metrics.Expected Behavior
pup metrics list --filter="kafka_index"should return metrics whose names contain or matchkafka_index, consistent with the help text:Suggested Fix
The v1
ListActiveMetricsAPI doesn't support metric name filtering server-side. Options:--tag-filterflag: Expose the actualtag_filterAPI parameter under its correct name, and use--filterfor client-side name matchingListMetricAssetsor metric search APIs may support name-based filteringEnvironment
dev (unknown)go install github.com/DataDog/pup@latest