Skip to content

Commit

Permalink
feat: make workload_class configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulguptajss committed Jun 14, 2023
1 parent ee6c1b6 commit 5e4c10c
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 7 deletions.
34 changes: 29 additions & 5 deletions cmd/collectors/restperf/restperf.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/netapp/harvest/v2/pkg/errs"
"github.com/netapp/harvest/v2/pkg/matrix"
"github.com/netapp/harvest/v2/pkg/set"
"github.com/netapp/harvest/v2/pkg/tree/node"
"github.com/netapp/harvest/v2/pkg/util"
"github.com/tidwall/gjson"
"path"
Expand All @@ -28,9 +29,11 @@ import (
)

const (
latencyIoReqd = 10
BILLION = 1_000_000_000
arrayKeyToken = "#"
latencyIoReqd = 10
BILLION = 1_000_000_000
arrayKeyToken = "#"
objWorkloadClass = "user_defined|system_defined"
objWorkloadVolumeClass = "autovolume"
)

var qosQuery = "api/cluster/counter/tables/qos"
Expand Down Expand Up @@ -171,6 +174,27 @@ func (r *RestPerf) InitMatrix() error {
return nil
}

// load workload_class or use defaultValue
func (r *RestPerf) loadWorkloadClassQuery(defaultValue string) string {

var x *node.Node

name := "workload_class"

if x = r.Params.GetChildS(name); x != nil {
v := x.GetAllChildContentS()
if len(v) == 0 {
r.Logger.Debug().Msgf("using %s = [%s] (default)", name, defaultValue)
return defaultValue
}
s := strings.Join(v, "|")
r.Logger.Debug().Msgf("using %s = [%s]", name, s)
return s
}
r.Logger.Debug().Msgf("using %s = [%s] (default)", name, defaultValue)
return defaultValue
}

// load an int parameter or use defaultValue
func (r *RestPerf) loadParamInt(name string, defaultValue int) int {

Expand Down Expand Up @@ -1255,9 +1279,9 @@ func (r *RestPerf) PollInstance() (map[string]*matrix.Matrix, error) {
fields = "*"
dataQuery = qosWorkloadQuery
if r.Prop.Query == qosVolumeQuery || r.Prop.Query == qosDetailVolumeQuery {
filter = append(filter, "workload-class=autovolume")
filter = append(filter, "workload_class="+r.loadWorkloadClassQuery(objWorkloadVolumeClass))
} else {
filter = append(filter, "workload-class=user_defined|system_defined")
filter = append(filter, "workload_class="+r.loadWorkloadClassQuery(objWorkloadClass))
}
}

Expand Down
27 changes: 25 additions & 2 deletions cmd/collectors/zapiperf/zapiperf.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ const (
objWorkloadDetail = "workload_detail"
objWorkloadVolume = "workload_volume"
objWorkloadDetailVolume = "workload_detail_volume"
objWorkloadClass = "user_defined|system_defined"
objWorkloadVolumeClass = "autovolume"
BILLION = 1_000_000_000
)

Expand Down Expand Up @@ -172,6 +174,27 @@ func (z *ZapiPerf) loadParamStr(name, defaultValue string) string {
return defaultValue
}

// load workload_class or use defaultValue
func (z *ZapiPerf) loadWorkloadClassQuery(defaultValue string) string {

var x *node.Node

name := "workload_class"

if x = z.Params.GetChildS(name); x != nil {
v := x.GetAllChildContentS()
if len(v) == 0 {
z.Logger.Debug().Msgf("using %s = [%s] (default)", name, defaultValue)
return defaultValue
}
s := strings.Join(v, "|")
z.Logger.Debug().Msgf("using %s = [%s]", name, s)
return s
}
z.Logger.Debug().Msgf("using %s = [%s] (default)", name, defaultValue)
return defaultValue
}

// load an int parameter or use defaultValue
func (z *ZapiPerf) loadParamInt(name string, defaultValue int) int {

Expand Down Expand Up @@ -1318,9 +1341,9 @@ func (z *ZapiPerf) PollInstance() (map[string]*matrix.Matrix, error) {
queryElem := request.NewChildS("query", "")
infoElem := queryElem.NewChildS("qos-workload-info", "")
if z.Query == objWorkloadVolume || z.Query == objWorkloadDetailVolume {
infoElem.NewChildS("workload-class", "autovolume|user_defined|system_defined")
infoElem.NewChildS("workload-class", z.loadWorkloadClassQuery(objWorkloadVolumeClass))
} else {
infoElem.NewChildS("workload-class", "user_defined|system_defined")
infoElem.NewChildS("workload-class", z.loadWorkloadClassQuery(objWorkloadClass))
}

instancesAttr = "attributes-list"
Expand Down
4 changes: 4 additions & 0 deletions conf/restperf/9.12.0/workload.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ object: qos

# recommended to use large interval, since workload objects are expensive
client_timeout: 1m30s
workload_class:
- user_defined
- system_defined

schedule:
- counter: 1200s
- instance: 600s
Expand Down
4 changes: 4 additions & 0 deletions conf/restperf/9.12.0/workload_detail.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ object: qos_detail

# recommended to use large interval, since workload objects are expensive
client_timeout: 1m30s
workload_class:
- user_defined
- system_defined

schedule:
- counter: 1200s
- instance: 600s
Expand Down
3 changes: 3 additions & 0 deletions conf/restperf/9.12.0/workload_detail_volume.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ object: qos_detail

# recommended to use large interval, since workload objects are expensive
client_timeout: 1m30s
workload_class:
- autovolume

schedule:
- counter: 1200s
- instance: 600s
Expand Down
3 changes: 3 additions & 0 deletions conf/restperf/9.12.0/workload_volume.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ object: qos

# recommended to use large interval, since workload objects are expensive
client_timeout: 1m30s
workload_class:
- autovolume

schedule:
- counter: 1200s
- instance: 600s
Expand Down
3 changes: 3 additions & 0 deletions conf/zapiperf/cdot/9.8.0/workload.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ query: workload
object: qos

instance_key: uuid
workload_class:
- user_defined
- system_defined

# recommended to use large interval, since workload objects are expensive
client_timeout: 1m30s
Expand Down
4 changes: 4 additions & 0 deletions conf/zapiperf/cdot/9.8.0/workload_detail.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ instance_key: name

# recommended to use a large interval, since workload objects are expensive
client_timeout: 1m30s
workload_class:
- user_defined
- system_defined

schedule:
- counter: 1200s
- instance: 600s
Expand Down
3 changes: 3 additions & 0 deletions conf/zapiperf/cdot/9.8.0/workload_detail_volume.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ instance_key: name

# recommended to use a large interval, since workload objects are expensive
client_timeout: 1m30s
workload_class:
- autovolume

schedule:
- counter: 1200s
- instance: 600s
Expand Down
2 changes: 2 additions & 0 deletions conf/zapiperf/cdot/9.8.0/workload_volume.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ schedule:
- data: 180s

instance_key: name
workload_class:
- autovolume

counters:
- instance_name
Expand Down

0 comments on commit 5e4c10c

Please sign in to comment.