fix(inputs.zfs): Support gathering metrics on zfs 2.2.0 and later (#14280)
This commit is contained in:
parent
19c3d26d79
commit
b7e7756e19
|
|
@ -223,6 +223,27 @@ For ZFS >= 2.1.x the format has changed significantly:
|
||||||
- nunlinks (integer, count)
|
- nunlinks (integer, count)
|
||||||
- nunlinked (integer, count)
|
- nunlinked (integer, count)
|
||||||
|
|
||||||
|
For ZFS >= 2.2.x the following additional fields are available:
|
||||||
|
|
||||||
|
- additional fields for ZFS > 2.2.x
|
||||||
|
- zil_commit_count (integer, count)
|
||||||
|
- zil_commit_writer_count (integer, count)
|
||||||
|
- zil_itx_count (integer, count)
|
||||||
|
- zil_itx_indirect_count (integer, count)
|
||||||
|
- zil_itx_indirect_bytes (integer, bytes)
|
||||||
|
- zil_itx_copied_count (integer, count)
|
||||||
|
- zil_itx_copied_bytes (integer, bytes)
|
||||||
|
- zil_itx_needcopy_count (integer, count)
|
||||||
|
- zil_itx_needcopy_bytes (integer, bytes)
|
||||||
|
- zil_itx_metaslab_normal_count (integer, count)
|
||||||
|
- zil_itx_metaslab_normal_bytes (integer, bytes)
|
||||||
|
- zil_itx_metaslab_normal_write (integer, bytes)
|
||||||
|
- zil_itx_metaslab_normal_alloc (integer, bytes)
|
||||||
|
- zil_itx_metaslab_slog_count (integer, count)
|
||||||
|
- zil_itx_metaslab_slog_bytes (integer, bytes)
|
||||||
|
- zil_itx_metaslab_slog_write (integer, bytes)
|
||||||
|
- zil_itx_metaslab_slog_alloc (integer, bytes)
|
||||||
|
|
||||||
On FreeBSD:
|
On FreeBSD:
|
||||||
|
|
||||||
- zfs_pool
|
- zfs_pool
|
||||||
|
|
@ -391,6 +412,7 @@ memory is too low)
|
||||||
|
|
||||||
### ZIL (Linux Only)
|
### ZIL (Linux Only)
|
||||||
|
|
||||||
note: ZIL measurements are system-wide, neither per-pool nor per-dataset
|
note: `zil` measurements in `kstatMetrics` are system-wide, in `poolMetrics`
|
||||||
|
they are pool-wide
|
||||||
|
|
||||||
`zil_commit_count` counts when ZFS transactions are committed to a ZIL
|
`zil_commit_count` counts when ZFS transactions are committed to a ZIL
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ func getTags(pools []poolInfo) map[string]string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func gather(lines []string, fileLines int) ([]string, []string, error) {
|
func gather(lines []string, fileLines int) ([]string, []string, error) {
|
||||||
if len(lines) != fileLines {
|
if len(lines) < fileLines {
|
||||||
return nil, nil, errors.New("expected lines in kstat does not match")
|
return nil, nil, errors.New("expected lines in kstat does not match")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -172,7 +172,7 @@ func gatherPoolStats(pool poolInfo, acc telegraf.Accumulator) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if gatherErr != nil {
|
if gatherErr != nil {
|
||||||
return err
|
return gatherErr
|
||||||
}
|
}
|
||||||
|
|
||||||
acc.AddFields("zfs_pool", fields, tags)
|
acc.AddFields("zfs_pool", fields, tags)
|
||||||
|
|
|
||||||
|
|
@ -130,6 +130,33 @@ nread 4 1884160
|
||||||
nunlinks 4 14148
|
nunlinks 4 14148
|
||||||
nunlinked 4 14147
|
nunlinked 4 14147
|
||||||
`
|
`
|
||||||
|
const objsetV22Contents = `36 1 0x01 7 2160 5214787391 74985931356512
|
||||||
|
name type data
|
||||||
|
dataset_name 7 HOMEV22
|
||||||
|
writes 4 978
|
||||||
|
nwritten 4 6450688
|
||||||
|
reads 4 22
|
||||||
|
nread 4 1884160
|
||||||
|
nunlinks 4 14148
|
||||||
|
nunlinked 4 14147
|
||||||
|
zil_commit_count 4 1
|
||||||
|
zil_commit_writer_count 4 2
|
||||||
|
zil_itx_count 4 3
|
||||||
|
zil_itx_indirect_count 4 4
|
||||||
|
zil_itx_indirect_bytes 4 5
|
||||||
|
zil_itx_copied_count 4 6
|
||||||
|
zil_itx_copied_bytes 4 7
|
||||||
|
zil_itx_needcopy_count 4 8
|
||||||
|
zil_itx_needcopy_bytes 4 9
|
||||||
|
zil_itx_metaslab_normal_count 4 10
|
||||||
|
zil_itx_metaslab_normal_bytes 4 11
|
||||||
|
zil_itx_metaslab_normal_write 4 12
|
||||||
|
zil_itx_metaslab_normal_alloc 4 13
|
||||||
|
zil_itx_metaslab_slog_count 4 14
|
||||||
|
zil_itx_metaslab_slog_bytes 4 15
|
||||||
|
zil_itx_metaslab_slog_write 4 16
|
||||||
|
zil_itx_metaslab_slog_alloc 4 17
|
||||||
|
`
|
||||||
const zilContents = `7 1 0x01 14 672 34118481334 437444452158445
|
const zilContents = `7 1 0x01 14 672 34118481334 437444452158445
|
||||||
name type data
|
name type data
|
||||||
zil_commit_count 4 77
|
zil_commit_count 4 77
|
||||||
|
|
@ -235,6 +262,8 @@ func TestZfsPoolMetrics(t *testing.T) {
|
||||||
|
|
||||||
err = os.WriteFile(testKstatPath+"/HOME/objset-0x20a", []byte(objsetContents), 0640)
|
err = os.WriteFile(testKstatPath+"/HOME/objset-0x20a", []byte(objsetContents), 0640)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
err = os.WriteFile(testKstatPath+"/HOME/objset-0x20b", []byte(objsetV22Contents), 0640)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
acc.Metrics = nil
|
acc.Metrics = nil
|
||||||
|
|
||||||
|
|
@ -242,9 +271,12 @@ func TestZfsPoolMetrics(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
tags["dataset"] = "HOME"
|
tags["dataset"] = "HOME"
|
||||||
|
|
||||||
poolMetrics = getPoolMetricsNewFormat()
|
poolMetrics = getPoolMetricsNewFormat()
|
||||||
acc.AssertContainsTaggedFields(t, "zfs_pool", poolMetrics, tags)
|
acc.AssertContainsTaggedFields(t, "zfs_pool", poolMetrics, tags)
|
||||||
|
|
||||||
|
tags["dataset"] = "HOMEV22"
|
||||||
|
poolMetrics = getPoolMetricsNewFormatV22()
|
||||||
|
acc.AssertContainsTaggedFields(t, "zfs_pool", poolMetrics, tags)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestZfsGeneratesMetrics(t *testing.T) {
|
func TestZfsGeneratesMetrics(t *testing.T) {
|
||||||
|
|
@ -554,3 +586,31 @@ func getPoolMetricsNewFormat() map[string]interface{} {
|
||||||
"writes": int64(978),
|
"writes": int64(978),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getPoolMetricsNewFormatV22() map[string]interface{} {
|
||||||
|
return map[string]interface{}{
|
||||||
|
"nread": int64(1884160),
|
||||||
|
"nunlinked": int64(14147),
|
||||||
|
"nunlinks": int64(14148),
|
||||||
|
"nwritten": int64(6450688),
|
||||||
|
"reads": int64(22),
|
||||||
|
"writes": int64(978),
|
||||||
|
"zil_commit_count": int64(1),
|
||||||
|
"zil_commit_writer_count": int64(2),
|
||||||
|
"zil_itx_count": int64(3),
|
||||||
|
"zil_itx_indirect_count": int64(4),
|
||||||
|
"zil_itx_indirect_bytes": int64(5),
|
||||||
|
"zil_itx_copied_count": int64(6),
|
||||||
|
"zil_itx_copied_bytes": int64(7),
|
||||||
|
"zil_itx_needcopy_count": int64(8),
|
||||||
|
"zil_itx_needcopy_bytes": int64(9),
|
||||||
|
"zil_itx_metaslab_normal_count": int64(10),
|
||||||
|
"zil_itx_metaslab_normal_bytes": int64(11),
|
||||||
|
"zil_itx_metaslab_normal_write": int64(12),
|
||||||
|
"zil_itx_metaslab_normal_alloc": int64(13),
|
||||||
|
"zil_itx_metaslab_slog_count": int64(14),
|
||||||
|
"zil_itx_metaslab_slog_bytes": int64(15),
|
||||||
|
"zil_itx_metaslab_slog_write": int64(16),
|
||||||
|
"zil_itx_metaslab_slog_alloc": int64(17),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue