Skip to content

Commit 9d5d99d

Browse files
committed
SUMO-245309 Add the doc for the new resource sumologic_azure_metrics_source
1 parent df9b4b0 commit 9d5d99d

File tree

4 files changed

+72
-90
lines changed

4 files changed

+72
-90
lines changed

.github/workflows/test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ jobs:
9898
SUMOLOGIC_TEST_ROLE_ARN: ${{ secrets.SUMOLOGIC_TEST_ROLE_ARN }}
9999
SUMOLOGIC_TEST_SAS_KEY: ${{ secrets.SUMOLOGIC_TEST_SAS_KEY }}
100100
SUMOLOGIC_TEST_SAS_KEY_NAME: ${{ secrets.SUMOLOGIC_TEST_SAS_KEY_NAME }}
101+
SUMOLOGIC_TEST_AZURE_TENANT_ID: ${{ secrets.SUMOLOGIC_TEST_AZURE_TENANT_ID }}
102+
SUMOLOGIC_TEST_AZURE_CLIENT_ID: ${{ secrets.SUMOLOGIC_TEST_AZURE_CLIENT_ID }}
103+
SUMOLOGIC_TEST_AZURE_CLIENT_SECRET: ${{ secrets.SUMOLOGIC_TEST_AZURE_CLIENT_SECRET }}
101104

102105
# disable go test timeout. We rely on GitHub action timeout.
103106
run: |

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## X.Y.Z (Unreleased)
2-
* Add new change notes here
2+
FEATURES:
3+
* **New Resource:** sumologic_azure_metrics_source (GH-710)
34

45
## 3.0.0 (December 09, 2024)
56
**REMOVALS:**

sumologic/resource_sumologic_polling_source.go

Lines changed: 0 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -125,85 +125,13 @@ func resourceSumologicPollingSource() *schema.Resource {
125125
},
126126
},
127127
},
128-
"azure_tag_filters": {
129-
Type: schema.TypeList,
130-
Optional: true,
131-
Elem: &schema.Resource{
132-
Schema: map[string]*schema.Schema{
133-
"type": {
134-
Type: schema.TypeString,
135-
Required: true,
136-
},
137-
"namespace": {
138-
Type: schema.TypeString,
139-
Optional: true,
140-
},
141-
"tags": {
142-
Type: schema.TypeList,
143-
Optional: true,
144-
Elem: &schema.Resource{
145-
Schema: map[string]*schema.Schema{
146-
"name": {
147-
Type: schema.TypeString,
148-
Required: true,
149-
},
150-
"values": {
151-
Type: schema.TypeList,
152-
Optional: true,
153-
Elem: &schema.Schema{
154-
Type: schema.TypeString,
155-
},
156-
},
157-
},
158-
},
159-
},
160-
},
161-
},
162-
},
163128
},
164129
},
165130
}
166131

167132
return pollingSource
168133
}
169134

170-
func validateTags(val interface{}, key string) ([]string, []error) {
171-
var errors []error
172-
173-
if tags, ok := val.([]interface{}); ok {
174-
for i, tag := range tags {
175-
switch t := tag.(type) {
176-
case map[string]interface{}:
177-
// Validate object structure
178-
// Validate "name" to be a string
179-
if _, ok := t["name"]; !ok {
180-
errors = append(errors, fmt.Errorf("%s[%d]: missing required field 'name'", key, i))
181-
} else if _, ok := t["name"].(string); !ok {
182-
errors = append(errors, fmt.Errorf("%s[%d]: 'name' must be a string", key, i))
183-
}
184-
185-
// Validate "values" to be a list of strings
186-
if _, ok := t["values"]; !ok {
187-
errors = append(errors, fmt.Errorf("%s[%d]: missing required field 'values'", key, i))
188-
} else if values, ok := t["values"].([]interface{}); !ok {
189-
errors = append(errors, fmt.Errorf("%s[%d]: 'values' must be a list of strings", key, i))
190-
} else {
191-
for j, value := range values {
192-
if _, ok := value.(string); !ok {
193-
errors = append(errors, fmt.Errorf("%s[%d].values[%d]: must be a string", key, i, j))
194-
}
195-
}
196-
}
197-
case string:
198-
continue
199-
default:
200-
errors = append(errors, fmt.Errorf("%s[%d]: must be either a string or an object with 'name' and 'values'", key, i))
201-
}
202-
}
203-
}
204-
return nil, errors
205-
}
206-
207135
func resourceSumologicPollingSourceCreate(d *schema.ResourceData, meta interface{}) error {
208136

209137
c := meta.(*Client)
@@ -317,7 +245,6 @@ func getThirdPartyPathAttributes(pollingResource []PollingResource) []map[string
317245
func flattenTagFilters(v []interface{}) []map[string]interface{} {
318246
var filters []map[string]interface{}
319247
for _, d := range v {
320-
log.Printf("[DEBUG] Entering myTerraformFunction" + d.(string))
321248
switch t := d.(type) {
322249
case TagFilter:
323250
filter := map[string]interface{}{
@@ -326,22 +253,6 @@ func flattenTagFilters(v []interface{}) []map[string]interface{} {
326253
"tags": t.Tags,
327254
}
328255
filters = append(filters, filter)
329-
case AzureTagFilter:
330-
var tags []map[string]interface{}
331-
for _, rawTag := range t.Tags {
332-
tag := map[string]interface{}{
333-
"name": rawTag.Name,
334-
"values": rawTag.Values,
335-
}
336-
tags = append(tags, tag)
337-
}
338-
339-
filter := map[string]interface{}{
340-
"type": t.Type,
341-
"namespace": t.Namespace,
342-
"tags": tags,
343-
}
344-
filters = append(filters, filter)
345256
}
346257
}
347258
return filters
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
layout: "sumologic"
3+
page_title: "SumoLogic: sumologic_azure_metrics_source"
4+
description: |-
5+
Provides a Sumologic Azure Metrics Source.
6+
---
7+
8+
# sumologic_azure_metrics_source
9+
Provides a [Sumologic Azure Metrics Source](https://help.sumologic.com/docs/send-data/hosted-collectors/microsoft-source/azure-metrics-source/)
10+
11+
__IMPORTANT:__ The Azure Event Hub credentials are stored in plain-text in the state. This is a potential security issue.
12+
13+
## Example Usage
14+
```hcl
15+
resource "sumologic_azure_metrics_source" "terraform_azure_metrics_source" {
16+
name = "Azure Metrics Source"
17+
description = "My description"
18+
category = "azure/metrics"
19+
content_type = "AzureMetrics"
20+
collector_id = "${sumologic_collector.collector.id}"
21+
22+
authentication {
23+
type = "AzureClientSecretAuthentication"
24+
tenant_id = "azure_tenant_id"
25+
client_id = "azure_client_id"
26+
client_secret = "azure_client_secret"
27+
}
28+
29+
path {
30+
type = "AzureMetricsPath"
31+
environment = "Azure"
32+
limit_to_namespaces = ["Microsoft.ClassicStorage/storageAccounts"]
33+
azure_tag_filters {
34+
type = "AzureTagFilters"
35+
namespace = "Microsoft.ClassicStorage/storageAccounts"
36+
tags {
37+
name = "test-name-1"
38+
values = ["value1", "value2"]
39+
}
40+
}
41+
}
42+
}
43+
44+
resource "sumologic_collector" "collector" {
45+
name = "my-collector"
46+
description = "Just testing this"
47+
}
48+
```
49+
50+
## Argument reference
51+
In addition to the [Common Source Properties](https://registry.terraform.io/providers/SumoLogic/sumologic/latest/docs#common-source-properties), the following arguments are supported:
52+
- `content_type` - (Required) Must be `AzureMetrics`.
53+
- `authentication` - (Required) Authentication details for connecting to ingest metrics from Azure.
54+
+ `type` - (Required) Must be `AzureClientSecretAuthentication`.
55+
+ `tenant_id` - (Required) Your tenant id collected from [Azure platform](https://help.sumologic.com/docs/send-data/hosted-collectors/microsoft-source/azure-metrics-source/#vendor-configuration).
56+
+ `client_id` - (Required) Your client id collected from [Azure platform](https://help.sumologic.com/docs/send-data/hosted-collectors/microsoft-source/azure-metrics-source/#vendor-configuration).
57+
+ `client_secret` - (Required) Your client secret collected from [Azure platform](https://help.sumologic.com/docs/send-data/hosted-collectors/microsoft-source/azure-metrics-source/#vendor-configuration).
58+
- `path` - (Required) The location to scan for new data.
59+
+ `type` - (Required) Must be `AzureMetricsPath`.
60+
+ `environment` - (Required) The environment to collect Azure metrics.
61+
+ `limit_to_namespaces` - (Opitonal) The list of namespaces to collect metrics. By default all namespaces are selected.
62+
+ `azure_tag_filters` - (Optional) Tag filters allow you to filter the Azure metrics by the tags you have assigned to your Azure resources. You can define tag filters for each supported namespace. If you do not define any tag filters, all metrics will be collected for namespaces you configured for the source above.
63+
+ `type` - (Required) This value has to be set to `AzureTagFilters`
64+
+ `namespace` - Namespace for which you want to define the tag filters.
65+
+ `tags` - List of key and value list of tag filters.
66+
+ `name`: The name of tag.
67+
+ `values`: The list of accepted values for the tag name.

0 commit comments

Comments
 (0)