Skip to content

Commit 18377a0

Browse files
[receiver/azuremonitorreceiver] Renamed the auth field to credentials (#39738)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description Doing this breaking change to prepare usage of azure auth extension and be able to set the auth config like it's usually done for the different authentication by extensions ```yaml auth: authenticator: 'azureauth/prd' ``` <!-- Issue number (e.g. #1234) or full URL to issue, if applicable. --> #### Link to tracking issue Unblocks #39658 <!--Describe what testing was performed and which tests were added.--> #### Testing <!--Describe the documentation added.--> #### Documentation <!--Please delete paragraphs that you did not use before submitting.--> Signed-off-by: Célian Garcia <[email protected]>
1 parent b265322 commit 18377a0

File tree

8 files changed

+44
-17
lines changed

8 files changed

+44
-17
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: 'breaking'
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: 'azuremonitorreceiver'
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: "Renamed the `auth` field to `credentials` in the azuremonitorreceiver configuration."
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [39738]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: [user]

receiver/azuremonitorreceiver/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ The following settings are required:
2323

2424
The following settings are optional:
2525

26-
- `auth` (default = service_principal): Specifies the used authentication method. Supported values are `service_principal`, `workload_identity`, `managed_identity`, `default_credentials`.
26+
- `credentials` (default = service_principal): Specifies the used authentication method. Supported values are `service_principal`, `workload_identity`, `managed_identity`, `default_credentials`.
2727
- `resource_groups` (default = none): Filter metrics for specific resource groups, not setting a value will scrape metrics for all resources in the subscription.
2828
- `services` (default = none): Filter metrics for specific services, not setting a value will scrape metrics for all services integrated with Azure Monitor.
2929
- `metrics` (default = none): Filter metrics by name and aggregations. Not setting a value will scrape all metrics and their aggregations.
@@ -122,7 +122,7 @@ Using [Azure Workload Identity](https://learn.microsoft.com/en-us/azure/develope
122122
receivers:
123123
azuremonitor:
124124
subscription_ids: ["${subscription_id}"]
125-
auth: "workload_identity"
125+
credentials: "workload_identity"
126126
tenant_id: "${env:AZURE_TENANT_ID}"
127127
client_id: "${env:AZURE_CLIENT_ID}"
128128
federated_token_file: "${env:AZURE_FEDERATED_TOKEN_FILE}"
@@ -134,7 +134,7 @@ Using [Managed Identity](https://learn.microsoft.com/en-us/azure/developer/go/az
134134
receivers:
135135
azuremonitor:
136136
subscription_ids: ["${subscription_id}"]
137-
auth: "managed_identity"
137+
credentials: "managed_identity"
138138
client_id: "${env:AZURE_CLIENT_ID}"
139139
```
140140
@@ -144,7 +144,7 @@ Using [Environment Variables](https://learn.microsoft.com/en-us/azure/developer/
144144
receivers:
145145
azuremonitor:
146146
subscription_ids: ["${subscription_id}"]
147-
auth: "default_credentials"
147+
credentials: "default_credentials"
148148
```
149149
150150
Overriding dimensions for a particular metric:

receiver/azuremonitorreceiver/config.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ type Config struct {
242242
Cloud string `mapstructure:"cloud"`
243243
SubscriptionIDs []string `mapstructure:"subscription_ids"`
244244
DiscoverSubscriptions bool `mapstructure:"discover_subscriptions"`
245-
Authentication string `mapstructure:"auth"`
245+
Credentials string `mapstructure:"credentials"`
246246
TenantID string `mapstructure:"tenant_id"`
247247
ClientID string `mapstructure:"client_id"`
248248
ClientSecret string `mapstructure:"client_secret"`
@@ -272,7 +272,7 @@ func (c Config) Validate() (err error) {
272272
err = multierr.Append(err, errMissingSubscriptionIDs)
273273
}
274274

275-
switch c.Authentication {
275+
switch c.Credentials {
276276
case servicePrincipal:
277277
if c.TenantID == "" {
278278
err = multierr.Append(err, errMissingTenantID)
@@ -301,7 +301,7 @@ func (c Config) Validate() (err error) {
301301
case managedIdentity:
302302
case defaultCredentials:
303303
default:
304-
return fmt.Errorf("authentication %v is not supported. supported authentications include [%v,%v,%v,%v]", c.Authentication, servicePrincipal, workloadIdentity, managedIdentity, defaultCredentials)
304+
return fmt.Errorf("credentials %v is not supported. supported authentications include [%v,%v,%v,%v]", c.Credentials, servicePrincipal, workloadIdentity, managedIdentity, defaultCredentials)
305305
}
306306

307307
if c.Cloud != azureCloud && c.Cloud != azureGovernmentCloud && c.Cloud != azureChinaCloud {

receiver/azuremonitorreceiver/factory.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func createDefaultConfig() component.Config {
4545
MaximumNumberOfMetricsInACall: 20,
4646
MaximumNumberOfRecordsPerResource: 10,
4747
Services: monitorServices,
48-
Authentication: servicePrincipal,
48+
Credentials: servicePrincipal,
4949
Cloud: defaultCloud,
5050
}
5151
}

receiver/azuremonitorreceiver/factory_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func TestNewFactory(t *testing.T) {
4545
CacheResourcesDefinitions: 24 * 60 * 60,
4646
MaximumNumberOfMetricsInACall: 20,
4747
MaximumNumberOfRecordsPerResource: 10,
48-
Authentication: servicePrincipal,
48+
Credentials: servicePrincipal,
4949
Cloud: defaultCloud,
5050
}
5151

receiver/azuremonitorreceiver/scraper.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ func (s *azureScraper) unloadSubscription(id string) {
159159
}
160160

161161
func (s *azureScraper) loadCredentials() (err error) {
162-
switch s.cfg.Authentication {
162+
switch s.cfg.Credentials {
163163
case defaultCredentials:
164164
if s.cred, err = s.azDefaultCredentialsFunc(nil); err != nil {
165165
return err
@@ -183,7 +183,7 @@ func (s *azureScraper) loadCredentials() (err error) {
183183
return err
184184
}
185185
default:
186-
return fmt.Errorf("unknown authentication %v", s.cfg.Authentication)
186+
return fmt.Errorf("unknown credentials %v", s.cfg.Credentials)
187187
}
188188
return nil
189189
}

receiver/azuremonitorreceiver/scraper_batch.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func (s *azureBatchScraper) unloadSubscription(id string) {
112112

113113
// TODO: duplicate
114114
func (s *azureBatchScraper) loadCredentials() (err error) {
115-
switch s.cfg.Authentication {
115+
switch s.cfg.Credentials {
116116
case defaultCredentials:
117117
if s.cred, err = s.azDefaultCredentialsFunc(nil); err != nil {
118118
return err
@@ -136,7 +136,7 @@ func (s *azureBatchScraper) loadCredentials() (err error) {
136136
return err
137137
}
138138
default:
139-
return fmt.Errorf("unknown authentication %v", s.cfg.Authentication)
139+
return fmt.Errorf("unknown credentials %v", s.cfg.Credentials)
140140
}
141141
return nil
142142
}

receiver/azuremonitorreceiver/scraper_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func TestAzureScraperStart(t *testing.T) {
9090
name: "service_principal",
9191
testFunc: func(t *testing.T) {
9292
cfg := createDefaultTestConfig()
93-
cfg.Authentication = servicePrincipal
93+
cfg.Credentials = servicePrincipal
9494
s := &azureScraper{
9595
cfg: cfg,
9696
time: timeMock,
@@ -109,7 +109,7 @@ func TestAzureScraperStart(t *testing.T) {
109109
name: "workload_identity",
110110
testFunc: func(t *testing.T) {
111111
cfg := createDefaultTestConfig()
112-
cfg.Authentication = workloadIdentity
112+
cfg.Credentials = workloadIdentity
113113
s := &azureScraper{
114114
cfg: cfg,
115115
time: timeMock,
@@ -128,7 +128,7 @@ func TestAzureScraperStart(t *testing.T) {
128128
name: "managed_identity",
129129
testFunc: func(t *testing.T) {
130130
cfg := createDefaultTestConfig()
131-
cfg.Authentication = managedIdentity
131+
cfg.Credentials = managedIdentity
132132
s := &azureScraper{
133133
cfg: cfg,
134134
time: timeMock,
@@ -147,7 +147,7 @@ func TestAzureScraperStart(t *testing.T) {
147147
name: "default_credentials",
148148
testFunc: func(t *testing.T) {
149149
cfg := createDefaultTestConfig()
150-
cfg.Authentication = defaultCredentials
150+
cfg.Credentials = defaultCredentials
151151
s := &azureScraper{
152152
cfg: cfg,
153153
time: timeMock,

0 commit comments

Comments
 (0)