Skip to content

[8.17](backport #41790) Concurrent fetch of azure metricdefinitions and batchApi usage#44241

Merged
zmoog merged 6 commits into8.17from
mergify/bp/8.17/pr-41790
May 19, 2025
Merged

[8.17](backport #41790) Concurrent fetch of azure metricdefinitions and batchApi usage#44241
zmoog merged 6 commits into8.17from
mergify/bp/8.17/pr-41790

Conversation

@mergify
Copy link
Contributor

@mergify mergify bot commented May 7, 2025

The changes affect azure monitor and relevant metricsets. The list of metricsets affected are:

  • monitor
  • container_registry
  • container_instance
  • container_service
  • compute_vm
  • compute_vm_scaleset
  • database_account
  • storage_account

A new configuration parameter is introduced enable_batch_api of type boolean.
If set to false(default) nothing changes in the way the metrics are collected for these metricsets.

If set to true:

  • The metric definitions of resources are collected asynchronously and write the results in a channel.
  • The channel is read and when the number of definitions collected reach 50 (batch API limit)
  • The metrics definitions are grouped based on criteria(1) and the azure BatchAPI is used to retrieve
    metrics of multiple resources with one api call.
  1. Grouping criteria are
  • Namespace
  • SubscriptionID
  • Location
  • Names
  • TimeGrain
  • Dimensions

Proposed commit message

  • WHAT: Introduce enable_batch_api parameter for concurrent fetching of azure metric definitions and metric values collection using Batch Api
  • WHY: Helps mitigating scalability problems

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

Disruptive User Impact

Author's Checklist

  • [ ]

How to test this PR locally

Related issues

Use cases

Screenshots

Logs


This is an automatic backport of pull request #41790 done by [Mergify](https://mergify.com).
@mergify mergify bot requested review from a team as code owners May 7, 2025 10:47
@mergify mergify bot added backport conflicts There is a conflict in the backported pull request labels May 7, 2025
@mergify
Copy link
Contributor Author

mergify bot commented May 7, 2025

Cherry-pick of 13f8fde has failed:

On branch mergify/bp/8.17/pr-41790
Your branch is up to date with 'origin/8.17'.

You are currently cherry-picking commit 13f8fde9a.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   CHANGELOG.next.asciidoc
	modified:   NOTICE.txt
	new file:   x-pack/metricbeat/module/azure/README.md
	modified:   x-pack/metricbeat/module/azure/_meta/docs.asciidoc
	modified:   x-pack/metricbeat/module/azure/azure.go
	modified:   x-pack/metricbeat/module/azure/client.go
	new file:   x-pack/metricbeat/module/azure/client_batch.go
	new file:   x-pack/metricbeat/module/azure/client_batch_test.go
	modified:   x-pack/metricbeat/module/azure/client_utils.go
	modified:   x-pack/metricbeat/module/azure/config.go
	modified:   x-pack/metricbeat/module/azure/data.go
	modified:   x-pack/metricbeat/module/azure/mock_service.go
	new file:   x-pack/metricbeat/module/azure/monitor/client_helper_concurrent.go
	new file:   x-pack/metricbeat/module/azure/monitor/client_helper_concurrent_test.go
	modified:   x-pack/metricbeat/module/azure/monitor/monitor.go
	modified:   x-pack/metricbeat/module/azure/monitor_service.go
	modified:   x-pack/metricbeat/module/azure/resources.go
	modified:   x-pack/metricbeat/module/azure/service_interface.go
	new file:   x-pack/metricbeat/module/azure/storage/client_helper_concurrent.go
	new file:   x-pack/metricbeat/module/azure/storage/client_helper_concurrent_test.go
	modified:   x-pack/metricbeat/module/azure/storage/storage.go

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   go.mod
	both modified:   go.sum
	both added:      metricbeat/docs/modules/azure.asciidoc

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label May 7, 2025
@zmoog zmoog self-assigned this May 9, 2025
@zmoog zmoog added the Team:obs-ds-hosted-services Label for the Observability Hosted Services team label May 9, 2025
@elasticmachine
Copy link
Contributor

Pinging @elastic/obs-ds-hosted-services (Team:obs-ds-hosted-services)

@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label May 9, 2025
@zmoog zmoog added needs_team Indicates that the issue/PR needs a Team:* label input:azure-monitor labels May 9, 2025
@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label May 9, 2025
@zmoog zmoog force-pushed the mergify/bp/8.17/pr-41790 branch from c8dcf80 to ce1c0f5 Compare May 9, 2025 13:20
@zmoog zmoog requested a review from a team as a code owner May 9, 2025 14:07
@zmoog zmoog marked this pull request as draft May 9, 2025 14:07
@mergify
Copy link
Contributor Author

mergify bot commented May 12, 2025

This pull request has not been merged yet. Could you please review and merge it @zmoog, @MichaelKatsoulis? 🙏

@zmoog zmoog force-pushed the mergify/bp/8.17/pr-41790 branch from 21721ce to c285ee7 Compare May 15, 2025 14:05
@zmoog zmoog marked this pull request as ready for review May 15, 2025 14:05
@zmoog
Copy link
Contributor

zmoog commented May 15, 2025

/test

@zmoog zmoog force-pushed the mergify/bp/8.17/pr-41790 branch 2 times, most recently from a9a9b45 to 777a8ef Compare May 16, 2025 13:35
@zmoog
Copy link
Contributor

zmoog commented May 16, 2025

/test

@mergify
Copy link
Contributor Author

mergify bot commented May 17, 2025

This pull request is now in conflicts. Could you fix it? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

git fetch upstream
git checkout -b mergify/bp/8.17/pr-41790 upstream/mergify/bp/8.17/pr-41790
git merge upstream/8.17
git push upstream mergify/bp/8.17/pr-41790
@mergify
Copy link
Contributor Author

mergify bot commented May 19, 2025

This pull request has not been merged yet. Could you please review and merge it @zmoog, @MichaelKatsoulis? 🙏

MichaelKatsoulis and others added 4 commits May 19, 2025 09:48
* Use concurrency in metricsdefinition collection

* Change ResourceConfigurations.Metrics to a map

* Use batch API

* New queryResourceClient per location

* Wait for 50 reource ids before fetching the metrics

* Set timegrain if is equal to ''"

* Use batch API as feature

* Use baseclient to tackle code duplication

* Add unit tests for concurrent fetching of metric definitions

* Add batch client unit tests

* Add support of batch API for storage accounts

* Update docs and add unit tests form storage client

* Split metric names by 20

(cherry picked from commit 13f8fde)

# Conflicts:
#	go.mod
#	go.sum
#	metricbeat/docs/modules/azure.asciidoc
@zmoog zmoog force-pushed the mergify/bp/8.17/pr-41790 branch from 777a8ef to 1610871 Compare May 19, 2025 07:53
@zmoog zmoog merged commit 62bdae5 into 8.17 May 19, 2025
170 checks passed
@zmoog zmoog deleted the mergify/bp/8.17/pr-41790 branch May 19, 2025 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport conflicts There is a conflict in the backported pull request input:azure-monitor Team:obs-ds-hosted-services Label for the Observability Hosted Services team

3 participants