Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Application Options:
-v, --verbose verbose mode [$VERBOSE]
--log.json Switch log output to json format [$LOG_JSON]
--azure-environment= Azure environment name (default: AZUREPUBLICCLOUD) [$AZURE_ENVIRONMENT]
--azure-ad-resource-url= Specifies the AAD resource ID to use. If not set, it defaults to ResourceManagerEndpoint for operations with Azure Resource Manager [$AZURE_AD_RESOURCE]
--concurrency.subscription= Concurrent subscription fetches (default: 5) [$CONCURRENCY_SUBSCRIPTION]
--concurrency.subscription.resource= Concurrent requests per resource (inside subscription requests) (default:
10) [$CONCURRENCY_SUBSCRIPTION_RESOURCE]
Expand Down
4 changes: 2 additions & 2 deletions azure_insights.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (m *AzureInsightMetrics) MetricsClient(subscriptionId string) *insights.Met
m.clientMutex.Lock()

if _, ok := m.metricsClientCache[subscriptionId]; !ok {
client := insights.NewMetricsClient(subscriptionId)
client := insights.NewMetricsClientWithBaseURI(AzureAdResourceUrl, subscriptionId)
client.Authorizer = AzureAuthorizer
m.metricsClientCache[subscriptionId] = &client
}
Expand All @@ -49,7 +49,7 @@ func (m *AzureInsightMetrics) ResourcesClient(subscriptionId string) *resources.
m.clientMutex.Lock()

if _, ok := m.resourceClientCache[subscriptionId]; !ok {
client := resources.NewClient(subscriptionId)
client := resources.NewClientWithBaseURI(AzureAdResourceUrl, subscriptionId)
client.Authorizer = AzureAuthorizer
m.resourceClientCache[subscriptionId] = &client
}
Expand Down
3 changes: 2 additions & 1 deletion config/opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ type (

// azure
Azure struct {
Environment *string `long:"azure-environment" env:"AZURE_ENVIRONMENT" description:"Azure environment name" default:"AZUREPUBLICCLOUD"`
Environment *string `long:"azure-environment" env:"AZURE_ENVIRONMENT" description:"Azure environment name" default:"AZUREPUBLICCLOUD"`
AdResourceUrl *string `long:"azure-ad-resource-url" env:"AZURE_AD_RESOURCE" description:"Specifies the AAD resource ID to use. If not set, it defaults to ResourceManagerEndpoint for operations with Azure Resource Manager"`
}

// Prober settings
Expand Down
11 changes: 9 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ var (
argparser *flags.Parser
opts config.Opts

AzureEnvironment azure.Environment
AzureAuthorizer autorest.Authorizer
AzureEnvironment azure.Environment
AzureAuthorizer autorest.Authorizer
AzureAdResourceUrl string

prometheusCollectTime *prometheus.SummaryVec
prometheusMetricRequests *prometheus.CounterVec
Expand Down Expand Up @@ -132,6 +133,12 @@ func initAzureConnection() {
log.Panic(err)
}

if opts.Azure.AdResourceUrl == nil {
AzureAdResourceUrl = AzureEnvironment.ResourceManagerEndpoint
} else {
AzureAdResourceUrl = *opts.Azure.AdResourceUrl
}

// setup azure authorizer
AzureAuthorizer, err = auth.NewAuthorizerFromEnvironment()
if err != nil {
Expand Down