diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index a50db5d2e0..4280d3d9c5 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -5734,6 +5734,12 @@ components: Scope down exclusion filter to only a subset of logs with a log query. example: "*" type: string + sample_attribute: + description: |- + Sample attribute to use for the sampling of logs going through this exclusion filter. + When set, only the logs with the specified attribute are sampled. + example: "@ci.job_id" + type: string sample_rate: description: |- Sample rate to apply to logs going through this exclusion filter, @@ -29274,7 +29280,7 @@ paths: Update an index as identified by its name. Returns the Index object passed in the request body when the request is successful. - Using the `PUT` method updates your index’s configuration by **replacing** + Using the `PUT` method updates your index's configuration by **replacing** your current configuration with the new one sent to your Datadog organization. operationId: UpdateLogsIndex parameters: diff --git a/examples/v1/logs-indexes/CreateLogsIndex.py b/examples/v1/logs-indexes/CreateLogsIndex.py index 0fe8b31016..9f2d0f5889 100644 --- a/examples/v1/logs-indexes/CreateLogsIndex.py +++ b/examples/v1/logs-indexes/CreateLogsIndex.py @@ -21,6 +21,7 @@ LogsExclusion( filter=LogsExclusionFilter( query="*", + sample_attribute="@ci.job_id", sample_rate=1.0, ), name="payment", diff --git a/examples/v1/logs-indexes/UpdateLogsIndex.py b/examples/v1/logs-indexes/UpdateLogsIndex.py index 9922159286..8059e2c38d 100644 --- a/examples/v1/logs-indexes/UpdateLogsIndex.py +++ b/examples/v1/logs-indexes/UpdateLogsIndex.py @@ -22,6 +22,7 @@ LogsExclusion( filter=LogsExclusionFilter( query="*", + sample_attribute="@ci.job_id", sample_rate=1.0, ), name="payment", diff --git a/src/datadog_api_client/v1/api/logs_indexes_api.py b/src/datadog_api_client/v1/api/logs_indexes_api.py index ad1a0b3667..6a59ce1bb0 100644 --- a/src/datadog_api_client/v1/api/logs_indexes_api.py +++ b/src/datadog_api_client/v1/api/logs_indexes_api.py @@ -254,7 +254,7 @@ def update_logs_index( Update an index as identified by its name. Returns the Index object passed in the request body when the request is successful. - Using the ``PUT`` method updates your index’s configuration by **replacing** + Using the ``PUT`` method updates your index's configuration by **replacing** your current configuration with the new one sent to your Datadog organization. :param name: Name of the log index. diff --git a/src/datadog_api_client/v1/model/logs_exclusion_filter.py b/src/datadog_api_client/v1/model/logs_exclusion_filter.py index ad747dcfac..992d854fa7 100644 --- a/src/datadog_api_client/v1/model/logs_exclusion_filter.py +++ b/src/datadog_api_client/v1/model/logs_exclusion_filter.py @@ -18,15 +18,23 @@ class LogsExclusionFilter(ModelNormal): def openapi_types(_): return { "query": (str,), + "sample_attribute": (str,), "sample_rate": (float,), } attribute_map = { "query": "query", + "sample_attribute": "sample_attribute", "sample_rate": "sample_rate", } - def __init__(self_, sample_rate: float, query: Union[str, UnsetType] = unset, **kwargs): + def __init__( + self_, + sample_rate: float, + query: Union[str, UnsetType] = unset, + sample_attribute: Union[str, UnsetType] = unset, + **kwargs, + ): """ Exclusion filter is defined by a query, a sampling rule, and a active/inactive toggle. @@ -34,12 +42,18 @@ def __init__(self_, sample_rate: float, query: Union[str, UnsetType] = unset, ** Scope down exclusion filter to only a subset of logs with a log query. :type query: str, optional + :param sample_attribute: Sample attribute to use for the sampling of logs going through this exclusion filter. + When set, only the logs with the specified attribute are sampled. + :type sample_attribute: str, optional + :param sample_rate: Sample rate to apply to logs going through this exclusion filter, a value of 1.0 excludes all logs matching the query. :type sample_rate: float """ if query is not unset: kwargs["query"] = query + if sample_attribute is not unset: + kwargs["sample_attribute"] = sample_attribute super().__init__(kwargs) self_.sample_rate = sample_rate diff --git a/tests/v1/features/logs_indexes.feature b/tests/v1/features/logs_indexes.feature index 8277ce4ae2..4091527029 100644 --- a/tests/v1/features/logs_indexes.feature +++ b/tests/v1/features/logs_indexes.feature @@ -11,21 +11,21 @@ Feature: Logs Indexes @generated @skip @team:DataDog/logs-backend @team:DataDog/logs-core Scenario: Create an index returns "Invalid Parameter Error" response Given new "CreateLogsIndex" request - And body with value {"daily_limit": 300000000, "daily_limit_reset": {"reset_time": "14:00", "reset_utc_offset": "+02:00"}, "daily_limit_warning_threshold_percentage": 70, "exclusion_filters": [{"filter": {"query": "*", "sample_rate": 1.0}, "name": "payment"}], "filter": {"query": "source:python"}, "name": "main", "num_flex_logs_retention_days": 360, "num_retention_days": 15, "tags": ["team:backend", "env:production"]} + And body with value {"daily_limit": 300000000, "daily_limit_reset": {"reset_time": "14:00", "reset_utc_offset": "+02:00"}, "daily_limit_warning_threshold_percentage": 70, "exclusion_filters": [{"filter": {"query": "*", "sample_attribute": "@ci.job_id", "sample_rate": 1.0}, "name": "payment"}], "filter": {"query": "source:python"}, "name": "main", "num_flex_logs_retention_days": 360, "num_retention_days": 15, "tags": ["team:backend", "env:production"]} When the request is sent Then the response status is 400 Invalid Parameter Error @generated @skip @team:DataDog/logs-backend @team:DataDog/logs-core Scenario: Create an index returns "OK" response Given new "CreateLogsIndex" request - And body with value {"daily_limit": 300000000, "daily_limit_reset": {"reset_time": "14:00", "reset_utc_offset": "+02:00"}, "daily_limit_warning_threshold_percentage": 70, "exclusion_filters": [{"filter": {"query": "*", "sample_rate": 1.0}, "name": "payment"}], "filter": {"query": "source:python"}, "name": "main", "num_flex_logs_retention_days": 360, "num_retention_days": 15, "tags": ["team:backend", "env:production"]} + And body with value {"daily_limit": 300000000, "daily_limit_reset": {"reset_time": "14:00", "reset_utc_offset": "+02:00"}, "daily_limit_warning_threshold_percentage": 70, "exclusion_filters": [{"filter": {"query": "*", "sample_attribute": "@ci.job_id", "sample_rate": 1.0}, "name": "payment"}], "filter": {"query": "source:python"}, "name": "main", "num_flex_logs_retention_days": 360, "num_retention_days": 15, "tags": ["team:backend", "env:production"]} When the request is sent Then the response status is 200 OK @generated @skip @team:DataDog/logs-backend @team:DataDog/logs-core Scenario: Create an index returns "Unprocessable Entity" response Given new "CreateLogsIndex" request - And body with value {"daily_limit": 300000000, "daily_limit_reset": {"reset_time": "14:00", "reset_utc_offset": "+02:00"}, "daily_limit_warning_threshold_percentage": 70, "exclusion_filters": [{"filter": {"query": "*", "sample_rate": 1.0}, "name": "payment"}], "filter": {"query": "source:python"}, "name": "main", "num_flex_logs_retention_days": 360, "num_retention_days": 15, "tags": ["team:backend", "env:production"]} + And body with value {"daily_limit": 300000000, "daily_limit_reset": {"reset_time": "14:00", "reset_utc_offset": "+02:00"}, "daily_limit_warning_threshold_percentage": 70, "exclusion_filters": [{"filter": {"query": "*", "sample_attribute": "@ci.job_id", "sample_rate": 1.0}, "name": "payment"}], "filter": {"query": "source:python"}, "name": "main", "num_flex_logs_retention_days": 360, "num_retention_days": 15, "tags": ["team:backend", "env:production"]} When the request is sent Then the response status is 422 Unprocessable Entity @@ -73,7 +73,7 @@ Feature: Logs Indexes Scenario: Update an index returns "Invalid Parameter Error" response Given new "UpdateLogsIndex" request And request contains "name" parameter from "REPLACE.ME" - And body with value {"daily_limit": 300000000, "daily_limit_reset": {"reset_time": "14:00", "reset_utc_offset": "+02:00"}, "daily_limit_warning_threshold_percentage": 70, "disable_daily_limit": false, "exclusion_filters": [{"filter": {"query": "*", "sample_rate": 1.0}, "name": "payment"}], "filter": {"query": "source:python"}, "num_flex_logs_retention_days": 360, "num_retention_days": 15, "tags": ["team:backend", "env:production"]} + And body with value {"daily_limit": 300000000, "daily_limit_reset": {"reset_time": "14:00", "reset_utc_offset": "+02:00"}, "daily_limit_warning_threshold_percentage": 70, "disable_daily_limit": false, "exclusion_filters": [{"filter": {"query": "*", "sample_attribute": "@ci.job_id", "sample_rate": 1.0}, "name": "payment"}], "filter": {"query": "source:python"}, "num_flex_logs_retention_days": 360, "num_retention_days": 15, "tags": ["team:backend", "env:production"]} When the request is sent Then the response status is 400 Invalid Parameter Error @@ -81,7 +81,7 @@ Feature: Logs Indexes Scenario: Update an index returns "OK" response Given new "UpdateLogsIndex" request And request contains "name" parameter from "REPLACE.ME" - And body with value {"daily_limit": 300000000, "daily_limit_reset": {"reset_time": "14:00", "reset_utc_offset": "+02:00"}, "daily_limit_warning_threshold_percentage": 70, "disable_daily_limit": false, "exclusion_filters": [{"filter": {"query": "*", "sample_rate": 1.0}, "name": "payment"}], "filter": {"query": "source:python"}, "num_flex_logs_retention_days": 360, "num_retention_days": 15, "tags": ["team:backend", "env:production"]} + And body with value {"daily_limit": 300000000, "daily_limit_reset": {"reset_time": "14:00", "reset_utc_offset": "+02:00"}, "daily_limit_warning_threshold_percentage": 70, "disable_daily_limit": false, "exclusion_filters": [{"filter": {"query": "*", "sample_attribute": "@ci.job_id", "sample_rate": 1.0}, "name": "payment"}], "filter": {"query": "source:python"}, "num_flex_logs_retention_days": 360, "num_retention_days": 15, "tags": ["team:backend", "env:production"]} When the request is sent Then the response status is 200 OK