Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add top metrics plugin to KeyPerf #3315

Merged
merged 3 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions cmd/collectors/keyperf/keyperf.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package keyperf
import (
"fmt"
"github.com/netapp/harvest/v2/cmd/collectors/rest"
"github.com/netapp/harvest/v2/cmd/collectors/restperf/plugins/volumetopmetrics"
"github.com/netapp/harvest/v2/cmd/poller/collector"
"github.com/netapp/harvest/v2/cmd/poller/plugin"
"github.com/netapp/harvest/v2/pkg/conf"
Expand Down Expand Up @@ -145,6 +146,16 @@ func (kp *KeyPerf) loadParamInt(name string, defaultValue int) int {
return defaultValue
}

func (kp *KeyPerf) LoadPlugin(kind string, p *plugin.AbstractPlugin) plugin.Plugin {
switch kind {
case "VolumeTopClients":
return volumetopmetrics.New(p)
default:
kp.Logger.Info("no KeyPerf plugin found", slog.String("kind", kind))
}
return nil
}

func (kp *KeyPerf) buildCounters() {
staticCounterDef, err := LoadStaticCounterDefinitions(kp.Prop.Object, "conf/keyperf/static_counter_definitions.yaml", kp.Logger)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,10 +327,10 @@ func (t *TopMetrics) processTopMetrics(data *matrix.Matrix) (*TopMetricsData, er
}

func (t *TopMetrics) collectMetricValues(data *matrix.Matrix, filteredDataInstances *set.Set) ([]MetricValue, []MetricValue, []MetricValue, []MetricValue) {
readOpsMetric := data.GetMetric("total_read_ops")
writeOpsMetric := data.GetMetric("total_write_ops")
readDataMetric := data.GetMetric("bytes_read")
writeDataMetric := data.GetMetric("bytes_written")
readOpsMetric := data.DisplayMetric("read_ops")
writeOpsMetric := data.DisplayMetric("write_ops")
readDataMetric := data.DisplayMetric("read_data")
writeDataMetric := data.DisplayMetric("write_data")

var readOpsList, writeOpsList, readDataList, writeDataList []MetricValue
for key := range filteredDataInstances.Iter() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,19 @@ func setupMockDataMatrix() *matrix.Matrix {
instance2.SetLabel("volume", "volharvest")
instance2.SetLabel("svm", "osc")

readOpsMetric, _ := data.NewMetricFloat64("total_read_ops")
readOpsMetric, _ := data.NewMetricFloat64("total_read_ops", "read_ops")
_ = readOpsMetric.SetValueFloat64(instance1, 1)
_ = readOpsMetric.SetValueFloat64(instance2, 241)

writeOpsMetric, _ := data.NewMetricFloat64("total_write_ops")
writeOpsMetric, _ := data.NewMetricFloat64("total_write_ops", "write_ops")
_ = writeOpsMetric.SetValueFloat64(instance1, 100)
_ = writeOpsMetric.SetValueFloat64(instance2, 341)

readDataMetric, _ := data.NewMetricFloat64("bytes_read")
readDataMetric, _ := data.NewMetricFloat64("bytes_read", "read_data")
_ = readDataMetric.SetValueFloat64(instance1, 100000)
_ = readDataMetric.SetValueFloat64(instance2, 341000)

writeDataMetric, _ := data.NewMetricFloat64("bytes_written")
writeDataMetric, _ := data.NewMetricFloat64("bytes_written", "write_data")
_ = writeDataMetric.SetValueFloat64(instance1, 100000)
_ = writeDataMetric.SetValueFloat64(instance2, 341000)
return data
Expand All @@ -77,15 +77,14 @@ func init() {
func TestProcessTopClients(t *testing.T) {
testCases := []struct {
name string
metric string
matrixName string
testFilePath string
expectedCount int
}{
{"Client Read Ops", "iops.read", topClientReadOPSMatrix, "testdata/client_readops.json", 1},
{"Client Write Ops", "iops.write", topClientWriteOPSMatrix, "testdata/client_writeops.json", 4},
{"Client Read Data", "throughput.read", topClientReadDataMatrix, "testdata/client_readdata.json", 1},
{"Client Write Data", "throughput.write", topClientWriteDataMatrix, "testdata/client_writedata.json", 3},
{"Client Read Ops", topClientReadOPSMatrix, "testdata/client_readops.json", 1},
{"Client Write Ops", topClientWriteOPSMatrix, "testdata/client_writeops.json", 4},
{"Client Read Data", topClientReadDataMatrix, "testdata/client_readdata.json", 1},
{"Client Write Data", topClientWriteDataMatrix, "testdata/client_writedata.json", 3},
}

for _, tc := range testCases {
Expand Down Expand Up @@ -125,15 +124,14 @@ func TestProcessTopClients(t *testing.T) {
func TestProcessTopFiles(t *testing.T) {
testCases := []struct {
name string
metric string
matrixName string
testFilePath string
expectedCount int
}{
{"File Read Ops", "iops.read", topFileReadOPSMatrix, "testdata/file_readops.json", 1},
{"File Write Ops", "iops.write", topFileWriteOPSMatrix, "testdata/file_writeops.json", 6},
{"File Read Data", "throughput.read", topFileReadDataMatrix, "testdata/file_readdata.json", 1},
{"File Write Data", "throughput.write", topFileWriteDataMatrix, "testdata/file_writedata.json", 1},
{"File Read Ops", topFileReadOPSMatrix, "testdata/file_readops.json", 1},
{"File Write Ops", topFileWriteOPSMatrix, "testdata/file_writeops.json", 6},
{"File Read Data", topFileReadDataMatrix, "testdata/file_readdata.json", 1},
{"File Write Data", topFileWriteDataMatrix, "testdata/file_writedata.json", 1},
}

for _, tc := range testCases {
Expand Down
44 changes: 38 additions & 6 deletions cmd/tools/generate/counter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1687,30 +1687,46 @@ counters:
Endpoint: api/storage/volumes/*/top-metrics/clients
ONTAPCounter: iops.read
Template: conf/rest/9.12.0/volume.yaml
- API: KeyPerf
Endpoint: api/storage/volumes/*/top-metrics/clients
ONTAPCounter: iops.read
Template: conf/keyperf/9.15.0/volume.yaml

- Name: volume_top_clients_write_ops
Description: This metric tracks the number of write operations performed by the top clients on a specific volume.
APIs:
- API: REST
Endpoint: api/storage/volumes/*/top-metrics/clients
ONTAPCounter: iops.read
ONTAPCounter: iops.write
Template: conf/rest/9.12.0/volume.yaml
- API: KeyPerf
Endpoint: api/storage/volumes/*/top-metrics/clients
ONTAPCounter: iops.write
Template: conf/keyperf/9.15.0/volume.yaml

- Name: volume_top_clients_read_data
Description: This metric measures the amount of data read by the top clients to a specific volume.
APIs:
- API: REST
Endpoint: api/storage/volumes/*/top-metrics/clients
ONTAPCounter: iops.read
ONTAPCounter: throughput.read
Template: conf/rest/9.12.0/volume.yaml
- API: KeyPerf
Endpoint: api/storage/volumes/*/top-metrics/clients
ONTAPCounter: throughput.read
Template: conf/keyperf/9.15.0/volume.yaml

- Name: volume_top_clients_write_data
Description: This metric measures the amount of data written by the top clients to a specific volume.
APIs:
- API: REST
Endpoint: api/storage/volumes/*/top-metrics/clients
ONTAPCounter: iops.read
ONTAPCounter: throughput.write
Template: conf/rest/9.12.0/volume.yaml
- API: KeyPerf
Endpoint: api/storage/volumes/*/top-metrics/files
ONTAPCounter: throughput.write
Template: conf/keyperf/9.15.0/volume.yaml

- Name: volume_top_files_read_ops
Description: This metric tracks the number of read operations performed on the files of a specific volume.
Expand All @@ -1719,30 +1735,46 @@ counters:
Endpoint: api/storage/volumes/*/top-metrics/files
ONTAPCounter: iops.read
Template: conf/rest/9.12.0/volume.yaml
- API: KeyPerf
Endpoint: api/storage/volumes/*/top-metrics/files
ONTAPCounter: iops.read
Template: conf/keyperf/9.15.0/volume.yaml

- Name: volume_top_files_write_ops
Description: This metric tracks the number of write operations performed on the files of a specific volume.
APIs:
- API: REST
Endpoint: api/storage/volumes/*/top-metrics/files
ONTAPCounter: iops.read
ONTAPCounter: iops.write
Template: conf/rest/9.12.0/volume.yaml
- API: KeyPerf
Endpoint: api/storage/volumes/*/top-metrics/files
ONTAPCounter: iops.write
Template: conf/keyperf/9.15.0/volume.yaml

- Name: volume_top_files_read_data
Description: This metric measures the amount of data read from the files of a specific volume.
APIs:
- API: REST
Endpoint: api/storage/volumes/*/top-metrics/files
ONTAPCounter: iops.read
ONTAPCounter: throughput.read
Template: conf/rest/9.12.0/volume.yaml
- API: KeyPerf
Endpoint: api/storage/volumes/*/top-metrics/files
ONTAPCounter: throughput.read
Template: conf/keyperf/9.15.0/volume.yaml

- Name: volume_top_files_write_data
Description: This metric measures the amount of data written to the top files of a specific volume.
APIs:
- API: REST
Endpoint: api/storage/volumes/*/top-metrics/files
ONTAPCounter: iops.read
ONTAPCounter: throughput.write
Template: conf/rest/9.12.0/volume.yaml
- API: KeyPerf
Endpoint: api/storage/volumes/*/top-metrics/files
ONTAPCounter: throughput.write
Template: conf/keyperf/9.15.0/volume.yaml

- Name: volume_clone_split_estimate
Description: Display an estimate of additional storage required in the underlying aggregate to perform a volume clone split operation.
Expand Down
9 changes: 9 additions & 0 deletions conf/keyperf/9.15.0/volume.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ endpoints:
- ^nodes => node

plugins:
# - VolumeTopClients:
# # `max_volumes` is the maximum number of volumes to consider for top client metrics. This value is capped at 50, even if a higher number is specified.
# # When enabled, this plugin will collect read/write operations and throughput metrics for the top clients of each volume.
# - schedule:
# - data: 1h # This value should be a multiple of the poll duration. By default, Harvest will check once an hour to see how many volumes have activity_tracking.state set to on.
# - max_volumes: 5
# - objects:
# - client # collect read/write operations and throughput metrics for the top clients.
# - file # collect read/write operations and throughput metrics for the top files
- Aggregator:
# plugin will create summary/average for each object
# any names after the object names will be treated as label names that will be added to instances
Expand Down
22 changes: 15 additions & 7 deletions docs/ontap-metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ These can be generated on demand by running `bin/harvest grafana metrics`. See
- More information about ONTAP REST performance counters can be found [here](https://docs.netapp.com/us-en/ontap-pcmap-9121/index.html).

```
Creation Date : 2024-Nov-19
Creation Date : 2024-Nov-22
ONTAP Version: 9.15.1
```
## Understanding the structure
Expand Down Expand Up @@ -15825,7 +15825,8 @@ This metric measures the amount of data read by the top clients to a specific vo

| API | Endpoint | Metric | Template |
|--------|----------|--------|---------|
| REST | `api/storage/volumes/*/top-metrics/clients` | `iops.read` | conf/rest/9.12.0/volume.yaml |
| REST | `api/storage/volumes/*/top-metrics/clients` | `throughput.read` | conf/rest/9.12.0/volume.yaml |
| KeyPerf | `api/storage/volumes/*/top-metrics/clients` | `throughput.read`<br><span class="key">Unit:</span> <br><span class="key">Type:</span> <br><span class="key">Base:</span> | conf/keyperf/9.15.0/volume.yaml |


### volume_top_clients_read_ops
Expand All @@ -15835,6 +15836,7 @@ This metric tracks the number of read operations performed by the top clients on
| API | Endpoint | Metric | Template |
|--------|----------|--------|---------|
| REST | `api/storage/volumes/*/top-metrics/clients` | `iops.read` | conf/rest/9.12.0/volume.yaml |
| KeyPerf | `api/storage/volumes/*/top-metrics/clients` | `iops.read`<br><span class="key">Unit:</span> <br><span class="key">Type:</span> <br><span class="key">Base:</span> | conf/keyperf/9.15.0/volume.yaml |


### volume_top_clients_write_data
Expand All @@ -15843,7 +15845,8 @@ This metric measures the amount of data written by the top clients to a specific

| API | Endpoint | Metric | Template |
|--------|----------|--------|---------|
| REST | `api/storage/volumes/*/top-metrics/clients` | `iops.read` | conf/rest/9.12.0/volume.yaml |
| REST | `api/storage/volumes/*/top-metrics/clients` | `throughput.write` | conf/rest/9.12.0/volume.yaml |
| KeyPerf | `api/storage/volumes/*/top-metrics/files` | `throughput.write`<br><span class="key">Unit:</span> <br><span class="key">Type:</span> <br><span class="key">Base:</span> | conf/keyperf/9.15.0/volume.yaml |


### volume_top_clients_write_ops
Expand All @@ -15852,7 +15855,8 @@ This metric tracks the number of write operations performed by the top clients o

| API | Endpoint | Metric | Template |
|--------|----------|--------|---------|
| REST | `api/storage/volumes/*/top-metrics/clients` | `iops.read` | conf/rest/9.12.0/volume.yaml |
| REST | `api/storage/volumes/*/top-metrics/clients` | `iops.write` | conf/rest/9.12.0/volume.yaml |
| KeyPerf | `api/storage/volumes/*/top-metrics/clients` | `iops.write`<br><span class="key">Unit:</span> <br><span class="key">Type:</span> <br><span class="key">Base:</span> | conf/keyperf/9.15.0/volume.yaml |


### volume_top_files_read_data
Expand All @@ -15861,7 +15865,8 @@ This metric measures the amount of data read from the files of a specific volume

| API | Endpoint | Metric | Template |
|--------|----------|--------|---------|
| REST | `api/storage/volumes/*/top-metrics/files` | `iops.read` | conf/rest/9.12.0/volume.yaml |
| REST | `api/storage/volumes/*/top-metrics/files` | `throughput.read` | conf/rest/9.12.0/volume.yaml |
| KeyPerf | `api/storage/volumes/*/top-metrics/files` | `throughput.read`<br><span class="key">Unit:</span> <br><span class="key">Type:</span> <br><span class="key">Base:</span> | conf/keyperf/9.15.0/volume.yaml |


### volume_top_files_read_ops
Expand All @@ -15871,6 +15876,7 @@ This metric tracks the number of read operations performed on the files of a spe
| API | Endpoint | Metric | Template |
|--------|----------|--------|---------|
| REST | `api/storage/volumes/*/top-metrics/files` | `iops.read` | conf/rest/9.12.0/volume.yaml |
| KeyPerf | `api/storage/volumes/*/top-metrics/files` | `iops.read`<br><span class="key">Unit:</span> <br><span class="key">Type:</span> <br><span class="key">Base:</span> | conf/keyperf/9.15.0/volume.yaml |


### volume_top_files_write_data
Expand All @@ -15879,7 +15885,8 @@ This metric measures the amount of data written to the top files of a specific v

| API | Endpoint | Metric | Template |
|--------|----------|--------|---------|
| REST | `api/storage/volumes/*/top-metrics/files` | `iops.read` | conf/rest/9.12.0/volume.yaml |
| REST | `api/storage/volumes/*/top-metrics/files` | `throughput.write` | conf/rest/9.12.0/volume.yaml |
| KeyPerf | `api/storage/volumes/*/top-metrics/files` | `throughput.write`<br><span class="key">Unit:</span> <br><span class="key">Type:</span> <br><span class="key">Base:</span> | conf/keyperf/9.15.0/volume.yaml |


### volume_top_files_write_ops
Expand All @@ -15888,7 +15895,8 @@ This metric tracks the number of write operations performed on the files of a sp

| API | Endpoint | Metric | Template |
|--------|----------|--------|---------|
| REST | `api/storage/volumes/*/top-metrics/files` | `iops.read` | conf/rest/9.12.0/volume.yaml |
| REST | `api/storage/volumes/*/top-metrics/files` | `iops.write` | conf/rest/9.12.0/volume.yaml |
| KeyPerf | `api/storage/volumes/*/top-metrics/files` | `iops.write`<br><span class="key">Unit:</span> <br><span class="key">Type:</span> <br><span class="key">Base:</span> | conf/keyperf/9.15.0/volume.yaml |


### volume_total_data
Expand Down