Azure / azure-sdk-for-go

This repository is for active development of the Azure SDK for Go. For consumers of the SDK we recommend visiting our public developer docs at:
https://docs.microsoft.com/azure/developer/go/
MIT License
1.62k stars 824 forks source link

Support Application Insights querying #22355

Open JorTurFer opened 8 months ago

JorTurFer commented 8 months ago

Service Package Request

Currently, we have SDK for multiple services, but Application Insights isn't included between them. In KEDA we are consolidating the Azure SDKs to use github.com/Azure/azure-sdk-for-go SDKs, as it has a huge improvement thanks to use github.com/Azure/azure-sdk-for-go/sdk/azidentity.

During the process, I've noticed that there isn't any way to directly query application insights and the only option that we have is to continue using github.com/Azure/go-autorest/autorest and managing the token providers by our side. After a review, I've found that for directly querying we should hit api.applicationinsights.io but this SDK only supports indirect queries via api.loganalytics.io and it requires more information (like the resource group where the Insights is). Currently, github.com/Azure/go-autorest/autorest just requires the InsightsID thanks to use api.applicationinsights.io

jhendrixMSFT commented 8 months ago

Hello @JorTurFer can we get more info on what's broken in your scenario and how you're using github.com/Azure/go-autorest/autorest to resolve it?

JorTurFer commented 8 months ago

Hi @jhendrixMSFT Actually, nothing is broken with our scenario. We are successfully working with autorest (this is the implementation that we use).

The main problem is that autorest uses it's own authorizer, which is not compatible with azcore.TokenCredential, so we had had to implement the token request process. As we in KEDA support multiple Azure Services, we use several ways to request the tokens as each service SDK has it's own authentication way.

Thanks to the increase of covered services by azure-sdk-for-go, we have been able to migrate all the services from the old SDKs to the new ones based on this repo, which is nice because all of them are build with support for azidentity, allowing us to unify also that part. We also use kusto SDK (github.com/Azure/azure-kusto-go/kusto) but they have supported azidentity too, so for us it's nice.

I have thought also in asking for support in Application Insights SDK for go, but it looks like abandoned (last commit was 2 years ago).

The good point from api.applicationinsights.io API is that just a token and the resource ID are enough for querying, meanwhile for querying the same metric using the monitoring API requires several extra parameters just for the same query

jhendrixMSFT commented 8 months ago

Got it, thanks for clarifying. I don't know what our plans are for an AppInsights SDK. I've assigned this to @sandeep-sen for comments.

JorTurFer commented 7 months ago

Do you have any update @sandeep-sen ? 😄

hungran commented 3 months ago

+1 for this feature