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

fix Azure receiver not azure china #34402

Merged
merged 10 commits into from
Aug 12, 2024
27 changes: 27 additions & 0 deletions .chloggen/mo-silent_fix-34315.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: 'bug_fix'

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: azuremonitorreceiver

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Add Azure China as a `cloud` option.

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [34315]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: [user]
2 changes: 1 addition & 1 deletion receiver/azuremonitorreceiver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ The following settings are optional:
- `maximum_number_of_metrics_in_a_call` (default = 20): Maximum number of metrics to fetch in per API call, current limit in Azure is 20 (as of 03/27/2023).
- `maximum_number_of_records_per_resource` (default = 10): Maximum number of records to fetch per resource.
- `initial_delay` (default = `1s`): defines how long this receiver waits before starting.
- `cloud` (default = `AzureCloud`): defines which Azure cloud to use. Either `AzureCloud` or `AzureUSGovernment`
- `cloud` (default = `AzureCloud`): defines which Azure cloud to use. Valid values: `AzureCloud`, `AzureUSGovernment`, `AzureChinaCloud`.

Authenticating using service principal requires following additional settings:

Expand Down
3 changes: 2 additions & 1 deletion receiver/azuremonitorreceiver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
const (
azureCloud = "AzureCloud"
azureGovernmentCloud = "AzureUSGovernment"
azureChinaCloud = "AzureChinaCloud"
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be good to add support for "AzureGermanCloud" as well, i'll open a follow up issue

)

var (
Expand Down Expand Up @@ -292,7 +293,7 @@ func (c Config) Validate() (err error) {
return fmt.Errorf("authentication %v is not supported. supported authentications include [%v,%v,%v,%v]", c.Authentication, servicePrincipal, workloadIdentity, managedIdentity, defaultCredentials)
}

if c.Cloud != azureCloud && c.Cloud != azureGovernmentCloud {
if c.Cloud != azureCloud && c.Cloud != azureGovernmentCloud && c.Cloud != azureChinaCloud {
err = multierr.Append(err, errInvalidCloud)
}

Expand Down
2 changes: 2 additions & 0 deletions receiver/azuremonitorreceiver/scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ func (s *azureScraper) getArmClientOptions() *arm.ClientOptions {
switch s.cfg.Cloud {
case azureGovernmentCloud:
cloudToUse = cloud.AzureGovernment
case azureChinaCloud:
cloudToUse = cloud.AzureChina
default:
cloudToUse = cloud.AzurePublic
}
Expand Down