Skip to content
Open
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
149 changes: 76 additions & 73 deletions internal/openmetrics-exporter/file_systems_perf_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,78 +23,81 @@ func (c *FileSystemsPerfCollector) Describe(ch chan<- *prometheus.Desc) {
}

func (c *FileSystemsPerfCollector) Collect(ch chan<- prometheus.Metric) {
filesystemsperf := c.Client.GetFileSystemsPerformance(c.FileSystems, "NFS")
if len(filesystemsperf.Items) == 0 {
if len(c.FileSystems.Items) == 0 {
return
}

for _, fp := range filesystemsperf.Items {
ch <- prometheus.MustNewConstMetric(
c.LatencyDesc,
prometheus.GaugeValue,
fp.UsecPerOtherOp,
fp.Name, "usec_per_other_op",
)
ch <- prometheus.MustNewConstMetric(
c.LatencyDesc,
prometheus.GaugeValue,
fp.UsecPerReadOp,
fp.Name, "usec_per_read_op",
)
ch <- prometheus.MustNewConstMetric(
c.LatencyDesc,
prometheus.GaugeValue,
fp.UsecPerWriteOp,
fp.Name, "usec_per_write_op",
)
ch <- prometheus.MustNewConstMetric(
c.ThroughputDesc,
prometheus.GaugeValue,
fp.OthersPerSec,
fp.Name, "others_per_sec",
)
ch <- prometheus.MustNewConstMetric(
c.ThroughputDesc,
prometheus.GaugeValue,
fp.ReadsPerSec,
fp.Name, "reads_per_sec",
)
ch <- prometheus.MustNewConstMetric(
c.ThroughputDesc,
prometheus.GaugeValue,
fp.WritesPerSec,
fp.Name, "writes_per_sec",
)
ch <- prometheus.MustNewConstMetric(
c.BandwidthDesc,
prometheus.GaugeValue,
fp.ReadBytesPerSec,
fp.Name, "read_bytes_per_sec",
)
ch <- prometheus.MustNewConstMetric(
c.BandwidthDesc,
prometheus.GaugeValue,
fp.WriteBytesPerSec,
fp.Name, "write_bytes_per_sec",
)
ch <- prometheus.MustNewConstMetric(
c.AverageSizeDesc,
prometheus.GaugeValue,
fp.BytesPerOp,
fp.Name, "bytes_per_op",
)
ch <- prometheus.MustNewConstMetric(
c.AverageSizeDesc,
prometheus.GaugeValue,
fp.BytesPerRead,
fp.Name, "bytes_per_read",
)
ch <- prometheus.MustNewConstMetric(
c.AverageSizeDesc,
prometheus.GaugeValue,
fp.BytesPerWrite,
fp.Name, "bytes_per_write",
)
protocols := []string{"all", "SMB", "NFS"}
for _, proto := range protocols {
filesystemsperf := c.Client.GetFileSystemsPerformance(c.FileSystems, proto)
for _, fp := range filesystemsperf.Items {
ch <- prometheus.MustNewConstMetric(
c.LatencyDesc,
prometheus.GaugeValue,
fp.UsecPerOtherOp,
fp.Name, "usec_per_other_op", proto,
)
ch <- prometheus.MustNewConstMetric(
c.LatencyDesc,
prometheus.GaugeValue,
fp.UsecPerReadOp,
fp.Name, "usec_per_read_op", proto,
)
ch <- prometheus.MustNewConstMetric(
c.LatencyDesc,
prometheus.GaugeValue,
fp.UsecPerWriteOp,
fp.Name, "usec_per_write_op", proto,
)
ch <- prometheus.MustNewConstMetric(
c.ThroughputDesc,
prometheus.GaugeValue,
fp.OthersPerSec,
fp.Name, "others_per_sec", proto,
)
ch <- prometheus.MustNewConstMetric(
c.ThroughputDesc,
prometheus.GaugeValue,
fp.ReadsPerSec,
fp.Name, "reads_per_sec", proto,
)
ch <- prometheus.MustNewConstMetric(
c.ThroughputDesc,
prometheus.GaugeValue,
fp.WritesPerSec,
fp.Name, "writes_per_sec", proto,
)
ch <- prometheus.MustNewConstMetric(
c.BandwidthDesc,
prometheus.GaugeValue,
fp.ReadBytesPerSec,
fp.Name, "read_bytes_per_sec", proto,
)
ch <- prometheus.MustNewConstMetric(
c.BandwidthDesc,
prometheus.GaugeValue,
fp.WriteBytesPerSec,
fp.Name, "write_bytes_per_sec", proto,
)
ch <- prometheus.MustNewConstMetric(
c.AverageSizeDesc,
prometheus.GaugeValue,
fp.BytesPerOp,
fp.Name, "bytes_per_op", proto,
)
ch <- prometheus.MustNewConstMetric(
c.AverageSizeDesc,
prometheus.GaugeValue,
fp.BytesPerRead,
fp.Name, "bytes_per_read", proto,
)
ch <- prometheus.MustNewConstMetric(
c.AverageSizeDesc,
prometheus.GaugeValue,
fp.BytesPerWrite,
fp.Name, "bytes_per_write", proto,
)
}
}
}

Expand All @@ -104,25 +107,25 @@ func NewFileSystemsPerfCollector(fb *client.FBClient,
LatencyDesc: prometheus.NewDesc(
"purefb_file_systems_performance_latency_usec",
"FlashBlade file systems latency",
[]string{"name", "dimension"},
[]string{"name", "dimension", "protocol"},
prometheus.Labels{},
),
ThroughputDesc: prometheus.NewDesc(
"purefb_file_systems_performance_throughput_iops",
"FlashBlade file systems throughput",
[]string{"name", "dimension"},
[]string{"name", "dimension", "protocol"},
prometheus.Labels{},
),
BandwidthDesc: prometheus.NewDesc(
"purefb_file_systems_performance_bandwidth_bytes",
"FlashBlade file systems bandwidth",
[]string{"name", "dimension"},
[]string{"name", "dimension", "protocol"},
prometheus.Labels{},
),
AverageSizeDesc: prometheus.NewDesc(
"purefb_file_systems_performance_average_bytes",
"FlashBlade file systems average operations size",
[]string{"name", "dimension"},
[]string{"name", "dimension", "protocol"},
prometheus.Labels{},
),
Client: fb,
Expand Down
16 changes: 10 additions & 6 deletions internal/rest-client/filesystems_perf.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package client

import "strings"

type FileSystemsPerformanceList struct {
CntToken string `json:"continuation_token"`
TotalItemCnt int `json:"total_item_count"`
Expand All @@ -11,15 +13,17 @@ func (fb *FBClient) GetFileSystemsPerformance(f *FileSystemsList,
protocol string) *FileSystemsPerformanceList {
uri := "/file-systems/performance"
result := new(FileSystemsPerformanceList)
const chunkSize = 10
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea of the chunkSize on this. I know the FlashBlade API limit on number of filesystems queried at once was recently changed from 5 to 10. Can we try with 10, and then if we get back an HTTP 400 error then reduce to 5?


switch protocol {
case "all", "NFS", "SMB":
temp := new(FileSystemsPerformanceList)
for i := 0; i < len(f.Items); i += 5 {
n := ""
for j := 0; (j < 5) && (i+j < len(f.Items)); j++ {
n = n + f.Items[i+j].Name + ","
for i := 0; i < len(f.Items); i += chunkSize {
names := make([]string, 0, chunkSize)
for _, fs := range f.Items[i:min(i+chunkSize, len(f.Items))] {
names = append(names, fs.Name)
}
n = n[:len(n)-1]
n := strings.Join(names, ",")
temp := new(FileSystemsPerformanceList)
res, _ := fb.RestClient.R().
SetResult(&temp).
SetQueryParam("names", n).
Expand Down