Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 indexs 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:
Expand Down
1 change: 1 addition & 0 deletions examples/v1/logs-indexes/CreateLogsIndex.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
LogsExclusion(
filter=LogsExclusionFilter(
query="*",
sample_attribute="@ci.job_id",
sample_rate=1.0,
),
name="payment",
Expand Down
1 change: 1 addition & 0 deletions examples/v1/logs-indexes/UpdateLogsIndex.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
LogsExclusion(
filter=LogsExclusionFilter(
query="*",
sample_attribute="@ci.job_id",
sample_rate=1.0,
),
name="payment",
Expand Down
2 changes: 1 addition & 1 deletion src/datadog_api_client/v1/api/logs_indexes_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 indexs 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.
Expand Down
16 changes: 15 additions & 1 deletion src/datadog_api_client/v1/model/logs_exclusion_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,42 @@ 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.

:param query: Default query is ``*`` , meaning all logs flowing in the index would be excluded.
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
10 changes: 5 additions & 5 deletions tests/v1/features/logs_indexes.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -73,15 +73,15 @@ 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

@generated @skip @team:DataDog/logs-backend @team:DataDog/logs-core
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

Expand Down
Loading