feat(azure): Cost management view queries, query views by subscription scope#5898
Merged
disq merged 5 commits intocloudquery:mainfrom Dec 28, 2022
Merged
feat(azure): Cost management view queries, query views by subscription scope#5898disq merged 5 commits intocloudquery:mainfrom
disq merged 5 commits intocloudquery:mainfrom
Conversation
This PR has the following changes to source plugin(s) tables:
|
disq
commented
Dec 21, 2022
plugins/source/azure/resources/services/costmanagement/view_queries.go
Outdated
Show resolved
Hide resolved
disq
commented
Dec 21, 2022
| return err | ||
| } | ||
| var qd armcostmanagement.QueryDefinition | ||
| if err := json.Unmarshal(b, &qd); err != nil { |
Member
Author
There was a problem hiding this comment.
Types are not compatible (ReportConfigDefinition vs. QueryDefinition) so instead of doing a deep conversion we'll use their marshal/unmarshal methods instead. If the fields were the same type and had equal names, the structs would be compatible with each other (lesser known Go feature) but the field names are different... Luckily their json tags match.
erezrokah
approved these changes
Dec 22, 2022
Member
erezrokah
left a comment
There was a problem hiding this comment.
Code looks good, I'm assuming this is the data we want for cost analysis
acd0c20 to
c909c92
Compare
erezrokah
approved these changes
Dec 26, 2022
kodiakhq bot
pushed a commit
that referenced
this pull request
Jan 3, 2023
🤖 I have created a release *beep* *boop* --- ## [3.1.0](plugins-source-azure-v3.0.0...plugins-source-azure-v3.1.0) (2023-01-03) ### Features * Add azure security pricings resource ([#6023](#6023)) ([9648f26](9648f26)) * **azure:** Add storage_blob_services ([#6245](#6245)) ([0620ccd](0620ccd)) * **azure:** Cost management view queries, query views by subscription scope ([#5898](#5898)) ([ace315f](ace315f)) ### Bug Fixes * **deps:** Update module github.com/Azure/azure-sdk-for-go/sdk/internal to v1.1.2 ([#6205](#6205)) ([154fa6f](154fa6f)) * **deps:** Update module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/redhatopenshift/armredhatopenshift to v1.1.0 ([#6183](#6183)) ([3395c09](3395c09)) * **deps:** Update module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage to v1.2.0 ([#6184](#6184)) ([adc96f3](adc96f3)) * **deps:** Update module github.com/cloudquery/plugin-sdk to v1.14.0 ([#6025](#6025)) ([35b2cfc](35b2cfc)) * **deps:** Update module github.com/cloudquery/plugin-sdk to v1.15.0 ([#6071](#6071)) ([684b525](684b525)) * **deps:** Update module github.com/cloudquery/plugin-sdk to v1.15.1 ([#6079](#6079)) ([650659c](650659c)) * **deps:** Update module github.com/cloudquery/plugin-sdk to v1.16.0 ([#6098](#6098)) ([7bacdf3](7bacdf3)) * **deps:** Update module github.com/cloudquery/plugin-sdk to v1.16.1 ([#6214](#6214)) ([53b2415](53b2415)) * **deps:** Update module github.com/cloudquery/plugin-sdk to v1.17.0 ([#6256](#6256)) ([b19f6cd](b19f6cd)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
kodiakhq bot
pushed a commit
that referenced
this pull request
Jan 4, 2023
Missing examples. https://cloudquery-dimzb4rp1-cloudquery.vercel.app/blog/azure-cost-optimization-with-cloudquery Should be merged/released after #5898 is merged and released.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
NOTICE Let's keep this unmerged for now it as might need tweaking to make the blog post viable
azure_cost_management_viewswere coming up empty. Querying with the scope subscription we can get user's previously saved views (in Cost Analysis) and some data.Unfortunately the main resource only returns metadata about pivots and aggregations, to get the actual table data/metrics we still need to run the query. Not sure if this is the right way to do it in terms of performance.
Example "views" row:
Example "view_queries" row:
There's a ResourceGuid option which doesn't match anything we have, so we use the "Resource" field which will give us a full id of the resource (
/subscriptions/<uuid>/resourcegroups/<groupname>/providers/<provider>/<type>/<name>format) so we'll also need to include that id ("full_id" I'm calling it) inazure_resources.The query to join all of them to see cost vs. res is: