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
775 changes: 775 additions & 0 deletions .generator/schemas/v2/openapi.yaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
"""
Investigate a timeseries anomaly returns "OK" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.timeseries_anomaly_investigations_api import TimeseriesAnomalyInvestigationsApi
from datadog_api_client.v2.model.timeseries_anomaly_investigation_data_source import (
TimeseriesAnomalyInvestigationDataSource,
)
from datadog_api_client.v2.model.timeseries_anomaly_investigation_formula import TimeseriesAnomalyInvestigationFormula
from datadog_api_client.v2.model.timeseries_anomaly_investigation_metric_query import (
TimeseriesAnomalyInvestigationMetricQuery,
)
from datadog_api_client.v2.model.timeseries_anomaly_investigation_request import TimeseriesAnomalyInvestigationRequest
from datadog_api_client.v2.model.timeseries_anomaly_investigation_request_attributes import (
TimeseriesAnomalyInvestigationRequestAttributes,
)
from datadog_api_client.v2.model.timeseries_anomaly_investigation_request_data import (
TimeseriesAnomalyInvestigationRequestData,
)
from datadog_api_client.v2.model.timeseries_anomaly_investigation_timeseries_request import (
TimeseriesAnomalyInvestigationTimeseriesRequest,
)
from datadog_api_client.v2.model.timeseries_anomaly_investigation_type import TimeseriesAnomalyInvestigationType

body = TimeseriesAnomalyInvestigationRequest(
data=TimeseriesAnomalyInvestigationRequestData(
attributes=TimeseriesAnomalyInvestigationRequestAttributes(
requests=[
TimeseriesAnomalyInvestigationTimeseriesRequest(
formulas=[
TimeseriesAnomalyInvestigationFormula(
formula="anomalies(query1, 'agile', 3)",
),
],
_from=1754406000000,
queries=[
TimeseriesAnomalyInvestigationMetricQuery(
data_source=TimeseriesAnomalyInvestigationDataSource.METRICS,
name="query1",
query="avg:system.cpu.user{env:prod} by {service}",
),
],
to=1754423940000,
),
],
),
type=TimeseriesAnomalyInvestigationType.TIMESERIES_ANOMALY_INVESTIGATION,
),
)

configuration = Configuration()
configuration.unstable_operations["create_timeseries_anomaly_investigation"] = True
with ApiClient(configuration) as api_client:
api_instance = TimeseriesAnomalyInvestigationsApi(api_client)
response = api_instance.create_timeseries_anomaly_investigation(body=body)

print(response)
1 change: 1 addition & 0 deletions src/datadog_api_client/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,7 @@ def __init__(
"v2.add_member_team": False,
"v2.list_member_teams": False,
"v2.remove_member_team": False,
"v2.create_timeseries_anomaly_investigation": False,
"v2.create_web_integration_account": False,
"v2.delete_web_integration_account": False,
"v2.get_web_integration_account": False,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
# This product includes software developed at Datadog (https://www.datadoghq.com/).
# Copyright 2019-Present Datadog, Inc.
from __future__ import annotations

from typing import Any, Dict

from datadog_api_client.api_client import ApiClient, Endpoint as _Endpoint
from datadog_api_client.configuration import Configuration
from datadog_api_client.v2.model.timeseries_anomaly_investigation_response import TimeseriesAnomalyInvestigationResponse
from datadog_api_client.v2.model.timeseries_anomaly_investigation_request import TimeseriesAnomalyInvestigationRequest


class TimeseriesAnomalyInvestigationsApi:
"""
Investigate metrics timeseries anomalies and return deterministic findings.
"""

def __init__(self, api_client=None):
if api_client is None:
api_client = ApiClient(Configuration())
self.api_client = api_client

self._create_timeseries_anomaly_investigation_endpoint = _Endpoint(
settings={
"response_type": (TimeseriesAnomalyInvestigationResponse,),
"auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"],
"endpoint_path": "/api/v2/timeseries-anomaly-investigations",
"operation_id": "create_timeseries_anomaly_investigation",
"http_method": "POST",
"version": "v2",
},
params_map={
"body": {
"required": True,
"openapi_types": (TimeseriesAnomalyInvestigationRequest,),
"location": "body",
},
},
headers_map={"accept": ["application/json"], "content_type": ["application/json"]},
api_client=api_client,
)

def create_timeseries_anomaly_investigation(
self,
body: TimeseriesAnomalyInvestigationRequest,
) -> TimeseriesAnomalyInvestigationResponse:
"""Investigate a timeseries anomaly.

Investigates a metrics timeseries request for its most significant anomaly and returns deterministic findings.
Metrics queries with or without grouping are supported. This API version accepts exactly one request and returns at most one anomaly.

:param body: Metrics timeseries request to investigate.
:type body: TimeseriesAnomalyInvestigationRequest
:rtype: TimeseriesAnomalyInvestigationResponse
"""
kwargs: Dict[str, Any] = {}
kwargs["body"] = body

return self._create_timeseries_anomaly_investigation_endpoint.call_with_http_info(**kwargs)
2 changes: 2 additions & 0 deletions src/datadog_api_client/v2/apis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
from datadog_api_client.v2.api.teams_api import TeamsApi
from datadog_api_client.v2.api.test_optimization_api import TestOptimizationApi
from datadog_api_client.v2.api.threat_intelligence_api import ThreatIntelligenceApi
from datadog_api_client.v2.api.timeseries_anomaly_investigations_api import TimeseriesAnomalyInvestigationsApi
from datadog_api_client.v2.api.twilio_integration_accounts_api import TwilioIntegrationAccountsApi
from datadog_api_client.v2.api.usage_metering_api import UsageMeteringApi
from datadog_api_client.v2.api.user_authorized_clients_api import UserAuthorizedClientsApi
Expand Down Expand Up @@ -287,6 +288,7 @@
"TeamsApi",
"TestOptimizationApi",
"ThreatIntelligenceApi",
"TimeseriesAnomalyInvestigationsApi",
"TwilioIntegrationAccountsApi",
"UsageMeteringApi",
"UserAuthorizedClientsApi",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
# This product includes software developed at Datadog (https://www.datadoghq.com/).
# Copyright 2019-Present Datadog, Inc.
from __future__ import annotations

from typing import List, Union, TYPE_CHECKING

from datadog_api_client.model_utils import (
ModelNormal,
cached_property,
)


if TYPE_CHECKING:
from datadog_api_client.v2.model.timeseries_anomaly_investigation_detection import (
TimeseriesAnomalyInvestigationDetection,
)
from datadog_api_client.v2.model.timeseries_anomaly_investigation_interval import (
TimeseriesAnomalyInvestigationInterval,
)
from datadog_api_client.v2.model.timeseries_anomaly_investigation_finding import (
TimeseriesAnomalyInvestigationFinding,
)
from datadog_api_client.v2.model.timeseries_anomaly_investigation_maximum_deviation import (
TimeseriesAnomalyInvestigationMaximumDeviation,
)
from datadog_api_client.v2.model.timeseries_anomaly_investigation_series import TimeseriesAnomalyInvestigationSeries
from datadog_api_client.v2.model.timeseries_anomaly_investigation_tag_analysis import (
TimeseriesAnomalyInvestigationTagAnalysis,
)
from datadog_api_client.v2.model.timeseries_anomaly_investigation_anomaly_type import (
TimeseriesAnomalyInvestigationAnomalyType,
)
from datadog_api_client.v2.model.timeseries_anomaly_investigation_influential_tag_finding import (
TimeseriesAnomalyInvestigationInfluentialTagFinding,
)
from datadog_api_client.v2.model.timeseries_anomaly_investigation_anomaly_finding import (
TimeseriesAnomalyInvestigationAnomalyFinding,
)


class TimeseriesAnomalyInvestigationAnomaly(ModelNormal):
validations = {
"findings": {
"max_items": 3,
},
}

@cached_property
def openapi_types(_):
from datadog_api_client.v2.model.timeseries_anomaly_investigation_detection import (
TimeseriesAnomalyInvestigationDetection,
)
from datadog_api_client.v2.model.timeseries_anomaly_investigation_interval import (
TimeseriesAnomalyInvestigationInterval,
)
from datadog_api_client.v2.model.timeseries_anomaly_investigation_finding import (
TimeseriesAnomalyInvestigationFinding,
)
from datadog_api_client.v2.model.timeseries_anomaly_investigation_maximum_deviation import (
TimeseriesAnomalyInvestigationMaximumDeviation,
)
from datadog_api_client.v2.model.timeseries_anomaly_investigation_series import (
TimeseriesAnomalyInvestigationSeries,
)
from datadog_api_client.v2.model.timeseries_anomaly_investigation_tag_analysis import (
TimeseriesAnomalyInvestigationTagAnalysis,
)
from datadog_api_client.v2.model.timeseries_anomaly_investigation_anomaly_type import (
TimeseriesAnomalyInvestigationAnomalyType,
)

return {
"anomaly_detection": (TimeseriesAnomalyInvestigationDetection,),
"detected_interval": (TimeseriesAnomalyInvestigationInterval,),
"display_interval": (TimeseriesAnomalyInvestigationInterval,),
"findings": ([TimeseriesAnomalyInvestigationFinding],),
"maximum_deviation": (TimeseriesAnomalyInvestigationMaximumDeviation,),
"series": (TimeseriesAnomalyInvestigationSeries,),
"tag_analysis": (TimeseriesAnomalyInvestigationTagAnalysis,),
"type": (TimeseriesAnomalyInvestigationAnomalyType,),
}

attribute_map = {
"anomaly_detection": "anomaly_detection",
"detected_interval": "detected_interval",
"display_interval": "display_interval",
"findings": "findings",
"maximum_deviation": "maximum_deviation",
"series": "series",
"tag_analysis": "tag_analysis",
"type": "type",
}

def __init__(
self_,
anomaly_detection: TimeseriesAnomalyInvestigationDetection,
detected_interval: TimeseriesAnomalyInvestigationInterval,
display_interval: TimeseriesAnomalyInvestigationInterval,
findings: List[
Union[
TimeseriesAnomalyInvestigationFinding,
TimeseriesAnomalyInvestigationInfluentialTagFinding,
TimeseriesAnomalyInvestigationAnomalyFinding,
]
],
maximum_deviation: TimeseriesAnomalyInvestigationMaximumDeviation,
series: TimeseriesAnomalyInvestigationSeries,
tag_analysis: TimeseriesAnomalyInvestigationTagAnalysis,
type: TimeseriesAnomalyInvestigationAnomalyType,
**kwargs,
):
"""
Most significant anomaly detected in the request.

:param anomaly_detection: Anomaly detection configuration used for the result.
:type anomaly_detection: TimeseriesAnomalyInvestigationDetection

:param detected_interval: Half-open time interval in milliseconds since the Unix epoch.
:type detected_interval: TimeseriesAnomalyInvestigationInterval

:param display_interval: Half-open time interval in milliseconds since the Unix epoch.
:type display_interval: TimeseriesAnomalyInvestigationInterval

:param findings: Deterministic explanations for the anomaly, ordered by importance.
:type findings: [TimeseriesAnomalyInvestigationFinding]

:param maximum_deviation: Most anomalous point within the detected interval.
:type maximum_deviation: TimeseriesAnomalyInvestigationMaximumDeviation

:param series: Logical series on which the anomaly was detected.
:type series: TimeseriesAnomalyInvestigationSeries

:param tag_analysis: Summary of optional influential-tag enrichment. Count and key fields are present only when analysis completes; enrichment availability does not affect completion of the investigation result.
:type tag_analysis: TimeseriesAnomalyInvestigationTagAnalysis

:param type: Direction of an anomaly relative to its expected range.
:type type: TimeseriesAnomalyInvestigationAnomalyType
"""
super().__init__(kwargs)

self_.anomaly_detection = anomaly_detection
self_.detected_interval = detected_interval
self_.display_interval = display_interval
self_.findings = findings
self_.maximum_deviation = maximum_deviation
self_.series = series
self_.tag_analysis = tag_analysis
self_.type = type
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
# This product includes software developed at Datadog (https://www.datadoghq.com/).
# Copyright 2019-Present Datadog, Inc.
from __future__ import annotations

from typing import TYPE_CHECKING

from datadog_api_client.model_utils import (
ModelNormal,
cached_property,
)


if TYPE_CHECKING:
from datadog_api_client.v2.model.timeseries_anomaly_investigation_anomaly_finding_type import (
TimeseriesAnomalyInvestigationAnomalyFindingType,
)


class TimeseriesAnomalyInvestigationAnomalyFinding(ModelNormal):
@cached_property
def openapi_types(_):
from datadog_api_client.v2.model.timeseries_anomaly_investigation_anomaly_finding_type import (
TimeseriesAnomalyInvestigationAnomalyFindingType,
)

return {
"description": (str,),
"headline": (str,),
"type": (TimeseriesAnomalyInvestigationAnomalyFindingType,),
}

attribute_map = {
"description": "description",
"headline": "headline",
"type": "type",
}

def __init__(
self_, description: str, headline: str, type: TimeseriesAnomalyInvestigationAnomalyFindingType, **kwargs
):
"""
Finding that describes the anomaly when completed analysis produces no displayable influential tags.

:param description: Deterministic explanation of the finding.
:type description: str

:param headline: Concise, deterministic finding title.
:type headline: str

:param type: Finding category for an anomaly without a displayable influential tag.
:type type: TimeseriesAnomalyInvestigationAnomalyFindingType
"""
super().__init__(kwargs)

self_.description = description
self_.headline = headline
self_.type = type
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
# This product includes software developed at Datadog (https://www.datadoghq.com/).
# Copyright 2019-Present Datadog, Inc.
from __future__ import annotations


from datadog_api_client.model_utils import (
ModelSimple,
cached_property,
)

from typing import ClassVar


class TimeseriesAnomalyInvestigationAnomalyFindingType(ModelSimple):
"""
Finding category for an anomaly without a displayable influential tag.

:param value: If omitted defaults to "anomaly". Must be one of ["anomaly"].
:type value: str
"""

allowed_values = {
"anomaly",
}
ANOMALY: ClassVar["TimeseriesAnomalyInvestigationAnomalyFindingType"]

@cached_property
def openapi_types(_):
return {
"value": (str,),
}


TimeseriesAnomalyInvestigationAnomalyFindingType.ANOMALY = TimeseriesAnomalyInvestigationAnomalyFindingType("anomaly")
Loading
Loading