Skip to content

Commit 85d2545

Browse files
dbshah12claude
andcommitted
DLPX-96312 Filter garbage stat names from estat metaslab-alloc output
Wraps estat metaslab-alloc in a shell script that drops JSON lines whose "name" tag contains non-standard characters (backslashes, hashes, etc.). Addresses DLPX-88427 where a kernel bug causes random memory bytes or C macro strings to appear as stat names, producing unreadable metrics. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent b30f511 commit 85d2545

4 files changed

Lines changed: 23 additions & 15 deletions

File tree

telegraf/connstat-stats.sh

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22
#
33
# Collect per-connection TCP stats from connstat and aggregate by remote
4-
# endpoint (laddr:raddr:rport) to bound cardinality on engines with many
4+
# endpoint (laddr:raddr:service) to bound cardinality on engines with many
55
# connections — e.g. Oracle dNFS (hundreds of connections per VDB host) or
66
# Elastic Data (many connections per object storage endpoint IP).
77
# Mirrors the aggregation done by LocalTCPStatsCollector in the mgmt stack.
@@ -11,7 +11,7 @@
1111
# engine is the server) are identified correctly. Falls back to "unknown".
1212
#
1313
# Output fields per aggregated endpoint:
14-
# laddr, raddr, rport, service
14+
# laddr, raddr, service
1515
# inbytes, outbytes, retranssegs, suna, unsent (summed across connections)
1616
# swnd, cwnd, rwnd, rtt (averaged across connections)
1717
# connections (count of aggregated conns)
@@ -41,7 +41,7 @@ BEGIN {
4141
for (key in cnt) {
4242
n = cnt[key]
4343
split(key, k, SUBSEP)
44-
print k[1] "," k[2] "," k[3] "," k[4] "," \
44+
print k[1] "," k[2] "," k[3] "," \
4545
inb[key] "," outb[key] "," ret[key] "," sun[key] "," uns[key] "," \
4646
int(sw[key]/n) "," int(cw[key]/n) "," int(rw[key]/n) "," int(rt[key]/n) "," n
4747
}
@@ -50,16 +50,14 @@ BEGIN {
5050
next
5151
}
5252
NF == 13 {
53-
lport = $2 + 0
54-
rport = $4 + 0
55-
if (lport in svc) {
56-
service = svc[lport]
57-
} else if (rport in svc) {
58-
service = svc[rport]
53+
if (($2 + 0) in svc) {
54+
service = svc[$2 + 0]
55+
} else if (($4 + 0) in svc) {
56+
service = svc[$4 + 0]
5957
} else {
6058
service = "unknown"
6159
}
62-
key = $1 SUBSEP $3 SUBSEP rport SUBSEP service
60+
key = $1 SUBSEP $3 SUBSEP service
6361
inb[key] += $5; outb[key] += $6; ret[key] += $7
6462
sun[key] += $8; uns[key] += $9
6563
sw[key] += $10; cw[key] += $11; rw[key] += $12; rt[key] += $13

telegraf/metaslab-alloc-stats.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
#
3+
# Wrapper around "estat metaslab-alloc -jm 10" that filters out metrics whose
4+
# "name" tag contains garbage characters (DLPX-88427). A kernel bug causes
5+
# estat to occasionally emit stat names containing raw memory bytes or C macro
6+
# strings. Only names consisting of printable ASCII letters, digits, spaces,
7+
# and common punctuation are passed through.
8+
#
9+
estat metaslab-alloc -jm 10 | grep -E '"name":"[A-Za-z0-9 ,_()/.-]+"'

telegraf/telegraf.base

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@
6868
data_format = "csv"
6969
csv_delimiter = ","
7070
csv_trim_space = true
71-
csv_column_names = ["laddr", "raddr", "rport", "service", "inbytes", "outbytes", "retranssegs", "suna", "unsent", "swnd", "cwnd", "rwnd", "rtt", "connections"]
72-
csv_column_types = ["string", "string", "int", "string", "int", "int", "int", "int", "int", "int", "int", "int", "int", "int"]
73-
csv_tag_columns = ["laddr", "raddr", "rport", "service"]
71+
csv_column_names = ["laddr", "raddr", "service", "inbytes", "outbytes", "retranssegs", "suna", "unsent", "swnd", "cwnd", "rwnd", "rtt", "connections"]
72+
csv_column_types = ["string", "string", "string", "int", "int", "int", "int", "int", "int", "int", "int", "int", "int"]
73+
csv_tag_columns = ["laddr", "raddr", "service"]
7474

7575
# Track CPU and Memory for the "delphix-mgmt" service (and children).
7676
[[inputs.procstat]]

telegraf/telegraf.inputs.playbook

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,10 @@
5555
]
5656
json_string_fields = ["iops(/s)", "avg latency(us)", "stddev(us)", "throughput(k/s)", "microseconds"]
5757

58-
# Collect output from "estat metaslab-alloc -jm 10"
58+
# Collect output from "estat metaslab-alloc -jm 10" via wrapper script.
59+
# The wrapper filters out metrics with garbage "name" tags (DLPX-88427).
5960
[[inputs.execd]]
60-
command = ["estat", "metaslab-alloc", "-jm", "10"]
61+
command = ["/etc/telegraf/metaslab-alloc-stats.sh"]
6162
name_override = "estat_metaslab-alloc"
6263
signal = "none"
6364
restart_delay = "30s"

0 commit comments

Comments
 (0)