Skip to content

feat: improve dataobj-inspect command - #18618

Merged
grobinson-grafana merged 9 commits into
mainfrom
grobinson/improve-data-obj-inspect
Jul 29, 2025
Merged

feat: improve dataobj-inspect command#18618
grobinson-grafana merged 9 commits into
mainfrom
grobinson/improve-data-obj-inspect

Conversation

@grobinson-grafana

@grobinson-grafana grobinson-grafana commented Jul 28, 2025

Copy link
Copy Markdown
Contributor

This commit improves the dataobj-inspect command to have two sub-commands:

dump: Dumps the contents of each data object in file.
stats: Prints stats for each data object in file.

Here is an example of how it looks:

Streams section:
        offset: 0, columns: 8, compressed size: 219 B; uncompressed size 171 B
                STREAM_ID[]; 1 populated rows; 4 B compressed (NONE); 4 B uncompressed
                MIN_TIMESTAMP[]; 1 populated rows; 13 B compressed (NONE); 13 B uncompressed
                MAX_TIMESTAMP[]; 1 populated rows; 13 B compressed (NONE); 13 B uncompressed
                ROWS[]; 1 populated rows; 4 B compressed (NONE); 4 B uncompressed
                UNCOMPRESSED_SIZE[]; 0 populated rows; 3 B compressed (NONE); 3 B uncompressed
                LABEL[__end__]; 1 populated rows; 39 B compressed (ZSTD); 23 B uncompressed
                LABEL[__path__]; 1 populated rows; 104 B compressed (ZSTD); 88 B uncompressed
                LABEL[__start__]; 1 populated rows; 39 B compressed (ZSTD); 23 B uncompressed
Logs section:
        offset: 1, columns: 3, compressed size: 20 B; uncompressed size 20 B
                STREAM_ID[]; 1 populated rows; 4 B compressed (NONE); 4 B uncompressed
                TIMESTAMP[]; 1 populated rows; 13 B compressed (NONE); 13 B uncompressed
                MESSAGE[]; 0 populated rows; 3 B compressed (ZSTD); 3 B uncompressed

What this PR does / why we need it:

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

Checklist

  • Reviewed the CONTRIBUTING.md guide (required)
  • Documentation added
  • Tests updated
  • Title matches the required conventional commits format, see here
    • Note that Promtail is considered to be feature complete, and future development for logs collection will be in Grafana Alloy. As such, feat PRs are unlikely to be accepted unless a case can be made for the feature actually being a bug fix to existing behavior.
  • Changes that require user attention or interaction to upgrade are documented in docs/sources/setup/upgrade/_index.md
  • If the change is deprecating or removing a configuration option, update the deprecated-config.yaml and deleted-config.yaml files respectively in the tools/deprecated-config-checker directory. Example PR
@grobinson-grafana
grobinson-grafana requested a review from a team as a code owner July 28, 2025 14:31
@grobinson-grafana
grobinson-grafana force-pushed the grobinson/improve-data-obj-inspect branch from eb7c3b5 to 970db6d Compare July 28, 2025 14:53
@grobinson-grafana grobinson-grafana changed the title Improve dataobj-inspect command Jul 28, 2025
@grobinson-grafana
grobinson-grafana force-pushed the grobinson/improve-data-obj-inspect branch 2 times, most recently from 6c8602c to eb96803 Compare July 28, 2025 16:26
This commit improves the dataobj-inspect command to have two
sub-commands:

    dump: Dumps the contents of each data object in file.
    summary: Prints a summary of each data object in file.
@grobinson-grafana
grobinson-grafana force-pushed the grobinson/improve-data-obj-inspect branch from eb96803 to 6a74229 Compare July 28, 2025 16:33

@benclive benclive left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! I'm happy to approve after the reader conditions are fixed. Thanks for implementing!

Another thought: It's not a blocker since this cmd is for debugging and I haven't actually used it myself, but the print streams command feels like it should be a stream-id filter on the dump command instead

Comment thread cmd/dataobj-inspect/dump.go Outdated
case logs.CheckSection(sec):
cmd.dumpLogsSection(context.TODO(), offset, sec)
default:
exitWithError(errors.New("unknown section"))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have the section metadata from sec? It might be nice to print "unknown section: X" instead of exiting completely on the first unknown section

Comment thread cmd/dataobj-inspect/dump.go Outdated
Comment thread cmd/dataobj-inspect/dump.go Outdated
Comment thread cmd/dataobj-inspect/dump.go

@benclive benclive left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM apart from one reader's if statement. Approving to unblock though.

Comment thread cmd/dataobj-inspect/dump.go Outdated
@grobinson-grafana
grobinson-grafana merged commit 238e0b7 into main Jul 29, 2025
95 of 116 checks passed
@grobinson-grafana
grobinson-grafana deleted the grobinson/improve-data-obj-inspect branch July 29, 2025 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2 participants