DLPX-98742 connstat-stats.sh: preserve connstat timestamps in InfluxDB - #128
Open
dbshah12 wants to merge 4 commits into
Open
DLPX-98742 connstat-stats.sh: preserve connstat timestamps in InfluxDB#128dbshah12 wants to merge 4 commits into
dbshah12 wants to merge 4 commits into
Conversation
connstat -T u emits a "= <unix_seconds>" line before each sample. The awk script used this only as a flush trigger and discarded the value. Telegraf's execd input therefore timestamped every row at ingestion time. Since both connstat samples (10 s apart) arrive at Telegraf simultaneously after connstat exits, pairs of data points landed in InfluxDB only ~5 ms apart — making per-second rate calculations useless. Fix: extract the Unix timestamp from each "= <ts>" separator line into batch_ts; append it as a trailing column on every output row. Configure Telegraf's CSV parser to treat that column as the metric timestamp (csv_timestamp_column/csv_timestamp_format = "unix"). Both samples still arrive together, but Telegraf now stores them at the correct connstat collection times — 10 s apart — regardless of ingestion delay. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…tervals With sleep 5, consecutive connstat runs produced an alternating 5s/10s gap pattern: 10s within each run (connstat -i 10) then 5s between runs. Changing to sleep 10 aligns the inter-run gap with the intra-run interval, giving a constant 10s cadence across all sample pairs — verified on engine: connstat_ts=1788165198 (sample 1, run 1) connstat_ts=1788165208 gap=10s (sample 2, run 1) connstat_ts=1788165218 gap=10s (sample 1, run 2) connstat_ts=1788165228 gap=10s (sample 2, run 2) The sleep is still a guard against tight CPU spin if connstat exits immediately (binary missing / kernel module unavailable). Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
dbshah12
requested review from
ShibasishDelphix,
david-mendez1,
prakashsurya and
sebroy
and
a lite review from Copilot
August 31, 2026 09:09
There was a problem hiding this comment.
Pull request overview
This PR fixes timestamp handling for tcp_stats collected via connstat so InfluxDB points reflect the actual connstat sample times (10s apart) rather than Telegraf ingestion time, and it removes an unintended 5s/10s alternating cadence between runs.
Changes:
- Emit the connstat-provided Unix timestamp (
= <unix_seconds>) as a trailingtscolumn on every CSV row produced byconnstat-stats.sh. - Configure Telegraf’s CSV parser to use
tsas the measurement timestamp (csv_timestamp_column = "ts",csv_timestamp_format = "unix"). - Change the outer loop delay from
sleep 5tosleep 10to maintain a consistent 10-second cadence across sample boundaries.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| telegraf/telegraf.base | Adds ts CSV column and instructs Telegraf to use it as the event timestamp (unix seconds). |
| telegraf/connstat-stats.sh | Tracks connstat batch timestamps and appends them per row; updates loop sleep to keep a steady 10s cadence. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
sebroy
requested changes
Sep 1, 2026
dbshah12
force-pushed
the
dlpx/pr/dbshah12/dlpx-98742-connstat-timestamp-fix
branch
from
September 4, 2026 19:26
b08a77e to
7867f1a
Compare
…ring PR URL: https://www.github.com/delphix/performance-diagnostics/pull/128 Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
dbshah12
force-pushed
the
dlpx/pr/dbshah12/dlpx-98742-connstat-timestamp-fix
branch
from
September 4, 2026 19:26
7867f1a to
99482e8
Compare
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.
Background
connstat -T uemits a= <unix_seconds>line before each sample interval. The awk pipeline inconnstat-stats.shused this only as a flush trigger and silently discarded the timestamp value. Since both connstat samples (10 s apart) arrive at Telegraf simultaneously after connstat exits, Telegraf assigned its current ingestion time to every row — causing pairs oftcp_statsdata points to land in InfluxDB only ~5 ms apart instead of 10 s apart.Additionally,
sleep 5between outer loop iterations created an alternating 5 s / 10 s gap pattern even after timestamps were fixed: connstat outputs sample 1 at T=0 and sample 2 at T=10, thensleep 5meant the next sample 1 arrived at T=15 — giving 10 s within a run but only 5 s between runs.Problem
Per-second throughput rate calculations (Δbytes / Δseconds) were meaningless: a ~5 ms gap between samples produced wildly inflated apparent rates (e.g. 12 GB/s computed where actual throughput was ~30 MB/s). Root cause confirmed live on a 2026.5.0.0 engine: both sample batches arrive at Telegraf within 5 ms of each other (1788158588814 ms vs 1788158588819 ms), regardless of the 10 s connstat interval.
Solution
telegraf/connstat-stats.sh: Track the Unix timestamp from each= <ts>separator line inbatch_ts; append it as a trailing CSV column on every output row. Thesub(/^=[[:space:]]*/, "", ts)strip is needed because the field separator is,so$2is empty for these lines.telegraf/telegraf.base: Add"ts"tocsv_column_names/csv_column_types; setcsv_timestamp_column = "ts"andcsv_timestamp_format = "unix"so Telegraf uses the connstat-provided timestamp rather than ingestion time.sleep 5→sleep 10: Aligns the inter-run gap with the intra-run connstat interval, giving a constant 10 s cadence.connstat -c 2 -i 10outputs sample 1 at T=0 and sample 2 at T=10, thensleep 10places the next sample 1 at T=20 — all gaps are 10 s.Test plan
Deployed to
dhruv5.dlpxdc.co(2026.5.0.0 engine) and queried InfluxDB after 15 minutes of collection.Gap distribution across all series (last 15 min):
155 / 167 gaps (93%) are exactly 10 s. No 5 s gaps anywhere. The alternating 5 s / 10 s pattern is completely gone.
Sample data for
raddr=10.43.50.230, service=dlpx-spover 6 minutes:Generated with Claude Code