diff --git a/internal/openmetrics-exporter/file_systems_perf_collector.go b/internal/openmetrics-exporter/file_systems_perf_collector.go index 930a25f..312ee63 100644 --- a/internal/openmetrics-exporter/file_systems_perf_collector.go +++ b/internal/openmetrics-exporter/file_systems_perf_collector.go @@ -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, + ) + } } } @@ -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, diff --git a/internal/rest-client/filesystems_perf.go b/internal/rest-client/filesystems_perf.go index cfdfd78..c21f571 100644 --- a/internal/rest-client/filesystems_perf.go +++ b/internal/rest-client/filesystems_perf.go @@ -1,5 +1,7 @@ package client +import "strings" + type FileSystemsPerformanceList struct { CntToken string `json:"continuation_token"` TotalItemCnt int `json:"total_item_count"` @@ -11,15 +13,17 @@ func (fb *FBClient) GetFileSystemsPerformance(f *FileSystemsList, protocol string) *FileSystemsPerformanceList { uri := "/file-systems/performance" result := new(FileSystemsPerformanceList) + const chunkSize = 10 + 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).