alicloud_cms_hybrid_monitor_sls_task

Provides a Cloud Monitor Service Hybrid Monitor Sls Task resource.

For information about Cloud Monitor Service Hybrid Monitor Sls Task and how to use it, see What is Hybrid Monitor Sls Task.

Example Usage

Basic Usage

variable "name" {
  default = "tf_example"
}
data "alicloud_account" "default" {}
data "alicloud_regions" "default" {
  current = true
}
resource "random_uuid" "default" {
}
resource "alicloud_log_project" "default" {
  name = substr("tf-example-${replace(random_uuid.default.result, "-", "")}", 0, 16)
}

resource "alicloud_log_store" "default" {
  project               = alicloud_log_project.default.name
  name                  = var.name
  shard_count           = 3
  auto_split            = true
  max_split_shard_count = 60
  append_meta           = true
}

resource "alicloud_cms_sls_group" "default" {
  sls_group_config {
    sls_user_id  = data.alicloud_account.default.id
    sls_logstore = alicloud_log_store.default.name
    sls_project  = alicloud_log_project.default.name
    sls_region   = data.alicloud_regions.default.regions.0.id
  }
  sls_group_description = var.name
  sls_group_name        = var.name
}

resource "alicloud_cms_namespace" "default" {
  namespace     = substr("tf-example-${replace(random_uuid.default.result, "-", "")}", 0, 16)
  specification = "cms.s1.large"
}

resource "alicloud_cms_hybrid_monitor_sls_task" "default" {
  task_name           = var.name
  namespace           = alicloud_cms_namespace.default.id
  description         = var.name
  collect_interval    = 60
  collect_target_type = alicloud_cms_sls_group.default.id

  sls_process_config {
    filter {
      relation = "and"
      filters {
        operator     = "="
        value        = "200"
        sls_key_name = "code"
      }
    }
    statistics {
      function      = "count"
      alias         = "level_count"
      sls_key_name  = "name"
      parameter_one = "200"
      parameter_two = "299"
    }
    group_by {
      alias        = "code"
      sls_key_name = "ApiResult"
    }
    express {
      express = "success_count"
      alias   = "SuccRate"
    }
  }

  attach_labels {
    name  = "app_service"
    value = "example_Value"
  }
}

Argument Reference

The following arguments are supported:

sls_process_config

The sls_process_config supports the following:

sls_process_config-statistics

The statistics supports the following:

sls_process_config-group_by

The group_by supports the following:

sls_process_config-filter

The filter supports the following:

sls_process_config-filter-filters

The filters supports the following:

sls_process_config-express

The express supports the following:

attach_labels

The attach_labels supports the following:

Attributes Reference

The following attributes are exported:

Timeouts

The timeouts block allows you to specify timeouts for certain actions:

Import

Cloud Monitor Service Hybrid Monitor Sls Task can be imported using the id, e.g.

$ terraform import alicloud_cms_hybrid_monitor_sls_task.example <id>