Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Azure monitor scraper #18898

Merged
merged 14 commits into from
Apr 24, 2023
Prev Previous commit
small fixes
  • Loading branch information
altuner committed Apr 21, 2023
commit a9fa1ba1305fcfc7dde858d038c0162f12914004
2 changes: 1 addition & 1 deletion receiver/azuremonitorreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func createMetricsReceiver(ctx context.Context, params receiver.CreateSettings,
}

azureScraper := newScraper(cfg, params)
scraper, err := scraperhelper.NewScraper(typeStr, azureScraper.scrape, scraperhelper.WithStart(azureScraper.start))
scraper, err := scraperhelper.NewScraper(metadata.Type, azureScraper.scrape, scraperhelper.WithStart(azureScraper.start))
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion receiver/azuremonitorreceiver/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func TestNewFactory(t *testing.T) {
desc: "creates a new factory with correct type",
testFunc: func(t *testing.T) {
factory := NewFactory()
require.EqualValues(t, typeStr, factory.Type())
require.EqualValues(t, metadata.Type, factory.Type())
},
},
{
Expand Down
22 changes: 11 additions & 11 deletions receiver/azuremonitorreceiver/scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,10 @@ func (s *azureScraper) getResourceMetricsValues(ctx context.Context, resourceID

for _, metric := range result.Value {

for _, timeserie := range metric.Timeseries {
if timeserie.Data != nil {
for _, timeserieData := range timeserie.Data {
s.processTimeserieData(resourceID, metric, timeserieData, timeserie.Metadatavalues)
for _, timeseriesElement := range metric.Timeseries {
if timeseriesElement.Data != nil {
for _, metricValue := range timeseriesElement.Data {
s.processTimeseriesData(resourceID, metric, metricValue, timeseriesElement.Metadatavalues)
}
}
}
Expand Down Expand Up @@ -352,10 +352,10 @@ func getResourceMetricsValuesRequestOptions(
return filter
}

func (s *azureScraper) processTimeserieData(
func (s *azureScraper) processTimeseriesData(
resourceID string,
metric *armmonitor.Metric,
timeserieData *armmonitor.MetricValue,
metricValue *armmonitor.MetricValue,
metadataValues []*armmonitor.MetadataValue,
) {
s.mutex.Lock()
Expand All @@ -367,11 +367,11 @@ func (s *azureScraper) processTimeserieData(
name string
value *float64
}{
{"Average", timeserieData.Average},
{"Count", timeserieData.Count},
{"Maximum", timeserieData.Maximum},
{"Minimum", timeserieData.Minimum},
{"Total", timeserieData.Total},
{"Average", metricValue.Average},
{"Count", metricValue.Count},
{"Maximum", metricValue.Maximum},
{"Minimum", metricValue.Minimum},
{"Total", metricValue.Total},
}
for _, aggregation := range aggregationsData {
if aggregation.value != nil {
Expand Down