diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 73ba5dd..ddce8fe 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -69,7 +69,7 @@ jobs: key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} restore-keys: ${{ runner.os }}-go- - name: Run Docker containers - run: docker-compose up --detach + run: docker compose up --detach env: OSS_IMAGE: "${{ matrix.oss-image }}:${{ matrix.version }}" OS_COMMAND: "${{matrix.OS_COMMAND}}" diff --git a/docs/data-sources/host.md b/docs/data-sources/host.md index fbf16c2..4d2e4ad 100644 --- a/docs/data-sources/host.md +++ b/docs/data-sources/host.md @@ -29,3 +29,5 @@ data "opensearch_host" "test" { - `id` (String) The ID of this resource. - `url` (String) the url of the active cluster + + diff --git a/docs/resources/anomaly_detection.md b/docs/resources/anomaly_detection.md index e855c1a..a2abbd9 100644 --- a/docs/resources/anomaly_detection.md +++ b/docs/resources/anomaly_detection.md @@ -78,3 +78,5 @@ EOF ### Read-Only - `id` (String) The ID of this resource. + + diff --git a/docs/resources/cluster_settings.md b/docs/resources/cluster_settings.md index 28bf99d..4529b18 100644 --- a/docs/resources/cluster_settings.md +++ b/docs/resources/cluster_settings.md @@ -53,6 +53,11 @@ resource "opensearch_cluster_settings" "global" { - `cluster_routing_allocation_same_shard_host` (Boolean) Perform a check to prevent allocation of multiple instances of the same shard on a single host, if multiple nodes are started on the host - `cluster_routing_allocation_total_shards_per_node` (Number) Maximum number of primary and replica shards allocated to each node - `cluster_routing_rebalance_enable` (String) Allow rebalancing for specific kinds of shards (all, primaries, replicas, none) +- `cluster_search_request_slowlog_level` (String) Log level for search requests slowlog (TRACE, DEBUG, INFO, WARN) +- `cluster_search_request_slowlog_threshold_debug` (String) Slowlog threshold for DEBUG level search requests (e.g., 2s) +- `cluster_search_request_slowlog_threshold_info` (String) Slowlog threshold for INFO level search requests (e.g., 5s) +- `cluster_search_request_slowlog_threshold_trace` (String) Slowlog threshold for TRACE level search requests (e.g., 10ms) +- `cluster_search_request_slowlog_threshold_warn` (String) Slowlog threshold for WARN level search requests (e.g., 10s) - `indices_breaker_fielddata_limit` (String) The percentage of memory above which if loading a field into the field data cache would cause the cache to exceed this limit, an error is returned - `indices_breaker_fielddata_overhead` (Number) A constant that all field data estimations are multiplied by - `indices_breaker_request_limit` (String) The percentabge of memory above which per-request data structures (e.g. calculating aggregations) are prevented from exceeding @@ -67,3 +72,5 @@ resource "opensearch_cluster_settings" "global" { ### Read-Only - `id` (String) The ID of this resource. + + diff --git a/docs/resources/dashboard_object.md b/docs/resources/dashboard_object.md index 4b8cef3..7547284 100644 --- a/docs/resources/dashboard_object.md +++ b/docs/resources/dashboard_object.md @@ -111,3 +111,5 @@ EOF ### Read-Only - `id` (String) The ID of this resource. + + diff --git a/docs/resources/data_stream.md b/docs/resources/data_stream.md index 899131c..67a4483 100644 --- a/docs/resources/data_stream.md +++ b/docs/resources/data_stream.md @@ -39,3 +39,5 @@ resource "opensearch_data_stream" "foo" { ### Read-Only - `id` (String) The ID of this resource. + + diff --git a/examples/cluster-settings/provider.tf b/examples/cluster-settings/provider.tf new file mode 100644 index 0000000..efbea97 --- /dev/null +++ b/examples/cluster-settings/provider.tf @@ -0,0 +1,23 @@ +# Configure the OpenSearch provider +terraform { + required_providers { + opensearch = { + source = "registry.terraform.io/opensearch-project/opensearch" + } + } +} + +provider "opensearch" { + url = "http://127.0.0.1:9200" + username = "admin" + password = "myStrongPassword123@456" +} + +resource "opensearch_cluster_settings" "persistent" { + cluster_max_shards_per_node = 10 + cluster_search_request_slowlog_level = "WARN" + cluster_search_request_slowlog_threshold_warn = "10s" + cluster_search_request_slowlog_threshold_info = "5s" + cluster_search_request_slowlog_threshold_debug = "2s" + cluster_search_request_slowlog_threshold_trace = "100ms" +} diff --git a/provider/resource_opensearch_cluster_settings.go b/provider/resource_opensearch_cluster_settings.go index 8510a2b..8364f01 100644 --- a/provider/resource_opensearch_cluster_settings.go +++ b/provider/resource_opensearch_cluster_settings.go @@ -36,6 +36,11 @@ var ( "search.default_search_timeout", "action.auto_create_index", "cluster.routing.allocation.enable", + "cluster.search.request.slowlog.level", + "cluster.search.request.slowlog.threshold.warn", + "cluster.search.request.slowlog.threshold.info", + "cluster.search.request.slowlog.threshold.debug", + "cluster.search.request.slowlog.threshold.trace", } intClusterSettings = []string{ "cluster.max_shards_per_node", @@ -170,6 +175,31 @@ func resourceOpensearchClusterSettings() *schema.Resource { Optional: true, Description: "Enable or disable allocation for specific kinds of shards (all, primaries, new_primaries, none)", }, + "cluster_search_request_slowlog_level": { + Type: schema.TypeString, + Optional: true, + Description: "Log level for search requests slowlog (TRACE, DEBUG, INFO, WARN)", + }, + "cluster_search_request_slowlog_threshold_warn": { + Type: schema.TypeString, + Optional: true, + Description: "Slowlog threshold for WARN level search requests (e.g., 10s)", + }, + "cluster_search_request_slowlog_threshold_info": { + Type: schema.TypeString, + Optional: true, + Description: "Slowlog threshold for INFO level search requests (e.g., 5s)", + }, + "cluster_search_request_slowlog_threshold_debug": { + Type: schema.TypeString, + Optional: true, + Description: "Slowlog threshold for DEBUG level search requests (e.g., 2s)", + }, + "cluster_search_request_slowlog_threshold_trace": { + Type: schema.TypeString, + Optional: true, + Description: "Slowlog threshold for TRACE level search requests (e.g., 10ms)", + }, "cluster_routing_allocation_node_concurrent_incoming_recoveries": { Type: schema.TypeInt, Optional: true, diff --git a/provider/resource_opensearch_cluster_settings_test.go b/provider/resource_opensearch_cluster_settings_test.go index e40c652..3a69b69 100644 --- a/provider/resource_opensearch_cluster_settings_test.go +++ b/provider/resource_opensearch_cluster_settings_test.go @@ -26,6 +26,23 @@ func TestAccOpensearchClusterSettings(t *testing.T) { }) } +func TestAccOpensearchClusterSettingsSlowLogs(t *testing.T) { + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: checkOpensearchClusterSettingsDestroy, + Steps: []resource.TestStep{ + { + Config: testAccOpensearchClusterSettingsSlowLog, + Check: resource.ComposeTestCheckFunc( + testCheckOpensearchClusterSettingInState("opensearch_cluster_settings.global"), + testCheckOpensearchClusterSettingExists("cluster.search.request.slowlog.level"), + ), + }, + }, + }) +} + func testCheckOpensearchClusterSettingInState(name string) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[name] @@ -89,3 +106,10 @@ resource "opensearch_cluster_settings" "global" { action_auto_create_index = "my-index-000001,index10,-index1*,+ind*,-.aws_cold_catalog*,+*" } ` + +var testAccOpensearchClusterSettingsSlowLog = ` +resource "opensearch_cluster_settings" "global" { + cluster_search_request_slowlog_level = "WARN" + cluster_search_request_slowlog_threshold_warn = "10s" +} +`