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

Add reservation metics and exportType for costs #87

Merged
merged 42 commits into from
Feb 24, 2024
Merged

Add reservation metics and exportType for costs #87

merged 42 commits into from
Feb 24, 2024

Conversation

PaulPowershell
Copy link
Contributor

@PaulPowershell PaulPowershell commented Jan 23, 2024

Add metrics_azurerm_reservation.go :

  • Add possibility to export azure reservation in Tenant MCA (tenant with no subscriptions but read all reservations)

metrics_azurerm_costs.go :

  • Add choice in exportType (ActualCost, AmortizedCost)

@PaulPowershell
Copy link
Contributor Author

@mblaschke
#84

@PaulPowershell PaulPowershell changed the title Add metrics_azurerm_reservation.go & update metrics_azurerm_resources.go Add metrics_azurerm_reservation.go & update metrics_azurerm_resources.go & update metrics_azurerm_costs.go Jan 23, 2024
@mblaschke
Copy link
Member

you're using the old deprecated and not maintained azure-sdk-for-go (github.com/Azure/azure-sdk-for-go/profiles/latest/compute/mgmt/compute, new one is github.com/Azure/azure-sdk-for-go/sdk/*), is there any reason for this?
we should avoid this and it doesn't support workload identity/federations.

@mblaschke mblaschke self-requested a review January 24, 2024 19:32
@PaulPowershell
Copy link
Contributor Author

you're using the old deprecated and not maintained azure-sdk-for-go (github.com/Azure/azure-sdk-for-go/profiles/latest/compute/mgmt/compute, new one is github.com/Azure/azure-sdk-for-go/sdk/*), is there any reason for this? we should avoid this and it doesn't support workload identity/federations.

i will check that, thanks for your feedback

@PaulPowershell
Copy link
Contributor Author

@mblaschke I fix go module "azure-sdk-for-go" now it's ok
febb17b

Copy link
Member

@mblaschke mblaschke left a comment

Choose a reason for hiding this comment

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

i've refactored and cleanup some code, but still have some questions.

(sorry for the delay, had some private trouble in the last weeks/months)

startDate := formattedDate
endDate := time.Now().Format("2006-01-02")

clientFactory, err := armconsumption.NewClientFactory("<subscription-id>", AzureClient.GetCred(), AzureClient.NewArmClientOptions())
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't <subscription-id> not set to the subscription id? and loop trough every subscription id in the collect function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi, thanx for your return,
It is surprising, but in fact the value should not be defined because this metrics_azurerm_reservation.go is intended to be used from an MCA tenant (which operates by billing profile rather than by subscription). Therefore, leaving "" works well. We could rename the field but not set it to nil.

@@ -105,21 +111,69 @@ func (m *MetricsCollectorAzureRmResources) collectAzureResources(subscription *a

resourceMetric := m.Collector.GetMetricList("resource")

// Get azure disk detail
Copy link
Member

Choose a reason for hiding this comment

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

i'm currently not sure if we should add disks to the resourcemanager exporter.

This might be a better solution to use the azure-resourcegraph-exporter when you can use a ResourceGraph Kusto query to get every list you want.

Otherwise i would have to add every resource to this exporter and that's the reason most of the stuff was removed from this exporter. the resourcegraph queries are more flexible than this exporter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok for this part i understand, ca we ignore this modifications on this file ?

@mblaschke mblaschke changed the title Add metrics_azurerm_reservation.go & update metrics_azurerm_resources.go & update metrics_azurerm_costs.go Add reservation metics and exportType for costs Feb 24, 2024
Copy link

Quality Gate Passed Quality Gate passed

Issues
0 New issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@mblaschke mblaschke merged commit d917999 into webdevops:main Feb 24, 2024
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants