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
6 changes: 6 additions & 0 deletions .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
2 changes: 1 addition & 1 deletion .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,7 @@ components:
type: string
ResourceID:
description: |-
Identifier, formatted as `type:id`. Supported types: `dashboard`, `integration-service`, `integration-webhook`, `notebook`, `reference-table`, `security-rule`, `slo`, `workflow`, `app-builder-app`, `connection`, `connection-group`, `rum-application`, `cross-org-connection`, `spreadsheet`, `on-call-schedule`, `on-call-escalation-policy`, `on-call-team-routing-rules`, `logs-pipeline`.
Identifier, formatted as `type:id`. Supported types: `dashboard`, `integration-service`, `integration-webhook`, `notebook`, `powerpack`, `reference-table`, `security-rule`, `slo`, `synthetics-global-variable`, `synthetics-test`, `synthetics-private-location`, `monitor`, `workflow`, `app-builder-app`, `connection`, `connection-group`, `rum-application`, `cross-org-connection`, `spreadsheet`, `on-call-schedule`, `on-call-escalation-policy`, `on-call-team-routing-rules`, `logs-pipeline`, `case-management-project`.
example: "dashboard:abc-def-ghi"
in: path
name: resource_id
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
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
6 changes: 3 additions & 3 deletions src/datadog_api_client/v2/api/restriction_policies_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def delete_restriction_policy(

Deletes the restriction policy associated with a specified resource.

:param resource_id: Identifier, formatted as ``type:id``. Supported types: ``dashboard`` , ``integration-service`` , ``integration-webhook`` , ``notebook`` , ``reference-table`` , ``security-rule`` , ``slo`` , ``workflow`` , ``app-builder-app`` , ``connection`` , ``connection-group`` , ``rum-application`` , ``cross-org-connection`` , ``spreadsheet`` , ``on-call-schedule`` , ``on-call-escalation-policy`` , ``on-call-team-routing-rules`` , ``logs-pipeline``.
:param resource_id: Identifier, formatted as ``type:id``. Supported types: ``dashboard`` , ``integration-service`` , ``integration-webhook`` , ``notebook`` , ``powerpack`` , ``reference-table`` , ``security-rule`` , ``slo`` , ``synthetics-global-variable`` , ``synthetics-test`` , ``synthetics-private-location`` , ``monitor`` , ``workflow`` , ``app-builder-app`` , ``connection`` , ``connection-group`` , ``rum-application`` , ``cross-org-connection`` , ``spreadsheet`` , ``on-call-schedule`` , ``on-call-escalation-policy`` , ``on-call-team-routing-rules`` , ``logs-pipeline`` , ``case-management-project``.
:type resource_id: str
:rtype: None
"""
Expand All @@ -129,7 +129,7 @@ def get_restriction_policy(

Retrieves the restriction policy associated with a specified resource.

:param resource_id: Identifier, formatted as ``type:id``. Supported types: ``dashboard`` , ``integration-service`` , ``integration-webhook`` , ``notebook`` , ``reference-table`` , ``security-rule`` , ``slo`` , ``workflow`` , ``app-builder-app`` , ``connection`` , ``connection-group`` , ``rum-application`` , ``cross-org-connection`` , ``spreadsheet`` , ``on-call-schedule`` , ``on-call-escalation-policy`` , ``on-call-team-routing-rules`` , ``logs-pipeline``.
:param resource_id: Identifier, formatted as ``type:id``. Supported types: ``dashboard`` , ``integration-service`` , ``integration-webhook`` , ``notebook`` , ``powerpack`` , ``reference-table`` , ``security-rule`` , ``slo`` , ``synthetics-global-variable`` , ``synthetics-test`` , ``synthetics-private-location`` , ``monitor`` , ``workflow`` , ``app-builder-app`` , ``connection`` , ``connection-group`` , ``rum-application`` , ``cross-org-connection`` , ``spreadsheet`` , ``on-call-schedule`` , ``on-call-escalation-policy`` , ``on-call-team-routing-rules`` , ``logs-pipeline`` , ``case-management-project``.
:type resource_id: str
:rtype: RestrictionPolicyResponse
"""
Expand Down Expand Up @@ -235,7 +235,7 @@ def update_restriction_policy(
- ``viewer`` , ``contributor`` , ``manager``


:param resource_id: Identifier, formatted as ``type:id``. Supported types: ``dashboard`` , ``integration-service`` , ``integration-webhook`` , ``notebook`` , ``reference-table`` , ``security-rule`` , ``slo`` , ``workflow`` , ``app-builder-app`` , ``connection`` , ``connection-group`` , ``rum-application`` , ``cross-org-connection`` , ``spreadsheet`` , ``on-call-schedule`` , ``on-call-escalation-policy`` , ``on-call-team-routing-rules`` , ``logs-pipeline``.
:param resource_id: Identifier, formatted as ``type:id``. Supported types: ``dashboard`` , ``integration-service`` , ``integration-webhook`` , ``notebook`` , ``powerpack`` , ``reference-table`` , ``security-rule`` , ``slo`` , ``synthetics-global-variable`` , ``synthetics-test`` , ``synthetics-private-location`` , ``monitor`` , ``workflow`` , ``app-builder-app`` , ``connection`` , ``connection-group`` , ``rum-application`` , ``cross-org-connection`` , ``spreadsheet`` , ``on-call-schedule`` , ``on-call-escalation-policy`` , ``on-call-team-routing-rules`` , ``logs-pipeline`` , ``case-management-project``.
:type resource_id: str
:param body: Restriction policy payload
:type body: RestrictionPolicyUpdateRequest
Expand Down
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