Skip to content

Commit 8eab014

Browse files
authored
fix(tmp): [120953595] add open_default_record field (#3018)
* fix(tmp): [120953595] add open_default_record Field * fix: add changelog * fix: modify test
1 parent 4bb4ac5 commit 8eab014

File tree

4 files changed

+24
-6
lines changed

4 files changed

+24
-6
lines changed

.changelog/3018.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
resource/tencentcloud_monitor_tmp_tke_cluster_agent: support `open_default_record` field.
3+
```

tencentcloud/services/tmp/resource_tc_monitor_tmp_tke_cluster_agent.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,12 @@ func ResourceTencentCloudMonitorTmpTkeClusterAgent() *schema.Resource {
144144
Optional: true,
145145
Description: "Whether to collect indicators, true means drop all indicators, false means collect default indicators.",
146146
},
147+
"open_default_record": {
148+
Type: schema.TypeBool,
149+
Optional: true,
150+
Computed: true,
151+
Description: "Whether to enable the default pre-aggregation rule.",
152+
},
147153
"cluster_name": {
148154
Type: schema.TypeString,
149155
Computed: true,
@@ -247,6 +253,9 @@ func resourceTencentCloudMonitorTmpTkeClusterAgentCreate(d *schema.ResourceData,
247253
if v, ok := dMap["not_scrape"]; ok {
248254
prometheusClusterAgent.NotScrape = helper.Bool(v.(bool))
249255
}
256+
if v, ok := dMap["open_default_record"]; ok {
257+
prometheusClusterAgent.OpenDefaultRecord = helper.Bool(v.(bool))
258+
}
250259
var prometheusClusterAgents []*monitor.PrometheusClusterAgentBasic
251260
prometheusClusterAgents = append(prometheusClusterAgents, &prometheusClusterAgent)
252261
request.Agents = prometheusClusterAgents
@@ -324,6 +333,9 @@ func resourceTencentCloudMonitorTmpTkeClusterAgentRead(d *schema.ResourceData, m
324333

325334
var agents []map[string]interface{}
326335
agent := make(map[string]interface{})
336+
if v, ok := d.GetOk("agents"); ok && len(v.([]interface{})) > 0 {
337+
agent = v.([]interface{})[0].(map[string]interface{})
338+
}
327339
agent["cluster_id"] = clusterAgent.ClusterId
328340
agent["cluster_type"] = clusterAgent.ClusterType
329341
agent["status"] = clusterAgent.Status

tencentcloud/services/tmp/resource_tc_monitor_tmp_tke_cluster_agent_test.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,9 @@ func TestAccTencentCloudMonitorClusterAgent_basic(t *testing.T) {
6161
Config: testClusterAgentYaml_basic,
6262
Check: resource.ComposeTestCheckFunc(
6363
testAccCheckClusterAgentExists("tencentcloud_monitor_tmp_tke_cluster_agent.basic"),
64-
resource.TestCheckResourceAttr("tencentcloud_monitor_tmp_tke_cluster_agent.basic", "agents.0.cluster_id", "cls-9ae9qo9k"),
65-
resource.TestCheckResourceAttr("tencentcloud_monitor_tmp_tke_cluster_agent.basic", "agents.0.cluster_type", "eks"),
64+
resource.TestCheckResourceAttr("tencentcloud_monitor_tmp_tke_cluster_agent.basic", "agents.0.cluster_id", tcacctest.TkeClusterIdAgent),
65+
resource.TestCheckResourceAttr("tencentcloud_monitor_tmp_tke_cluster_agent.basic", "agents.0.cluster_type", tcacctest.TkeClusterTypeAgent),
66+
resource.TestCheckResourceAttr("tencentcloud_monitor_tmp_tke_cluster_agent.basic", "agents.0.open_default_record", "true"),
6667
),
6768
},
6869
},
@@ -147,9 +148,10 @@ const testClusterAgentYaml_basic = testClusterAgentYamlVar + `
147148
resource "tencentcloud_monitor_tmp_tke_cluster_agent" "basic" {
148149
instance_id = var.prometheus_id
149150
agents {
150-
region = var.default_region
151-
cluster_type = var.agent_cluster_type
152-
cluster_id = var.agent_cluster_id
153-
enable_external = false
151+
region = var.default_region
152+
cluster_type = var.agent_cluster_type
153+
cluster_id = var.agent_cluster_id
154+
enable_external = false
155+
open_default_record = true
154156
}
155157
}`

website/docs/r/monitor_tmp_tke_cluster_agent.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ The `agents` object supports the following:
188188
* `in_cluster_pod_config` - (Optional, List) Pod configuration for components deployed in the cluster.
189189
* `not_install_basic_scrape` - (Optional, Bool) Whether to install the default collection configuration.
190190
* `not_scrape` - (Optional, Bool) Whether to collect indicators, true means drop all indicators, false means collect default indicators.
191+
* `open_default_record` - (Optional, Bool) Whether to enable the default pre-aggregation rule.
191192

192193
The `external_labels` object of `agents` supports the following:
193194

0 commit comments

Comments
 (0)