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] [Billing] Add Azure resource tags from Usage Details API #36428

Merged
merged 5 commits into from Aug 30, 2023

Conversation

zmoog
Copy link
Contributor

@zmoog zmoog commented Aug 28, 2023

Proposed commit message

With this change, we are adding support for Azure resource tags from the response from the Usage Details API. Both legacy and modern usage details data formats include tags from resources.

We take tag values from the usage details response and store them in the event as azure.resource.tags field. We can leverage the existing module level mapping for these field.

Multiple users asked for including resource tags to make the most of usage details data.

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.

Author's Checklist

  • Fetch data from an Enterprise Agreement (EA) account
  • Fetch data from an Microsoft Customer Agreement (MCA) account

How to test this PR locally

Related issues

Use cases

Screenshots

CleanShot 2023-08-28 at 11 50 31@2x

Logs

@zmoog zmoog self-assigned this Aug 28, 2023
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Aug 28, 2023
@mergify
Copy link
Contributor

mergify bot commented Aug 28, 2023

This pull request does not have a backport label.
If this is a bug or security fix, could you label this PR @zmoog? 🙏.
For such, you'll need to label your PR with:

  • The upcoming major version of the Elastic Stack
  • The upcoming minor version of the Elastic Stack (if you're not pushing a breaking change)

To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-v8./d.0 is the label to automatically backport to the 8./d branch. /d is the digit

@zmoog zmoog added the Team:Cloud-Monitoring Label for the Cloud Monitoring team label Aug 28, 2023
@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Aug 28, 2023
@zmoog
Copy link
Contributor Author

zmoog commented Aug 28, 2023

I added a simple mapping of tag values from legacy (EA) and modern (MCA) billing account types.

I added a few tags to Azure resources, but I am not getting those tags from Usage Details API; I would like to know if this kind of data needs some time to propagate across Azure systems.

I am waiting some time before trying again.

@elasticmachine
Copy link
Collaborator

elasticmachine commented Aug 28, 2023

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2023-08-30T06:10:18.768+0000

  • Duration: 51 min 7 sec

Test stats 🧪

Test Results
Failed 0
Passed 1478
Skipped 96
Total 1574

💚 Flaky test report

Tests succeeded.

🤖 GitHub comments

Expand to view the GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

  • /package : Generate the packages and run the E2E tests.

  • /beats-tester : Run the installation tests with beats-tester.

  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@zmoog zmoog force-pushed the zmoog/azure-billing-add-tags branch from 149fc56 to f066926 Compare August 28, 2023 10:10
@zmoog zmoog changed the title [Azure] [Billing] Add resource tags from Usage Details API [Azure] [Billing] Add Azure resource tags from Usage Details API Aug 28, 2023
@zmoog zmoog added backport-v8.9.0 Automated backport with mergify backport-v8.10.0 Automated backport with mergify labels Aug 28, 2023
@zmoog zmoog marked this pull request as ready for review August 28, 2023 15:26
@zmoog zmoog requested a review from a team as a code owner August 28, 2023 15:26
@zmoog zmoog requested review from a team August 28, 2023 15:26
@zmoog zmoog force-pushed the zmoog/azure-billing-add-tags branch from cde009c to 7445190 Compare August 28, 2023 22:36
Both legacy and modern data formats support resource tags.
The Azure module already has an existing mapping for the
`azure.resource.tags` field.
@zmoog zmoog force-pushed the zmoog/azure-billing-add-tags branch from 7445190 to 2f5365a Compare August 29, 2023 15:47
@muthu-mps
Copy link
Contributor

I have tried enabling the billing module with this PR and the tags are added to the resources fields in the metrics. The change looks good!

Screenshot 2023-08-30 at 11 38 15 AM

Copy link
Contributor

@devamanv devamanv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good!

@zmoog zmoog removed backport-v8.9.0 Automated backport with mergify backport-v8.10.0 Automated backport with mergify labels Aug 30, 2023
@mergify
Copy link
Contributor

mergify bot commented Aug 30, 2023

This pull request does not have a backport label.
If this is a bug or security fix, could you label this PR @zmoog? 🙏.
For such, you'll need to label your PR with:

  • The upcoming major version of the Elastic Stack
  • The upcoming minor version of the Elastic Stack (if you're not pushing a breaking change)

To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-v8./d.0 is the label to automatically backport to the 8./d branch. /d is the digit

@zmoog
Copy link
Contributor Author

zmoog commented Aug 30, 2023

Removed the backport labels: I prefer to merge now and take some time and think about if and which version backport to.

@zmoog zmoog merged commit 55edac5 into elastic:main Aug 30, 2023
21 checks passed
@zmoog zmoog deleted the zmoog/azure-billing-add-tags branch August 30, 2023 09:09
@zmoog zmoog added the backport-v8.9.0 Automated backport with mergify label Aug 30, 2023
mergify bot pushed a commit that referenced this pull request Aug 30, 2023
)

* Add resource tags from Usage Details API

Both legacy and modern data formats support resource tags.

* Store tags in the azure.resource.tags field

The Azure module already has an existing mapping for the
`azure.resource.tags` field.

* Add a unit test to check the tags field mapping

* Update changelog

---------

Co-authored-by: muthu-mps <101238137+muthu-mps@users.noreply.github.com>
(cherry picked from commit 55edac5)
@zmoog zmoog added backport-v8.10.0 Automated backport with mergify bug labels Aug 30, 2023
mergify bot pushed a commit that referenced this pull request Aug 30, 2023
)

* Add resource tags from Usage Details API

Both legacy and modern data formats support resource tags.

* Store tags in the azure.resource.tags field

The Azure module already has an existing mapping for the
`azure.resource.tags` field.

* Add a unit test to check the tags field mapping

* Update changelog

---------

Co-authored-by: muthu-mps <101238137+muthu-mps@users.noreply.github.com>
(cherry picked from commit 55edac5)
@zmoog
Copy link
Contributor Author

zmoog commented Aug 30, 2023

Since the Azure module already includes mapping for azure.resource.tags, the lack of tag values can be considered a bug. So, I am backporting the fix to 8.9 and 8.10.

zmoog added a commit that referenced this pull request Aug 30, 2023
… Usage Details API (#36463)

* [Azure] [Billing] Add Azure resource tags from Usage Details API (#36428)

* Add resource tags from Usage Details API

Both legacy and modern data formats support resource tags.

* Store tags in the azure.resource.tags field

The Azure module already has an existing mapping for the
`azure.resource.tags` field.

* Add a unit test to check the tags field mapping

* Update changelog

---------

Co-authored-by: muthu-mps <101238137+muthu-mps@users.noreply.github.com>
(cherry picked from commit 55edac5)

* Remove extra changelog comments

---------

Co-authored-by: Maurizio Branca <maurizio.branca@elastic.co>
zmoog added a commit that referenced this pull request Sep 1, 2023
) (#36464)

* Add resource tags from Usage Details API

Both legacy and modern data formats support resource tags.

* Store tags in the azure.resource.tags field

The Azure module already has an existing mapping for the
`azure.resource.tags` field.

* Add a unit test to check the tags field mapping

* Update changelog

---------

Co-authored-by: muthu-mps <101238137+muthu-mps@users.noreply.github.com>
(cherry picked from commit 55edac5)

Co-authored-by: Maurizio Branca <maurizio.branca@elastic.co>
Scholar-Li pushed a commit to Scholar-Li/beats that referenced this pull request Feb 5, 2024
…stic#36428)

* Add resource tags from Usage Details API

Both legacy and modern data formats support resource tags.

* Store tags in the azure.resource.tags field

The Azure module already has an existing mapping for the
`azure.resource.tags` field.

* Add a unit test to check the tags field mapping

* Update changelog

---------

Co-authored-by: muthu-mps <101238137+muthu-mps@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-v8.9.0 Automated backport with mergify backport-v8.10.0 Automated backport with mergify bug Team:Cloud-Monitoring Label for the Cloud Monitoring team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Azure - Billing Metrics] - Fails to ingest tags resource field
6 participants