feat(xtcp): wide output support — jsonl/csv/tsv + tcp/file/stderr/http#36
Open
randomizedcoder wants to merge 1 commit into
Open
feat(xtcp): wide output support — jsonl/csv/tsv + tcp/file/stderr/http#36randomizedcoder wants to merge 1 commit into
randomizedcoder wants to merge 1 commit into
Conversation
…r/http sinks Make socket data easy to analyze with common tools. Adds, all reusing the existing envelope-marshaller + destination patterns: Formats (envelope marshallers, marshallers_text.go): - jsonl — one raw JSON record per line (NDJSON / ClickHouse JSONEachRow) - csv/tsv — reflection-generated columns (all 122 XtcpFlatRecord fields by default, or a -columns subset), humanized: IPs as dotted-quad/v6, TCP state and congestion as names, timestamp as RFC3339 (humanize.go, flat_record_row.go). Header written once per stream. Destinations (stdlib, no build tag): - tcp:host:port — reliable streaming to Vector/Logstash/Fluentd/nc (fills the UDP-only gap) - file:/path — append to a file (reuses writerDest, 0600) - stderr — one-liner over writerDest - http(s)://... — POST each batch; Content-Type derived from the marshaller Framing: marshallers now own their trailing newline and writerDest/tcp/http write bytes verbatim, so text formats are newline-delimited on every sink while protobufList stays a clean length-delimited stream. Config: new -columns flag → csv_columns proto field; marshal_to min_len 4→3 so "csv"/"tsv" validate (regen-protos updated all language bindings). Tests cover the humanizer (incl. the IPv4-in-16-byte-slot regression), reflection columns + selection, jsonl/csv/tsv output, and tcp/file/stderr/http sinks (net.Listen / httptest). Verified end-to-end in a container: csv/jsonl of real host sockets to stdout with humanized addresses/states. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Makes xtcp2 socket data easy to analyze with everyday tools (R/pandas/DuckDB/jq/Vector). Reuses the existing envelope-marshaller and destination patterns.
Formats (envelope marshallers)
jsonl— one raw JSON record per line (NDJSON / ClickHouse JSONEachRow).csv/tsv— columns generated via protobuf reflection (all 122XtcpFlatRecordfields by default, or a-columnssubset), humanized: IPs as dotted-quad/v6, TCP state & congestion as names, timestamp as RFC3339. Header written once per stream.Destinations (stdlib, no build tag)
tcp:host:port— reliable streaming to Vector/Logstash/Fluentd/nc(fills the UDP-only gap).file:/path— append to a file (reuseswriterDest,0600).stderr— one-liner overwriterDest.http(s)://…— POST each batch;Content-Typederived from the marshaller.Framing refactor
Marshallers now own their trailing newline;
writerDest/tcp/httpwrite bytes verbatim. Text formats are newline-delimited on every sink, whileprotobufListstays a clean length-delimited stream. (Adjusts the\nbehavior introduced in #35.)Config
New
-columnsflag →csv_columnsproto field.marshal_tovalidationmin_len4→3 socsv/tsvvalidate.regen-protosupdated all language bindings.Tests & verification
192.168.122.1, notc0a8:7a01::), reflection columns +-columnsselection/errors, jsonl/csv/tsv output, and tcp/file/stderr/http sinks (net.Listen/httptest).nix build .#test-pkg-xtcp .#test-cmd-xtcp2 .#checks.x86_64-linux.golangci-lintall pass.-dest stdout -marshal csv -columns …and-marshal jsonlprinted real host sockets with humanized addresses/states (172.16.50.219,LISTEN,CUBIC).Roadmap (not in this PR)
Influx line protocol, ClickHouse RowBinary/JSONEachRow-direct, Avro, Arrow, syslog, MQTT, Redis Streams, JetStream, Pulsar, cloud queues, SQL sinks, OTLP, a pretty
tableformat.🤖 Generated with Claude Code