-
Notifications
You must be signed in to change notification settings - Fork 29
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
Support for multi-resource queries #44
Comments
Do you have any information when this will be GA? Would be good if they include it in azure-sdk-for-go 👍 |
@mblaschke it is GA. The API is availible as stable in 2021-05-01. Azure/azure-sdk-for-go#20039 is open already, because I would like to know why a stable API is not present in the SDK. The Browser Portal is already using this API... |
That would also speed up metric collection, so it would make sense to implement it and not sure if I want to wait until the sdk implements it. |
I found it here: https://github.com/Azure/azure-sdk-for-go/blob/v68.0.0/services/preview/monitor/mgmt/2021-05-01-preview/metrics/metrics.go#L166-L195 but it seems like thats the "older" SDK. I also tried this by using existing APIs, but I'm not able to set the region parameter: package main
import (
"context"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/arm"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/policy"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/monitor/armmonitor"
"log"
)
func main() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
client, err := armmonitor.NewMetricsClient(cred, &arm.ClientOptions{ClientOptions: policy.ClientOptions{
APIVersion: "2021-05-01",
}})
res, err := client.List(ctx, "subscriptions/e1608e24-0728-4efd-ba5b-a05693b53c5a", &armmonitor.MetricsClientListOptions{
Timespan: to.Ptr("PT1M"),
Interval: to.Ptr("PT1M"),
Metricnames: to.Ptr("Available Memory Bytes"),
Aggregation: to.Ptr("average"),
Top: to.Ptr(int32(10)),
Orderby: nil,
Filter: to.Ptr("Microsoft.ResourceId eq '/subscriptions/e1608e24-0728-4efd-ba5b-a05693b53c5a/resourceGroups/default/providers/Microsoft.Compute/virtualMachines/bastion-win' or Microsoft.ResourceId eq '/subscriptions/e1608e24-0728-4efd-ba5b-a05693b53c5a/resourceGroups/default/providers/Microsoft.Compute/virtualMachines/bastion-linux'"),
ResultType: nil,
Metricnamespace: to.Ptr("microsoft.compute/virtualmachines"),
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// TODO: use response item
_ = res
} |
I'm currently waiting for the azidentity to go final for workload identity, so maybe wait until we get feedback from the azure sdk team. |
@mblaschke is upcoming azure-sdk/azure-sdk-for-go@8894250 |
The armmonitor v0.9.0 package will include the calls for the APIs Azure/azure-sdk-for-go#20039 (comment) The armmonitor also depends against azcore 1.4.0 |
seems that something in azure-sdk-for-go is broken: I'm unable to pass multiple metricnames in armmonitor v0.9.0 |
👋 @mblaschke I see this issue was closed by implementing a means to list all metrics for a subscription. I would like to leverage multi-resource queries in other code paths as well. Happy to open a new issue to track it if you want to separate it and I'm happy to help with implementation. |
@kgeckhart |
@mblaschke thanks for the quick response! If I am reading the code for the new endpoint correctly it's going to pull the data for all resources in the subscription based on the query params. The thought I had was to re-factor the existing code paths which currently execute per target to instead batch targets and query for their metrics using an explicit ResourceId filter instead of the current |
Because of the different api i was choosing another endpoint because it works in a different style. So for example you will get the sum of requests of AppGateways in the subscription and not per AppGateway. That also means you can only split metrics by two additional filters where resource based metrics can have three filters because the query is sent to the resource instead of the subscription. |
Thanks for the explanation @mblaschke! I always forget about the awkward behavior of the aws metrics APIs where the |
Hi,
Azure Monitor is offers multi-resource queries (preview).
https://azure.microsoft.com/en-us/updates/select-multiple-resources-in-azure-monitor-log-analytics/
My hope is to reduce the amount of calls to prevent rate-limit issues.
On Browser leve following request was used to gain multiple metrics:
I was trying to replicate it, but I had no success
Aside from that, there where no support for service discovery
See. also: https://learn.microsoft.com/en-us/azure/azure-monitor/essentials/metrics-dynamic-scope
Edit: It seems like its not availible in SDk, yet Azure/azure-sdk-for-go#20039
The text was updated successfully, but these errors were encountered: