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: keyperf collector templates #3194

Merged
merged 6 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
42 changes: 40 additions & 2 deletions cmd/collectors/keyperf/keyperf.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,12 @@ func (kp *KeyPerf) loadParamInt(name string, defaultValue int) int {
}

func (kp *KeyPerf) buildCounters() {
for k := range kp.Prop.Metrics {
staticCounterDef, err := loadStaticCounterDefinitions(kp.Prop.Object, "cmd/collectors/keyperf/static_counter_definitions.yaml", kp.Logger)
if err != nil {
kp.Logger.Error("Failed to load static counter definitions", slog.Any("error", err))
rahulguptajss marked this conversation as resolved.
Show resolved Hide resolved
}

for k, v := range kp.Prop.Metrics {
if _, exists := kp.perfProp.counterInfo[k]; !exists {
var ctr *counter

Expand Down Expand Up @@ -169,6 +174,36 @@ func (kp *KeyPerf) buildCounters() {
counterType: "delta",
unit: "sec",
}
default:
// look up metric in staticCounterDef
if counterDef, exists := staticCounterDef.CounterDefinitions[v.Name]; exists {
ctr = &counter{
name: k,
counterType: counterDef.Type,
denominator: counterDef.BaseCounter,
}
if counterDef.BaseCounter != "" {
// Ensure denominator exists in counterInfo
if _, denomExists := kp.perfProp.counterInfo[counterDef.BaseCounter]; !denomExists {
var baseCounterType string
if baseCounterDef, baseCounterExists := staticCounterDef.CounterDefinitions[counterDef.BaseCounter]; baseCounterExists {
baseCounterType = baseCounterDef.Type
}
if baseCounterType != "" {
kp.perfProp.counterInfo[counterDef.BaseCounter] = &counter{
name: counterDef.BaseCounter,
counterType: staticCounterDef.CounterDefinitions[counterDef.BaseCounter].Type,
}
if _, dExists := kp.Prop.Metrics[counterDef.BaseCounter]; !dExists {
m := &rest.Metric{Label: "", Name: counterDef.BaseCounter, MetricType: "", Exportable: false}
kp.Prop.Metrics[counterDef.BaseCounter] = m
}
}
}
}
} else {
slog.Warn("Skipping metric due to unknown metricType", "name", k, "metricType", v.MetricType)
rahulguptajss marked this conversation as resolved.
Show resolved Hide resolved
}
}

if ctr != nil {
Expand Down Expand Up @@ -303,7 +338,8 @@ func (kp *KeyPerf) pollData(
orderedDenominatorKeys = append(orderedDenominatorKeys, key)
}
} else {
kp.Logger.Warn("Counter is missing or unable to parse", slog.String("counter", metric.GetName()))
kp.Logger.Error("Counter is missing or unable to parse", slog.String("counter", metric.GetName()))
metric.SetExportable(false)
}
}

Expand Down Expand Up @@ -374,6 +410,8 @@ func (kp *KeyPerf) pollData(
slog.String("denominator", counter.denominator),
slog.Int("instIndex", instIndex),
)
skips = curMat.Record(key, false)
totalSkips += skips
continue
}

Expand Down
8 changes: 8 additions & 0 deletions cmd/collectors/keyperf/static_counter_definitions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
objects:
node:
counter_definitions:
- name: statistics.processor_utilization_raw
type: percent
base_counter: statistics.processor_utilization_base
- name: statistics.processor_utilization_base
type: delta
65 changes: 65 additions & 0 deletions cmd/collectors/keyperf/templating.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package keyperf

import (
"gopkg.in/yaml.v3"
"log/slog"
"os"
)

type CounterDefinition struct {
Name string `yaml:"name"`
Type string `yaml:"type"`
BaseCounter string `yaml:"base_counter,omitempty"`
}

type ObjectCounters struct {
CounterDefinitions map[string]CounterDefinition `yaml:"-"`
}

type Object struct {
CounterDefinitions []CounterDefinition `yaml:"counter_definitions"`
}

type StaticCounterDefinitions struct {
Objects map[string]Object `yaml:"objects"`
}

func loadStaticCounterDefinitions(object string, filePath string, logger *slog.Logger) (ObjectCounters, error) {
var staticDefinitions StaticCounterDefinitions
var objectCounters ObjectCounters

data, err := os.ReadFile(filePath)
if err != nil {
return objectCounters, err
}

err = yaml.Unmarshal(data, &staticDefinitions)
if err != nil {
return objectCounters, err
}

if obj, exists := staticDefinitions.Objects[object]; exists {
allCounterDefs := make(map[string]CounterDefinition)
for _, def := range obj.CounterDefinitions {
allCounterDefs[def.Name] = def
}

objectCounters.CounterDefinitions = make(map[string]CounterDefinition)
for _, def := range obj.CounterDefinitions {
if def.Type == "" {
logger.Error("Missing type in counter definition", slog.String("filePath", filePath), slog.String("counterName", def.Name))
continue
}
if def.BaseCounter != "" {
if _, baseCounterExists := allCounterDefs[def.BaseCounter]; !baseCounterExists {
logger.Error("Base counter definition not found", slog.String("filePath", filePath), slog.String("counterName", def.Name), slog.String("baseCounter", def.BaseCounter))
continue
}
}
objectCounters.CounterDefinitions[def.Name] = def
}
return objectCounters, nil
}

return objectCounters, nil
}
2 changes: 2 additions & 0 deletions cmd/collectors/rest/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,8 @@ func (r *Rest) HandleResults(mat *matrix.Matrix, result []gjson.Result, prop *pr
slog.Any("err", err),
slog.String("name", metric.Name),
)
} else {
metr.SetExportable(metric.Exportable)
}
}
f := instanceData.Get(metric.Name)
Expand Down
2 changes: 1 addition & 1 deletion cmd/tools/template/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (

const toConf = "../../../conf"

var allTemplatesButEms = []string{"rest", "restperf", "storagegrid", "zapi", "zapiperf"}
var allTemplatesButEms = []string{"rest", "restperf", "storagegrid", "zapi", "zapiperf", "keyperf"}

// validates each template file name:
// - ends with yaml
Expand Down
30 changes: 30 additions & 0 deletions conf/keyperf/9.15.0/aggr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Aggregate
query: api/storage/aggregates
object: aggr

counters:
- ^^uuid => uuid
- ^name => aggr
- ^node.name => node
- ^statistics.status => status
- statistics.iops_raw.other => other_ops
- statistics.iops_raw.read => read_ops
- statistics.iops_raw.total => total_ops
- statistics.iops_raw.write => write_ops
- statistics.latency_raw.other => other_latency
- statistics.latency_raw.read => read_latency
- statistics.latency_raw.total => total_latency
- statistics.latency_raw.write => write_latency
- statistics.throughput_raw.other => other_data
- statistics.throughput_raw.read => read_data
- statistics.throughput_raw.total => total_data
- statistics.throughput_raw.write => write_data
- statistics.timestamp(timestamp) => timestamp
- hidden_fields:
- statistics


export_options:
instance_keys:
- aggr
- node
27 changes: 27 additions & 0 deletions conf/keyperf/9.15.0/cifs_vserver.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: CIFSvserver
query: api/protocols/cifs/services
object: svm_cifs

counters:
- ^^svm.uuid => uuid
- ^statistics.status => status
- ^svm.name => svm
- statistics.iops_raw.other => other_ops
- statistics.iops_raw.read => read_ops
- statistics.iops_raw.total => total_ops
- statistics.iops_raw.write => write_ops
- statistics.latency_raw.other => other_latency
- statistics.latency_raw.read => read_latency
- statistics.latency_raw.total => total_latency
- statistics.latency_raw.write => write_latency
- statistics.throughput_raw.other => other_data
- statistics.throughput_raw.read => read_data
- statistics.throughput_raw.write => write_data
- statistics.timestamp(timestamp) => timestamp
- hidden_fields:
- statistics


export_options:
instance_keys:
- svm
27 changes: 27 additions & 0 deletions conf/keyperf/9.15.0/cluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Cluster
query: api/cluster
object: cluster

counters:
- ^^uuid => uuid
- ^statistics.status => status
- statistics.iops_raw.other => other_ops
- statistics.iops_raw.read => read_ops
- statistics.iops_raw.total => total_ops
- statistics.iops_raw.write => write_ops
- statistics.latency_raw.other => other_latency
- statistics.latency_raw.read => read_latency
- statistics.latency_raw.total => total_latency
- statistics.latency_raw.write => write_latency
- statistics.throughput_raw.other => other_data
- statistics.throughput_raw.read => read_data
- statistics.throughput_raw.total => total_data
- statistics.throughput_raw.write => write_data
- statistics.timestamp(timestamp) => timestamp
- hidden_fields:
- statistics


export_options:
instance_keys:
- uuid
27 changes: 27 additions & 0 deletions conf/keyperf/9.15.0/iscsi_svm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: ISCSISvm
query: api/protocols/san/iscsi/services
object: iscsi_svm

counters:
- ^^svm.name => svm
- ^statistics.status => status
- ^target.name => target
- statistics.iops_raw.other => other_ops
- statistics.iops_raw.read => read_ops
- statistics.iops_raw.total => total_ops
- statistics.iops_raw.write => write_ops
- statistics.latency_raw.other => other_latency
- statistics.latency_raw.read => read_latency
- statistics.latency_raw.total => total_latency
- statistics.latency_raw.write => write_latency
- statistics.throughput_raw.read => read_data
- statistics.throughput_raw.total => total_data
- statistics.throughput_raw.write => write_data
- statistics.timestamp(timestamp) => timestamp
- hidden_fields:
- statistics

export_options:
instance_keys:
- svm
- target
25 changes: 25 additions & 0 deletions conf/keyperf/9.15.0/lif.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: LIF
query: api/network/ip/interfaces
object: lif

counters:
- ^^uuid
- ^location.node.name => node
- ^location.port.name => port
- ^name => lif
- ^statistics.status => status
- ^svm.name => svm
- statistics.throughput_raw.read => sent_data
- statistics.throughput_raw.total => total_data
- statistics.throughput_raw.write => recv_data
- statistics.timestamp(timestamp) => timestamp
- hidden_fields:
- statistics


export_options:
instance_keys:
- lif
- node
- port
- svm
38 changes: 38 additions & 0 deletions conf/keyperf/9.15.0/lun.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Lun
query: api/storage/luns
object: lun

counters:
- ^^uuid => uuid
- ^location.volume.name => volume
- ^name => path
- ^statistics.status => status
- ^svm.name => svm
- statistics.iops_raw.other => other_ops
- statistics.iops_raw.read => read_ops
- statistics.iops_raw.total => total_ops
- statistics.iops_raw.write => write_ops
- statistics.latency_raw.other => other_latency
- statistics.latency_raw.read => avg_read_latency
- statistics.latency_raw.total => total_latency
- statistics.latency_raw.write => avg_write_latency
- statistics.throughput_raw.other => other_data
- statistics.throughput_raw.read => read_data
- statistics.throughput_raw.total => total_data
- statistics.throughput_raw.write => write_data
- statistics.timestamp(timestamp) => timestamp
- hidden_fields:
- statistics


plugins:
LabelAgent:
split_regex:
- path `^/[^/]+/([^/]+)(?:/.*?|)/([^/]+)$` volume,lun
- path `^([^/]+)$` lun

export_options:
instance_keys:
- lun
- svm
- volume
36 changes: 36 additions & 0 deletions conf/keyperf/9.15.0/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Namespace
query: api/storage/namespaces
object: namespace

counters:
- ^^uuid => uuid
- ^name => path
- ^statistics.status => status
- ^svm.name => svm
- statistics.iops_raw.other => other_ops
- statistics.iops_raw.read => read_ops
- statistics.iops_raw.total => total_ops
- statistics.iops_raw.write => write_ops
- statistics.latency_raw.other => avg_other_latency
- statistics.latency_raw.read => avg_read_latency
- statistics.latency_raw.total => avg_total_latency
- statistics.latency_raw.write => avg_write_latency
- statistics.throughput_raw.other => other_data
- statistics.throughput_raw.read => read_data
- statistics.throughput_raw.total => total_data
- statistics.throughput_raw.write => write_data
- statistics.timestamp(timestamp) => timestamp
- hidden_fields:
- statistics

plugins:
LabelAgent:
split:
- path `/` ,,volume,namespace

export_options:
instance_keys:
- namespace
- path
- svm
- volume
16 changes: 16 additions & 0 deletions conf/keyperf/9.15.0/node.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Node
query: api/cluster/nodes
object: node

counters:
- ^^uuid => uuid
- ^name => node
- ^statistics.status => status
- statistics.processor_utilization_raw => avg_processor_busy
- statistics.timestamp(timestamp) => timestamp
- hidden_fields:
- statistics

export_options:
instance_keys:
- node
Loading