From d6904ba9b412254fd82106f3bd0b6ad754f61107 Mon Sep 17 00:00:00 2001 From: Daniel Lee Date: Mon, 11 Feb 2019 01:22:15 +0100 Subject: [PATCH] azuremonitor: small refactoring --- pkg/tsdb/azuremonitor/azuremonitor-datasource.go | 11 +++++++++++ pkg/tsdb/azuremonitor/legend-key.go | 11 ----------- 2 files changed, 11 insertions(+), 11 deletions(-) delete mode 100644 pkg/tsdb/azuremonitor/legend-key.go diff --git a/pkg/tsdb/azuremonitor/azuremonitor-datasource.go b/pkg/tsdb/azuremonitor/azuremonitor-datasource.go index 3405c3bbd1f..079910e1b66 100644 --- a/pkg/tsdb/azuremonitor/azuremonitor-datasource.go +++ b/pkg/tsdb/azuremonitor/azuremonitor-datasource.go @@ -285,6 +285,9 @@ func (e *AzureMonitorDatasource) parseResponse(queryRes *tsdb.QueryResult, data return nil } +// findClosestAllowedIntervalMs is used for the auto time grain setting. +// It finds the closest time grain from the list of allowed time grains for Azure Monitor +// using the Grafana interval in milliseconds func (e *AzureMonitorDatasource) findClosestAllowedIntervalMs(intervalMs int64) int64 { closest := allowedIntervalsMS[0] @@ -299,3 +302,11 @@ func (e *AzureMonitorDatasource) findClosestAllowedIntervalMs(intervalMs int64) } return closest } + +// formatLegendKey builds the legend key or timeseries name +func formatLegendKey(resourceName string, metricName string, metadataName string, metadataValue string) string { + if len(metadataName) > 0 { + return fmt.Sprintf("%s{%s=%s}.%s", resourceName, metadataName, metadataValue, metricName) + } + return fmt.Sprintf("%s.%s", resourceName, metricName) +} diff --git a/pkg/tsdb/azuremonitor/legend-key.go b/pkg/tsdb/azuremonitor/legend-key.go deleted file mode 100644 index 7d5cdbbcdd3..00000000000 --- a/pkg/tsdb/azuremonitor/legend-key.go +++ /dev/null @@ -1,11 +0,0 @@ -package azuremonitor - -import "fmt" - -// formatLegendKey builds the legend key or timeseries name -func formatLegendKey(resourceName string, metricName string, metadataName string, metadataValue string) string { - if len(metadataName) > 0 { - return fmt.Sprintf("%s{%s=%s}.%s", resourceName, metadataName, metadataValue, metricName) - } - return fmt.Sprintf("%s.%s", resourceName, metricName) -}