Description
Enable access logs for HTTP and HTTPS listeners on Tencent Cloud CLB.
Potential impact
Missing logs make it harder to identify when a failed request arrived and how the load balancer handled it.
Remediation
Set log_set_id and log_topic_id to a Cloud Log Service (CLS) log set and topic. Choose a retention period, send a request through the listener and find it in the topic.
Examples
The examples add a Layer 7 log destination. Configure the VPC, subnet and listener separately. Layer 4 traffic is outside this log’s scope.
Before
hcl
resource "tencentcloud_clb_instance" "internal_clb" {
network_type = "INTERNAL"
clb_name = "clb_example"
project_id = 0
vpc_id = tencentcloud_vpc.vpc_test.id
subnet_id = tencentcloud_subnet.subnet_test.id
load_balancer_pass_to_target = true
}
After
hcl
resource "tencentcloud_clb_log_set" "set" {
period = 7
}
resource "tencentcloud_clb_log_topic" "topic" {
log_set_id = tencentcloud_clb_log_set.set.id
topic_name = "clb-topic"
}
resource "tencentcloud_clb_instance" "internal_clb" {
network_type = "INTERNAL"
clb_name = "clb_example"
project_id = 0
vpc_id = tencentcloud_vpc.vpc_test.id
subnet_id = tencentcloud_subnet.subnet_test.id
load_balancer_pass_to_target = true
log_set_id = tencentcloud_clb_log_set.set.id
log_topic_id = tencentcloud_clb_log_topic.topic.id
}