Skip to content

Commit

Permalink
feat: include metrics created via plugins in metrics doc
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulguptajss committed Aug 27, 2024
1 parent 014dce0 commit 1780959
Show file tree
Hide file tree
Showing 6 changed files with 238 additions and 115 deletions.
61 changes: 61 additions & 0 deletions cmd/collectors/power.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/netapp/harvest/v2/cmd/poller/plugin"
"github.com/netapp/harvest/v2/cmd/tools/rest"
"github.com/netapp/harvest/v2/pkg/conf"
constant "github.com/netapp/harvest/v2/pkg/const"
"github.com/netapp/harvest/v2/pkg/errs"
"github.com/netapp/harvest/v2/pkg/logging"
"github.com/netapp/harvest/v2/pkg/matrix"
Expand Down Expand Up @@ -452,3 +453,63 @@ func (my *Sensor) Run(dataMap map[string]*matrix.Matrix) ([]*matrix.Matrix, *uti

return metrics, my.client.Metadata, nil
}

func (my *Sensor) GetGeneratedMetrics() []plugin.CustomMetric {

return []plugin.CustomMetric{
{
Name: "power",
Endpoint: "NA",
ONTAPCounter: constant.HarvestGenerated,
Description: "Power consumed by a node in Watts.",
},
{
Name: "min_temperature",
Endpoint: "NA",
ONTAPCounter: constant.HarvestGenerated,
Description: "Minimum temperature of all non-ambient sensors for node in Celsius.",
},
{
Name: "average_ambient_temperature",
Endpoint: "NA",
ONTAPCounter: constant.HarvestGenerated,
Description: "Average temperature of all ambient sensors for node in Celsius.",
},
{
Name: "average_fan_speed",
Endpoint: "NA",
ONTAPCounter: constant.HarvestGenerated,
Description: "Average fan speed for node in rpm.",
},
{
Name: "average_temperature",
Endpoint: "NA",
ONTAPCounter: constant.HarvestGenerated,
Description: "Average temperature of all non-ambient sensors for node in Celsius.",
},
{
Name: "max_fan_speed",
Endpoint: "NA",
ONTAPCounter: constant.HarvestGenerated,
Description: "Maximum fan speed for node in rpm.",
},
{
Name: "max_temperature",
Endpoint: "NA",
ONTAPCounter: constant.HarvestGenerated,
Description: "Maximum temperature of all non-ambient sensors for node in Celsius.",
},
{
Name: "min_ambient_temperature",
Endpoint: "NA",
ONTAPCounter: constant.HarvestGenerated,
Description: "Minimum temperature of all ambient sensors for node in Celsius.",
},
{
Name: "min_fan_speed",
Endpoint: "NA",
ONTAPCounter: constant.HarvestGenerated,
Description: "Minimum fan speed for node in rpm.",
},
}
}
12 changes: 12 additions & 0 deletions cmd/poller/plugin/MetricGenerator.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package plugin

type CustomMetric struct {
Name string
Endpoint string
ONTAPCounter string
Description string
}

type MetricGenerator interface {
GetGeneratedMetrics() []CustomMetric
}
69 changes: 67 additions & 2 deletions cmd/tools/generate/counter.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ func processRestConfigCounters(path string) map[string]Counter {
fmt.Printf("Unable to import template file %s. File is invalid or empty err=%s\n", path, err)
return nil
}
noExtraMetrics := len(model.MultiplierMetrics) == 0 && len(model.PluginMetrics) == 0
noExtraMetrics := len(model.MultiplierMetrics) == 0 && len(model.PluginMetrics) == 0 && len(model.PluginCustomMetrics) == 0
templateCounters := t.GetChildS("counters")
if model.ExportData == "false" && noExtraMetrics {
return nil
Expand Down Expand Up @@ -312,6 +312,22 @@ func processRestConfigCounters(path string) map[string]Counter {
counters[co.Name] = co
}

for _, metric := range model.PluginCustomMetrics {
co := Counter{
Name: model.Object + "_" + metric.Name,
Description: metric.Description,
APIs: []MetricDef{
{
API: "REST",
Endpoint: metric.Endpoint,
Template: path,
ONTAPCounter: metric.ONTAPCounter,
},
},
}
counters[co.Name] = co
}

return counters
}

Expand Down Expand Up @@ -373,7 +389,7 @@ func processZAPIPerfCounters(path string, client *zapi.Client) map[string]Counte
return nil
}

noExtraMetrics := len(model.MultiplierMetrics) == 0 && len(model.PluginMetrics) == 0
noExtraMetrics := len(model.MultiplierMetrics) == 0 && len(model.PluginMetrics) == 0 && len(model.PluginCustomMetrics) == 0
templateCounters := t.GetChildS("counters")
override := t.GetChildS("override")

Expand Down Expand Up @@ -504,6 +520,23 @@ func processZAPIPerfCounters(path string, client *zapi.Client) map[string]Counte
}
counters[co.Name] = co
}

for _, metric := range model.PluginCustomMetrics {
co := Counter{
Name: model.Object + "_" + metric.Name,
Description: metric.Description,
APIs: []MetricDef{
{
API: "ZAPI",
Endpoint: metric.Endpoint,
Template: path,
ONTAPCounter: metric.ONTAPCounter,
},
},
}
counters[co.Name] = co
}

// handling for templates with common object names
if specialPerfObjects[model.Object] {
return specialHandlingPerfCounters(counters, model)
Expand Down Expand Up @@ -580,6 +613,22 @@ func processZapiConfigCounters(path string) map[string]Counter {
}
counters[co.Name] = co
}

for _, metric := range model.PluginCustomMetrics {
co := Counter{
Name: model.Object + "_" + metric.Name,
Description: metric.Description,
APIs: []MetricDef{
{
API: "ZAPI",
Endpoint: metric.Endpoint,
Template: path,
ONTAPCounter: metric.ONTAPCounter,
},
},
}
counters[co.Name] = co
}
return counters
}

Expand Down Expand Up @@ -910,6 +959,22 @@ func processRestPerfCounters(path string, client *rest.Client) map[string]Counte
}
counters[co.Name] = co
}

for _, metric := range model.PluginCustomMetrics {
co := Counter{
Name: model.Object + "_" + metric.Name,
Description: metric.Description,
APIs: []MetricDef{
{
API: "REST",
Endpoint: metric.Endpoint,
Template: path,
ONTAPCounter: metric.ONTAPCounter,
},
},
}
counters[co.Name] = co
}
// handling for templates with common object names/metric name
if specialPerfObjects[model.Object] {
return specialHandlingPerfCounters(counters, model)
Expand Down
108 changes: 0 additions & 108 deletions cmd/tools/generate/counter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,114 +99,6 @@ counters:
- Name: disk_usable_size
Description: Usable size of each disk, in bytes.

- Name: environment_sensor_average_ambient_temperature
Description: Average temperature of all ambient sensors for node in Celsius.
APIs:
- API: REST
Endpoint: NA
ONTAPCounter: Harvest generated
Template: conf/rest/9.12.0/sensor.yaml
- API: ZAPI
Endpoint: NA
ONTAPCounter: Harvest generated
Template: conf/zapi/cdot/9.8.0/sensor.yaml

- Name: environment_sensor_average_fan_speed
Description: Average fan speed for node in rpm.
APIs:
- API: REST
Endpoint: NA
ONTAPCounter: Harvest generated
Template: conf/rest/9.12.0/sensor.yaml
- API: ZAPI
Endpoint: NA
ONTAPCounter: Harvest generated
Template: conf/zapi/cdot/9.8.0/sensor.yaml

- Name: environment_sensor_average_temperature
Description: Average temperature of all non-ambient sensors for node in Celsius.
APIs:
- API: REST
Endpoint: NA
ONTAPCounter: Harvest generated
Template: conf/rest/9.12.0/sensor.yaml
- API: ZAPI
Endpoint: NA
ONTAPCounter: Harvest generated
Template: conf/zapi/cdot/9.8.0/sensor.yaml

- Name: environment_sensor_max_fan_speed
Description: Maximum fan speed for node in rpm.
APIs:
- API: REST
Endpoint: NA
ONTAPCounter: Harvest generated
Template: conf/rest/9.12.0/sensor.yaml
- API: ZAPI
Endpoint: NA
ONTAPCounter: Harvest generated
Template: conf/zapi/cdot/9.8.0/sensor.yaml

- Name: environment_sensor_max_temperature
Description: Maximum temperature of all non-ambient sensors for node in Celsius.
APIs:
- API: REST
Endpoint: NA
ONTAPCounter: Harvest generated
Template: conf/rest/9.12.0/sensor.yaml
- API: ZAPI
Endpoint: NA
ONTAPCounter: Harvest generated
Template: conf/zapi/cdot/9.8.0/sensor.yaml

- Name: environment_sensor_min_ambient_temperature
Description: Minimum temperature of all ambient sensors for node in Celsius.
APIs:
- API: REST
Endpoint: NA
ONTAPCounter: Harvest generated
Template: conf/rest/9.12.0/sensor.yaml
- API: ZAPI
Endpoint: NA
ONTAPCounter: Harvest generated
Template: conf/zapi/cdot/9.8.0/sensor.yaml

- Name: environment_sensor_min_fan_speed
Description: Minimum fan speed for node in rpm.
APIs:
- API: REST
Endpoint: NA
ONTAPCounter: Harvest generated
Template: conf/rest/9.12.0/sensor.yaml
- API: ZAPI
Endpoint: NA
ONTAPCounter: Harvest generated
Template: conf/zapi/cdot/9.8.0/sensor.yaml

- Name: environment_sensor_min_temperature
Description: Minimum temperature of all non-ambient sensors for node in Celsius.
APIs:
- API: REST
Endpoint: NA
ONTAPCounter: Harvest generated
Template: conf/rest/9.12.0/sensor.yaml
- API: ZAPI
Endpoint: NA
ONTAPCounter: Harvest generated
Template: conf/zapi/cdot/9.8.0/sensor.yaml

- Name: environment_sensor_power
Description: Power consumed by a node in Watts.
APIs:
- API: REST
Endpoint: NA
ONTAPCounter: Harvest generated
Template: conf/rest/9.12.0/sensor.yaml
- API: ZAPI
Endpoint: NA
ONTAPCounter: Harvest generated
Template: conf/zapi/cdot/9.8.0/sensor.yaml

- Name: fabricpool_average_latency
Description: This counter is deprecated.Average latencies executed during various phases of command execution. The execution-start latency represents the average time taken to start executing an operation. The request-prepare latency represent the average time taken to prepare the commplete request that needs to be sent to the server. The send latency represents the average time taken to send requests to the server. The execution-start-to-send-complete represents the average time taken to send an operation out since its execution started. The execution-start-to-first-byte-received represent the average time taken to receive the first byte of a response since the command's request execution started. These counters can be used to identify performance bottlenecks within the object store client module.

Expand Down
Loading

0 comments on commit 1780959

Please sign in to comment.