-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[receiver/azuremonitorreceiver] feat: multi subscriptions support and automatic discovery #37167
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
Conversation
This PR was marked stale due to lack of activity. It will be closed in 14 days. |
This PR was marked stale due to lack of activity. It will be closed in 14 days. |
4decd8a
to
d4de022
Compare
ping @andrzej-stencel @jmacd ready for review/merge 🚀 |
@@ -232,6 +224,11 @@ func (mb *MetricsBuilder) AddDataPoint( | |||
dp.SetStartTimestamp(mb.startTime) | |||
dp.SetTimestamp(ts) | |||
dp.SetDoubleValue(val) | |||
|
|||
if mb.resourceAttributesSettings.AzureMonitorSubscriptionID.Enabled { | |||
dp.Attributes().PutStr("azuremonitor.subscription_id", subscriptionID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe do this at the resource level? looks like maybe that's not possible, but the resourceAttributesSettings
indicates it should be set on the resource, not the data point
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I struggled a bit with that part, as it looks like if I want to keep this way to enabled/disable subscription, with one subscription per resource, I'd have to emit several bunch of metrics per row. (call several time Emit) Is that something feasible or done by another receiver at your knowledge? I'm not sure of the consequences 🫤 -- I'm checking twice right now and this might be the purpose of EmitForResource
I will investigate in that direction.
Otherwise I can also rename this "resource" config for subscriptionID to be "datapoint" to reflect more what it is. Which is a breaking change of the config but as in alpha that's okish. I'm more concern now of the scalability. It's probably better to have one metric resource per susbscription as if you have a lot of subscriptions, it may be a lot of metrics.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok let me know when is good to review again
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@atoulme this is ready now. The subscription id is back a resource attribute. I inspired a lot from other receivers that are using resouce builder and emit for resources. Which forced me to align a bit more the internal with the other receivers that are generated. Not an easy job but now this is done.
This is too bad that the generated code for metrics through metadata generation could not offer more customization. Ideally I would like it to generate all the code for metrics exposure, without having to define statically the metrics in the metadata.yaml.
Anyway here I have something working perfectly and more aligned with recent code so satisfying 🙂
Please address conflicts and mark the PR as ready for review again. |
66bea01
to
2cfdbc7
Compare
@@ -1,9 +1,6 @@ | |||
resourceMetrics: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -1,9 +1,6 @@ | |||
resourceMetrics: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -1,9 +1,6 @@ | |||
resourceMetrics: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
05b7d55
to
560e99d
Compare
/label -waiting-for-author |
What is this ?
I have to rename to unexported ? |
yes please. |
Okay I will 👍 . Besides this, this is ready for review. |
560e99d
to
4fc3526
Compare
… automatic discovery Co-authored-by: Joshua MacDonald <[email protected]> Signed-off-by: Célian Garcia <[email protected]>
4fc3526
to
f0bf558
Compare
Nudging the build by merging latest main. |
… cleaned because we take subID instead of resID (#38893) <!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description This is a fix of regression introduced here #37167. We are using this little map to cleanup Azure resources that are not anymore discovered. In this case resources are now stored by subcriptions so ``resources`` should be changed to ``resources[subID]`` to have existing resources. <!-- Issue number (e.g. #1234) or full URL to issue, if applicable. --> #### Link to tracking issue Fixes <!--Describe what testing was performed and which tests were added.--> #### Testing <!--Describe the documentation added.--> #### Documentation <!--Please delete paragraphs that you did not use before submitting.--> Signed-off-by: Célian Garcia <[email protected]>
… automatic discovery (open-telemetry#37167) Recreated from a diffferent fork. Context: open-telemetry#36467 > <!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. > Ex. Adding a feature - Explain what this achieves.--> > #### Description > > This PR allows to discover and scrape all the subscriptions located in the tenant. > I'm adding also at the same time the ability to give multiple subscriptions as it's free and can also be desired. > > This is a part of this PR: open-telemetry#29593 that has been split for readability. > Indeed in a next PR, I'll propose the usage of the getBatch of metrics Azure API. Because if your tenant contains a lot of subscription, you can face rate limitations. > > > It contains also a little refactor of the tests and the "backdoor" used to mock the API. Now the tests are using the way provided by Azure: the fake API. https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/samples/fakes > The "backdoor" is now only the client options. So no weird interfaces nor weird constructor for the Azure clients inside the ``scraper.go`` file. > > <!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. --> > #### Link to tracking issue > Fixes open-telemetry#36612 > > <!--Describe what testing was performed and which tests were added.--> > #### Testing > > <!--Describe the documentation added.--> > #### Documentation > > <!--Please delete paragraphs that you did not use before submitting.--> Thanks to the tests refactoring, closes open-telemetry#31264 (at best it fixes it, at worst this makes it obsolete), relates also open-telemetry#38639 Signed-off-by: Célian Garcia <[email protected]> Co-authored-by: Joshua MacDonald <[email protected]> Co-authored-by: Antoine Toulme <[email protected]>
… cleaned because we take subID instead of resID (open-telemetry#38893) <!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description This is a fix of regression introduced here open-telemetry#37167. We are using this little map to cleanup Azure resources that are not anymore discovered. In this case resources are now stored by subcriptions so ``resources`` should be changed to ``resources[subID]`` to have existing resources. <!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. --> #### Link to tracking issue Fixes <!--Describe what testing was performed and which tests were added.--> #### Testing <!--Describe the documentation added.--> #### Documentation <!--Please delete paragraphs that you did not use before submitting.--> Signed-off-by: Célian Garcia <[email protected]>
Recreated from a diffferent fork. Context: #36467
Thanks to the tests refactoring, closes #31264 (at best it fixes it, at worst this makes it obsolete), relates also #38639