@@ -23,6 +23,13 @@ import (
2323 "sigs.k8s.io/yaml"
2424)
2525
26+ const (
27+ // avgOSDiskQueueDepthThreshold defines the threshold for average OS Disk Queue Depth metric.
28+ // If the metric average is over the threshold, an interval will be created. This can be adjusted
29+ // based on value collected in real test environment.
30+ avgOSDiskQueueDepthThreshold = 3.0
31+ )
32+
2633type azureMetricsCollector struct {
2734 adminRESTConfig * rest.Config
2835}
@@ -88,7 +95,7 @@ func fetchExtrenuousMetrics(ctx context.Context, allVMs []string, client *armmon
8895 metricsMap := map [string ]metricTest {
8996 "OS Disk Queue Depth" : {
9097 interval : "PT1M" ,
91- avgThreshold : 3.0 ,
98+ avgThreshold : avgOSDiskQueueDepthThreshold ,
9299 },
93100 }
94101
@@ -105,17 +112,17 @@ func fetchExtrenuousMetrics(ctx context.Context, allVMs []string, client *armmon
105112 Metricnamespace : nil ,
106113 })
107114 if err != nil {
108- logrus .Infof ( "error getting metrics %+v" , err )
115+ logrus .WithError ( err ). Error ( "error getting metrics" )
109116 return nil , err
110117 }
111118 for _ , value := range resp .Value {
112119 for _ , ts := range value .Timeseries {
113120 for _ , d := range ts .Data {
114121 if d .Average != nil && * d .Average > test .avgThreshold {
115- message := fmt .Sprintf ("Average value of %f for metric %s is over the threshold of %f " , * d .Average , metric , test .avgThreshold )
116- ret = append (ret , monitorapi .NewInterval (monitorapi .SourceCloudMetrics , monitorapi .Error ).
122+ message := fmt .Sprintf ("Average value of %.2f for metric %s is over the threshold of %.2f " , * d .Average , metric , test .avgThreshold )
123+ ret = append (ret , monitorapi .NewInterval (monitorapi .SourceCloudMetrics , monitorapi .Warning ).
117124 Locator (monitorapi .NewLocator ().CloudNodeMetric (machineName , metric )).
118- Message (monitorapi .NewMessage ().Reason (monitorapi .IntervalReason ( monitorapi . CloudMetricsExtrenuous ) ).HumanMessage (message )).
125+ Message (monitorapi .NewMessage ().Reason (monitorapi .CloudMetricsExtrenuous ).HumanMessage (message )).
119126 Display ().
120127 Build (d .TimeStamp .Add (- 1 * time .Minute ), * d .TimeStamp ),
121128 )
@@ -162,7 +169,7 @@ func (w *azureMetricsCollector) CollectData(ctx context.Context, storageDir stri
162169 // create azure metrics client
163170 cred , err := azidentity .NewDefaultAzureCredential (nil )
164171 if err != nil {
165- logrus .Errorf ( "Default azure credential does not exist: %+v" , err )
172+ logrus .WithError ( err ). Error ( "default azure credential does not exist" )
166173 // we do not want to fail this because of missing azure credentials
167174 return nil , nil , nil
168175 }
0 commit comments