Skip to content

fix(ddsql): correct wrong DDSQL time-series help example#599

Closed
roippi wants to merge 1 commit into
DataDog:mainfrom
roippi:fix/ddsql-help-example
Closed

fix(ddsql): correct wrong DDSQL time-series help example#599
roippi wants to merge 1 commit into
DataDog:mainfrom
roippi:fix/ddsql-help-example

Conversation

@roippi

@roippi roippi commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Summary

The pup ddsql time-series example in --help queried a bare metrics table, which is not a valid DDSQL dataset. Anyone (or more likely anyone's agent) copying the example verbatim hits an HTTP 400. This swaps it for a verified dd.metrics_timeseries(...) query, the spec-correct way to read metrics via DDSQL.

Changes

  • Fixed the time-series example in the ddsql command help (src/main.rs:1083):
    • Before: SELECT avg(system.cpu.user) FROM metrics GROUP BY host
    • After: SELECT timestamp, value, tags->'host' AS host FROM dd.metrics_timeseries('avg:system.cpu.user{*} by {host}')
  • Dropped the misleading --interval 300000 flag from the example — metric resolution comes from the dd.metrics_timeseries(...) call, not that flag.

Testing

  • Reproduced the original failure against the live API:
$ pup ddsql time-series --query "SELECT avg(system.cpu.user) FROM metrics GROUP BY host" --from 1h
#Error: ... (HTTP 400): {"errors":[{"title":"Bad Request","detail":"depends on non-existent dataset "metrics""}]}
  • Verified the replacement returns real per-host timeseries:
$ pup ddsql time-series --query "SELECT timestamp, value, tags->'host' AS host FROM dd.metrics_timeseries('avg:system.cpu.user{*} by {host}')" --from 1h
#[ { "host": "dd-agent7", "timestamp": 1781725600000, "value": 0.1668... }, ... ]
  • cargo check passes (the doc comment feeds clap's verbatim_doc_comment derive).

The `ddsql time-series` example in `--help` queried a bare `metrics`
table, which is not a valid DDSQL dataset and fails with:
  HTTP 400: depends on non-existent dataset "metrics"

Replace it with a verified `dd.metrics_timeseries(...)` table-function
query, the spec-correct way to read metrics via DDSQL.
@roippi roippi requested a review from a team as a code owner June 18, 2026 03:08
@platinummonkey

Copy link
Copy Markdown
Collaborator

I pulled this commit in and signed it in #605 so we can get the signed commit requirement, thanks for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants