Skip to content

Commit

Permalink
Implement getclusterfullthreshold (#7)
Browse files Browse the repository at this point in the history
* initial commit for implementing GetClusterFullThreshold
* added metrics for GetClusterFullThreshold api call
  • Loading branch information
mjavier2k authored Mar 11, 2020
1 parent fa9aebe commit 9ce2b0e
Show file tree
Hide file tree
Showing 6 changed files with 452 additions and 0 deletions.
199 changes: 199 additions & 0 deletions pkg/prom/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package prom
import (
"math"
"strconv"
"strings"
"sync"

log "github.com/amoghe/distillog"
Expand Down Expand Up @@ -31,6 +32,13 @@ func sumHistogram(m map[float64]uint64) (r uint64) {
return
}

func strCompare(str1 string, str2 string) int {
if strings.Compare(strings.ToLower(str1), strings.ToLower(str2)) == 0 {
return 1
}
return 0
}

func (c *solidfireCollector) Describe(ch chan<- *prometheus.Desc) {
ch <- MetricDescriptions.ScrapeSuccessDesc

Expand Down Expand Up @@ -135,6 +143,23 @@ func (c *solidfireCollector) Describe(ch chan<- *prometheus.Desc) {
ch <- MetricDescriptions.ClusterStatsWriteOps
ch <- MetricDescriptions.ClusterStatsWriteOpsLastSample

ch <- MetricDescriptions.ClusterThresholdBlockFullness
ch <- MetricDescriptions.ClusterThresholdFullness
ch <- MetricDescriptions.ClusterThresholdMaxMetadataOverProvisionFactor
ch <- MetricDescriptions.ClusterThresholdMetadataFullness
ch <- MetricDescriptions.ClusterThresholdSliceReserveUsedThresholdPct
ch <- MetricDescriptions.ClusterThresholdStage2AwareThreshold
ch <- MetricDescriptions.ClusterThresholdStage2BlockThresholdBytes
ch <- MetricDescriptions.ClusterThresholdStage3BlockThresholdBytes
ch <- MetricDescriptions.ClusterThresholdStage3BlockThresholdPercent
ch <- MetricDescriptions.ClusterThresholdStage3LowThreshold
ch <- MetricDescriptions.ClusterThresholdStage4BlockThresholdBytes
ch <- MetricDescriptions.ClusterThresholdStage4CriticalThreshold
ch <- MetricDescriptions.ClusterThresholdStage5BlockThresholdBytes
ch <- MetricDescriptions.ClusterThresholdSumTotalClusterBytes
ch <- MetricDescriptions.ClusterThresholdSumTotalMetadataClusterBytes
ch <- MetricDescriptions.ClusterThresholdSumUsedClusterBytes
ch <- MetricDescriptions.ClusterThresholdSumUsedMetadataClusterBytes
}

func (c *solidfireCollector) Collect(ch chan<- prometheus.Metric) {
Expand Down Expand Up @@ -946,6 +971,180 @@ func (c *solidfireCollector) Collect(ch chan<- prometheus.Metric) {
clusterStats.Result.ClusterStats.WriteOpsLastSample,
)

clusterFullThreshold, err := c.client.GetClusterFullThreshold()
if err != nil {
scrapeSuccess = 0
log.Errorln(err)
}

ch <- prometheus.MustNewConstMetric(
MetricDescriptions.ClusterThresholdBlockFullness,
prometheus.GaugeValue,
float64(strCompare(clusterFullThreshold.Result.BlockFullness, "stage1Happy")),
"stage1Happy",
)

ch <- prometheus.MustNewConstMetric(
MetricDescriptions.ClusterThresholdBlockFullness,
prometheus.GaugeValue,
float64(strCompare(clusterFullThreshold.Result.BlockFullness, "stage2Aware")),
"stage2Aware",
)

ch <- prometheus.MustNewConstMetric(
MetricDescriptions.ClusterThresholdBlockFullness,
prometheus.GaugeValue,
float64(strCompare(clusterFullThreshold.Result.BlockFullness, "stage3Low")),
"stage3Low",
)

ch <- prometheus.MustNewConstMetric(
MetricDescriptions.ClusterThresholdBlockFullness,
prometheus.GaugeValue,
float64(strCompare(clusterFullThreshold.Result.BlockFullness, "stage4Critical")),
"stage4Critical",
)

ch <- prometheus.MustNewConstMetric(
MetricDescriptions.ClusterThresholdBlockFullness,
prometheus.GaugeValue,
float64(strCompare(clusterFullThreshold.Result.BlockFullness, "stage5CompletelyConsumed")),
"stage5CompletelyConsumed",
)

ch <- prometheus.MustNewConstMetric(
MetricDescriptions.ClusterThresholdFullness,
prometheus.GaugeValue,
float64(strCompare(clusterFullThreshold.Result.Fullness, "blockFullness")),
"blockFullness",
)

ch <- prometheus.MustNewConstMetric(
MetricDescriptions.ClusterThresholdFullness,
prometheus.GaugeValue,
float64(strCompare(clusterFullThreshold.Result.Fullness, "metadataFullness")),
"metadataFullness",
)

ch <- prometheus.MustNewConstMetric(
MetricDescriptions.ClusterThresholdMaxMetadataOverProvisionFactor,
prometheus.GaugeValue,
clusterFullThreshold.Result.MaxMetadataOverProvisionFactor,
)

ch <- prometheus.MustNewConstMetric(
MetricDescriptions.ClusterThresholdMetadataFullness,
prometheus.GaugeValue,
float64(strCompare(clusterFullThreshold.Result.MetadataFullness, "stage1Happy")),
"stage1Happy",
)

ch <- prometheus.MustNewConstMetric(
MetricDescriptions.ClusterThresholdMetadataFullness,
prometheus.GaugeValue,
float64(strCompare(clusterFullThreshold.Result.MetadataFullness, "stage2Aware")),
"stage2Aware",
)

ch <- prometheus.MustNewConstMetric(
MetricDescriptions.ClusterThresholdMetadataFullness,
prometheus.GaugeValue,
float64(strCompare(clusterFullThreshold.Result.MetadataFullness, "stage3Low")),
"stage3Low",
)

ch <- prometheus.MustNewConstMetric(
MetricDescriptions.ClusterThresholdMetadataFullness,
prometheus.GaugeValue,
float64(strCompare(clusterFullThreshold.Result.MetadataFullness, "stage4Critical")),
"stage4Critical",
)

ch <- prometheus.MustNewConstMetric(
MetricDescriptions.ClusterThresholdMetadataFullness,
prometheus.GaugeValue,
float64(strCompare(clusterFullThreshold.Result.MetadataFullness, "stage5CompletelyConsumed")),
"stage5CompletelyConsumed",
)

ch <- prometheus.MustNewConstMetric(
MetricDescriptions.ClusterThresholdSliceReserveUsedThresholdPct,
prometheus.GaugeValue,
clusterFullThreshold.Result.SliceReserveUsedThresholdPct,
)

ch <- prometheus.MustNewConstMetric(
MetricDescriptions.ClusterThresholdStage2AwareThreshold,
prometheus.GaugeValue,
clusterFullThreshold.Result.Stage2AwareThreshold,
)

ch <- prometheus.MustNewConstMetric(
MetricDescriptions.ClusterThresholdStage2BlockThresholdBytes,
prometheus.GaugeValue,
clusterFullThreshold.Result.Stage2BlockThresholdBytes,
)

ch <- prometheus.MustNewConstMetric(
MetricDescriptions.ClusterThresholdStage3BlockThresholdBytes,
prometheus.GaugeValue,
clusterFullThreshold.Result.Stage3BlockThresholdBytes,
)

ch <- prometheus.MustNewConstMetric(
MetricDescriptions.ClusterThresholdStage3BlockThresholdPercent,
prometheus.GaugeValue,
clusterFullThreshold.Result.Stage3BlockThresholdPercent,
)

ch <- prometheus.MustNewConstMetric(
MetricDescriptions.ClusterThresholdStage3LowThreshold,
prometheus.GaugeValue,
clusterFullThreshold.Result.Stage3LowThreshold,
)

ch <- prometheus.MustNewConstMetric(
MetricDescriptions.ClusterThresholdStage4BlockThresholdBytes,
prometheus.GaugeValue,
clusterFullThreshold.Result.Stage4BlockThresholdBytes,
)

ch <- prometheus.MustNewConstMetric(
MetricDescriptions.ClusterThresholdStage4CriticalThreshold,
prometheus.GaugeValue,
clusterFullThreshold.Result.Stage4CriticalThreshold,
)

ch <- prometheus.MustNewConstMetric(
MetricDescriptions.ClusterThresholdStage5BlockThresholdBytes,
prometheus.GaugeValue,
clusterFullThreshold.Result.Stage5BlockThresholdBytes,
)

ch <- prometheus.MustNewConstMetric(
MetricDescriptions.ClusterThresholdSumTotalClusterBytes,
prometheus.GaugeValue,
clusterFullThreshold.Result.SumTotalClusterBytes,
)

ch <- prometheus.MustNewConstMetric(
MetricDescriptions.ClusterThresholdSumTotalMetadataClusterBytes,
prometheus.GaugeValue,
clusterFullThreshold.Result.SumTotalMetadataClusterBytes,
)

ch <- prometheus.MustNewConstMetric(
MetricDescriptions.ClusterThresholdSumUsedClusterBytes,
prometheus.GaugeValue,
clusterFullThreshold.Result.SumUsedClusterBytes,
)

ch <- prometheus.MustNewConstMetric(
MetricDescriptions.ClusterThresholdSumUsedMetadataClusterBytes,
prometheus.GaugeValue,
clusterFullThreshold.Result.SumUsedMetadataClusterBytes,
)

// Set scrape success metric to scrapeSuccess
ch <- prometheus.MustNewConstMetric(MetricDescriptions.ScrapeSuccessDesc, prometheus.GaugeValue, scrapeSuccess)
}
Expand Down
137 changes: 137 additions & 0 deletions pkg/prom/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,24 @@ type Descriptions struct {
ClusterStatsWriteLatencyUSecTotal *prometheus.Desc
ClusterStatsWriteOps *prometheus.Desc
ClusterStatsWriteOpsLastSample *prometheus.Desc

ClusterThresholdBlockFullness *prometheus.Desc
ClusterThresholdFullness *prometheus.Desc
ClusterThresholdMaxMetadataOverProvisionFactor *prometheus.Desc
ClusterThresholdMetadataFullness *prometheus.Desc
ClusterThresholdSliceReserveUsedThresholdPct *prometheus.Desc
ClusterThresholdStage2AwareThreshold *prometheus.Desc
ClusterThresholdStage2BlockThresholdBytes *prometheus.Desc
ClusterThresholdStage3BlockThresholdBytes *prometheus.Desc
ClusterThresholdStage3BlockThresholdPercent *prometheus.Desc
ClusterThresholdStage3LowThreshold *prometheus.Desc
ClusterThresholdStage4BlockThresholdBytes *prometheus.Desc
ClusterThresholdStage4CriticalThreshold *prometheus.Desc
ClusterThresholdStage5BlockThresholdBytes *prometheus.Desc
ClusterThresholdSumTotalClusterBytes *prometheus.Desc
ClusterThresholdSumTotalMetadataClusterBytes *prometheus.Desc
ClusterThresholdSumUsedClusterBytes *prometheus.Desc
ClusterThresholdSumUsedMetadataClusterBytes *prometheus.Desc
}

func NewMetricDescriptions(namespace string) *Descriptions {
Expand Down Expand Up @@ -818,5 +836,124 @@ func NewMetricDescriptions(namespace string) *Descriptions {
nil,
)

d.ClusterThresholdBlockFullness = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "cluster_threshold_block_fullness"),
"The current computed level of block fullness of the cluster.",
[]string{"level"},
nil,
)

d.ClusterThresholdFullness = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "cluster_threshold_fullness"),
"Reflects the highest level of fullness between 'blockFullness' and 'metadataFullness'.",
[]string{"level"},
nil,
)

d.ClusterThresholdMaxMetadataOverProvisionFactor = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "cluster_threshold_max_metadata_over_provision_factor"),
"A value representative of the number of times metadata space can be over provisioned relative to the amount of space available.",
nil,
nil,
)

d.ClusterThresholdMetadataFullness = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "cluster_threshold_metadata_fullness"),
"The current computed level of metadata fullness of the cluster.",
[]string{"level"},
nil,
)

d.ClusterThresholdSliceReserveUsedThresholdPct = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "cluster_threshold_slice_reserve_used_threshold_percentage"),
"Error condition. A system alert is triggered if the reserved slice utilization is greater than the sliceReserveUsedThresholdPct value returned.",
nil,
nil,
)

d.ClusterThresholdStage2AwareThreshold = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "cluster_threshold_stage2_aware_threshold"),
"Awareness condition. The value that is set for 'Stage 2' cluster threshold level.",
nil,
nil,
)

d.ClusterThresholdStage2BlockThresholdBytes = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "cluster_threshold_stage2_block_threshold_bytes"),
"Number of bytes being used by the cluster at which a stage2 condition will exist.",
nil,
nil,
)

d.ClusterThresholdStage3BlockThresholdBytes = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "cluster_threshold_stage3_block_threshold_bytes"),
"Number of bytes being used by the cluster at which a stage3 condition will exist.",
nil,
nil,
)

d.ClusterThresholdStage3BlockThresholdPercent = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "cluster_threshold_stage3_block_threshold_percentage"),
"Percent value set for stage3. At this percent full, a warning is posted in the Alerts log.",
nil,
nil,
)

d.ClusterThresholdStage3LowThreshold = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "cluster_threshold_stage3_low_threshold"),
"Error condition. The threshold at which a system alert is created due to low capacity on a cluster",
nil,
nil,
)

d.ClusterThresholdStage4BlockThresholdBytes = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "cluster_threshold_stage4_block_threshold_bytes"),
"Number of bytes being used by the cluster at which a stage4 condition will exist",
nil,
nil,
)

d.ClusterThresholdStage4CriticalThreshold = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "cluster_threshold_stage4_critical_threshold"),
"Error condition. The threshold at which a system alert is created to warn about critically low capacity on a cluster.",
nil,
nil,
)

d.ClusterThresholdStage5BlockThresholdBytes = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "cluster_threshold_stage5_block_threshold_bytes"),
"The number of bytes being used by the cluster at which a stage5 condition will exist.",
nil,
nil,
)

d.ClusterThresholdSumTotalClusterBytes = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "cluster_threshold_sum_total_cluster_bytes"),
"Physical capacity of the cluster, measured in bytes.",
nil,
nil,
)

d.ClusterThresholdSumTotalMetadataClusterBytes = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "cluster_threshold_sum_total_metadata_cluster_bytes"),
"Total amount of space that can be used to store metadata",
nil,
nil,
)

d.ClusterThresholdSumUsedClusterBytes = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "cluster_threshold_sum_used_cluster_bytes"),
"Number of bytes used on the cluster.",
nil,
nil,
)

d.ClusterThresholdSumUsedMetadataClusterBytes = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "cluster_threshold_sum_used_metadata_cluster_bytes"),
"Amount of space used on volume drives to store metadata.",
nil,
nil,
)

return &d
}
Loading

0 comments on commit 9ce2b0e

Please sign in to comment.