Skip to content

Commit

Permalink
Update azure error messages when no resources are found (elastic#14327)
Browse files Browse the repository at this point in the history
* Limit error messages to log only

* Changelog update

* Update comments
  • Loading branch information
narph authored Oct 30, 2019
1 parent c148759 commit 36da195
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Change kubernetes.event.message to text. {pull}13964[13964]
- Fix performance counter values for windows/perfmon metricset. {issue}14036[14036] {pull}14039[14039]
- Add FailOnRequired when applying schema and fix metric names in mongodb metrics metricset. {pull}14143[14143]
- Limit some of the error messages to the logs only {issue}14317[14317] {pull}14327[14327]
- Convert indexed ms-since-epoch timestamp fields in `elasticsearch/ml_job` metricset to ints from float64s. {issue}14220[14220] {pull}14222[14222]
- Fix ARN parsing function to work for ELB ARNs. {pull}14316[14316]

Expand Down
4 changes: 4 additions & 0 deletions x-pack/metricbeat/module/azure/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ func (m *MetricSet) Fetch(report mb.ReporterV2) error {
if err != nil {
return err
}
if len(m.Client.Resources.Metrics) == 0 {
// error message is previously logged in the InitResources, no error event should be created
return nil
}
// retrieve metrics
err = m.Client.GetMetricValues(report)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions x-pack/metricbeat/module/azure/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (client *Client) InitResources(fn mapMetric, report mb.ReporterV2) error {
if len(resourceList.Values()) == 0 {
err = errors.Errorf("failed to retrieve resources: No resources returned using the configuration options resource ID %s, resource group %s, resource type %s, resource query %s",
resource.ID, resource.Group, resource.Type, resource.Query)
client.LogError(report, err)
client.Log.Error(err)
continue
}
for _, res := range resourceList.Values() {
Expand All @@ -78,10 +78,10 @@ func (client *Client) InitResources(fn mapMetric, report mb.ReporterV2) error {
}
}
}
// users could add or remove resources while metricbeat is running so we could encounter the situation where resources are unavailable, we log and create an event if this is the case (see above)
// but we return an error when absolutely no resources are found
// users could add or remove resources while metricbeat is running so we could encounter the situation where resources are unavailable we log an error message (see above)
// we also log a debug message when absolutely no resources are found
if len(metrics) == 0 {
return errors.New("no resources were found based on all the configurations options entered")
client.Log.Debug("no resources were found based on all the configurations options entered")
}
client.Resources.Metrics = metrics
return nil
Expand Down

0 comments on commit 36da195

Please sign in to comment.