Skip to content

Commit cd94b57

Browse files
jkroepkemblaschke
andauthored
Added data in ISO format as label (#66)
* Added data in ISO format as label * revert example.yaml --------- Co-authored-by: Markus Blaschke <[email protected]>
1 parent 8eb42ad commit cd94b57

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

metrics_azurerm_costs.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ func (m *MetricsCollectorAzureRmCosts) Setup(collector *collector.Collector) {
162162
}
163163

164164
if query.Granularity == "Daily" || query.Granularity == "Monthly" {
165-
costLabels = append(costLabels, "date")
165+
costLabels = append(costLabels, "date", "dateISO")
166166
}
167167

168168
queryGaugeVec := prometheus.NewGaugeVec(
@@ -483,21 +483,25 @@ func (m *MetricsCollectorAzureRmCosts) collectCostManagementMetrics(logger *zap.
483483

484484
if columnNumberGranularityDate != -1 {
485485
date := int64(0)
486+
dateISO := ""
486487
switch v := row[columnNumberGranularityDate].(type) {
487488
case float64:
488489
datetime, err := time.Parse("20060102", strconv.FormatFloat(v, 'g', 8, 64))
489490
if err != nil {
490491
logger.Errorf("Can't parse date %d", v)
491492
}
492493
date = datetime.Unix()
494+
dateISO = datetime.Format(time.RFC3339)
493495
case string:
494496
datetime, err := time.Parse("2006-01-02T00:00:00", v)
495497
if err != nil {
496498
logger.Errorf("Can't parse date %s", v)
497499
}
498500
date = datetime.Unix()
501+
dateISO = datetime.Format(time.RFC3339)
499502
}
500503
labels["date"] = strconv.FormatInt(date, 10)
504+
labels["dateISO"] = dateISO
501505
}
502506

503507
for _, dimensionConfig := range dimensionList {

0 commit comments

Comments
 (0)