diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 682c9d1e9b..8b58b6e874 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -119518,6 +119518,644 @@ components: $ref: '#/components/schemas/TimelineCellResource' type: array type: object + TimeseriesAnomalyInvestigationAnomaly: + description: Most significant anomaly detected in the request. + properties: + anomaly_detection: + $ref: '#/components/schemas/TimeseriesAnomalyInvestigationDetection' + detected_interval: + $ref: '#/components/schemas/TimeseriesAnomalyInvestigationInterval' + display_interval: + $ref: '#/components/schemas/TimeseriesAnomalyInvestigationInterval' + findings: + description: Deterministic explanations for the anomaly, ordered by importance. + example: [] + items: + $ref: '#/components/schemas/TimeseriesAnomalyInvestigationFinding' + maxItems: 3 + type: array + maximum_deviation: + $ref: '#/components/schemas/TimeseriesAnomalyInvestigationMaximumDeviation' + series: + $ref: '#/components/schemas/TimeseriesAnomalyInvestigationSeries' + tag_analysis: + $ref: '#/components/schemas/TimeseriesAnomalyInvestigationTagAnalysis' + type: + $ref: '#/components/schemas/TimeseriesAnomalyInvestigationAnomalyType' + required: + - series + - anomaly_detection + - detected_interval + - display_interval + - type + - maximum_deviation + - tag_analysis + - findings + type: object + TimeseriesAnomalyInvestigationAnomalyFinding: + description: Finding that describes the anomaly when completed analysis produces no displayable influential tags. + properties: + description: + description: Deterministic explanation of the finding. + example: "The service:api series rose outside its expected range." + type: string + headline: + description: Concise, deterministic finding title. + example: "An anomaly was detected on service:api" + type: string + type: + $ref: '#/components/schemas/TimeseriesAnomalyInvestigationAnomalyFindingType' + required: + - type + - headline + - description + type: object + TimeseriesAnomalyInvestigationAnomalyFindingType: + description: Finding category for an anomaly without a displayable influential tag. + enum: + - anomaly + example: anomaly + type: string + x-enum-varnames: + - ANOMALY + TimeseriesAnomalyInvestigationAnomalyType: + description: Direction of an anomaly relative to its expected range. + enum: + - spike + - dip + example: spike + type: string + x-enum-varnames: + - SPIKE + - DIP + TimeseriesAnomalyInvestigationCompleteStatus: + description: Status value indicating successful completion. + enum: + - complete + example: complete + type: string + x-enum-varnames: + - COMPLETE + TimeseriesAnomalyInvestigationConfigurationSource: + description: Source of the anomaly detection configuration. + enum: + - request_formula + - watchdog_explains_default + example: request_formula + type: string + x-enum-varnames: + - REQUEST_FORMULA + - WATCHDOG_EXPLAINS_DEFAULT + TimeseriesAnomalyInvestigationDataSource: + description: Data source for an anomaly investigation query. + enum: + - metrics + example: metrics + type: string + x-enum-varnames: + - METRICS + TimeseriesAnomalyInvestigationDetection: + description: Anomaly detection configuration used for the result. + properties: + configuration_source: + $ref: '#/components/schemas/TimeseriesAnomalyInvestigationConfigurationSource' + profile: + description: Applied Watchdog Explains profile, or null when the request supplied an explicit `anomalies()` formula. The current Watchdog profile is `watchdog_explains_v1`. + example: + nullable: true + type: string + required: + - configuration_source + - profile + type: object + TimeseriesAnomalyInvestigationFinding: + description: Deterministic explanation for a detected anomaly. + oneOf: + - $ref: '#/components/schemas/TimeseriesAnomalyInvestigationInfluentialTagFinding' + - $ref: '#/components/schemas/TimeseriesAnomalyInvestigationAnomalyFinding' + TimeseriesAnomalyInvestigationFindingSynonym: + description: Tag grouped under an influential tag by synonym analysis. + properties: + key: + description: Synonymous tag key. + example: app + type: string + values: + description: Values associated with the synonymous tag. + example: + - api + items: + description: Synonymous tag value. + example: api + type: string + type: array + required: + - key + - values + type: object + TimeseriesAnomalyInvestigationFindingTag: + description: Structured tag evidence for an influential-tag finding. + properties: + influence_type: + $ref: '#/components/schemas/TimeseriesAnomalyInvestigationInfluenceType' + key: + description: Influential tag key. + example: service + type: string + rating: + description: Influence rating from 1 through 5. + example: 5.0 + format: double + maximum: 5 + minimum: 1 + type: number + synonyms: + description: Tags grouped with this tag by Variation of Influence synonym analysis. + example: [] + items: + $ref: '#/components/schemas/TimeseriesAnomalyInvestigationFindingSynonym' + type: array + values: + description: Influential values for the tag key. + example: + - api + items: + description: Influential tag value. + example: api + type: string + type: array + required: + - key + - values + - influence_type + - rating + - synonyms + type: object + TimeseriesAnomalyInvestigationFormula: + description: Formula evaluated by the timeseries request. + properties: + formula: + description: Formula expression referencing one or more named queries. + example: "anomalies(query1, 'agile', 3)" + minLength: 1 + type: string + limit: + $ref: '#/components/schemas/TimeseriesAnomalyInvestigationFormulaLimit' + required: + - formula + type: object + TimeseriesAnomalyInvestigationFormulaLimit: + description: Optional formula limit accepted for compatibility with Timeseries API requests. Formula limits have no effect on timeseries queries. + properties: + count: + description: Requested result limit. This field has no effect on a timeseries anomaly investigation. + example: 10 + format: int64 + minimum: 0 + type: integer + order: + $ref: '#/components/schemas/TimeseriesAnomalyInvestigationFormulaLimitOrder' + type: object + TimeseriesAnomalyInvestigationFormulaLimitOrder: + description: Sort order used when applying a formula series limit. + enum: + - asc + - desc + example: desc + type: string + x-enum-varnames: + - ASC + - DESC + TimeseriesAnomalyInvestigationInfluenceType: + description: Kind of influence a tag has on a series. + enum: + - shape + - value + example: shape + type: string + x-enum-varnames: + - SHAPE + - VALUE + TimeseriesAnomalyInvestigationInfluentialTagFinding: + description: Finding that attributes an anomaly to an influential tag. + properties: + description: + description: Deterministic explanation of the finding. + example: "Filtering out service:api flattens the spike." + type: string + headline: + description: Concise, deterministic finding title. + example: "service:api is the likely cause" + type: string + tag: + $ref: '#/components/schemas/TimeseriesAnomalyInvestigationFindingTag' + type: + $ref: '#/components/schemas/TimeseriesAnomalyInvestigationInfluentialTagFindingType' + required: + - type + - headline + - description + - tag + type: object + TimeseriesAnomalyInvestigationInfluentialTagFindingType: + description: Finding category for an influential tag. + enum: + - influential_tag + example: influential_tag + type: string + x-enum-varnames: + - INFLUENTIAL_TAG + TimeseriesAnomalyInvestigationInterval: + description: Half-open time interval in milliseconds since the Unix epoch. + properties: + end: + description: Exclusive end of the interval. + example: 1754406120000 + format: int64 + type: integer + start: + description: Inclusive start of the interval. + example: 1754406060000 + format: int64 + type: integer + required: + - start + - end + type: object + TimeseriesAnomalyInvestigationMaximumDeviation: + description: Most anomalous point within the detected interval. + properties: + delta_from_boundary: + description: Absolute distance between the observed value and the nearest anomaly boundary. + example: 7.0 + format: double + minimum: 0 + type: number + timestamp: + description: Point timestamp in milliseconds since the Unix epoch. + example: 1754406090000 + format: int64 + type: integer + value: + description: Observed value at the point. + example: 42.0 + format: double + type: number + required: + - timestamp + - value + - delta_from_boundary + type: object + TimeseriesAnomalyInvestigationMetaType: + description: Response metadata type for a timeseries anomaly investigation. + enum: + - timeseries_anomaly_investigation + example: timeseries_anomaly_investigation + type: string + x-enum-varnames: + - TIMESERIES_ANOMALY_INVESTIGATION + TimeseriesAnomalyInvestigationMetricQuery: + description: Metrics query referenced by a formula. + properties: + aggregator: + description: Optional scalar aggregator accepted for request compatibility. This field is ignored for timeseries queries. + example: avg + type: string + cross_org_uuids: + description: Optional organization UUID used for a cross-organization query. Each query accepts at most one UUID; use separate queries for separate organizations. Influential-tag analysis is currently unsupported for cross-organization queries, but anomaly detection still runs. + example: + - "00000000-0000-0000-0000-000000000000" + items: + description: Organization UUID to query. + example: "00000000-0000-0000-0000-000000000000" + minLength: 1 + type: string + maxItems: 1 + type: array + data_source: + $ref: '#/components/schemas/TimeseriesAnomalyInvestigationDataSource' + name: + description: Name used to reference this query from formulas. + example: query1 + minLength: 1 + type: string + query: + description: Datadog metrics query expression. + example: "avg:system.cpu.user{env:prod} by {service}" + minLength: 1 + type: string + required: + - data_source + - name + - query + type: object + TimeseriesAnomalyInvestigationQueryExecutionStatus: + description: Current execution status for a named query. + enum: + - running + - done + example: done + type: string + x-enum-varnames: + - RUNNING + - DONE + TimeseriesAnomalyInvestigationQueryStatus: + description: Execution status for one named query. + properties: + name: + description: Query name from the request. + example: query1 + type: string + status: + $ref: '#/components/schemas/TimeseriesAnomalyInvestigationQueryExecutionStatus' + required: + - name + - status + type: object + TimeseriesAnomalyInvestigationRequest: + description: Request to investigate a metrics timeseries for anomalies. + properties: + data: + $ref: '#/components/schemas/TimeseriesAnomalyInvestigationRequestData' + required: + - data + type: object + TimeseriesAnomalyInvestigationRequestAttributes: + description: Attributes of an anomaly investigation request. + properties: + requests: + description: Timeseries requests to investigate. This API version accepts exactly one request. + example: + - formulas: + - formula: "anomalies(query1, 'agile', 3)" + from: 1754406000000 + queries: + - data_source: metrics + name: query1 + query: "avg:system.cpu.user{env:prod} by {service}" + to: 1754423940000 + items: + $ref: '#/components/schemas/TimeseriesAnomalyInvestigationTimeseriesRequest' + maxItems: 1 + minItems: 1 + type: array + required: + - requests + type: object + TimeseriesAnomalyInvestigationRequestData: + description: JSON:API resource containing an anomaly investigation request. + properties: + attributes: + $ref: '#/components/schemas/TimeseriesAnomalyInvestigationRequestAttributes' + type: + $ref: '#/components/schemas/TimeseriesAnomalyInvestigationType' + required: + - type + - attributes + type: object + TimeseriesAnomalyInvestigationResponse: + description: Response containing the anomaly investigation results and timeseries metadata. + properties: + data: + $ref: '#/components/schemas/TimeseriesAnomalyInvestigationResponseData' + meta: + $ref: '#/components/schemas/TimeseriesAnomalyInvestigationResponseMeta' + required: + - data + - meta + type: object + TimeseriesAnomalyInvestigationResponseAttributes: + description: Attributes of an anomaly investigation response. + properties: + results: + description: Results returned in the same order as the submitted requests. This API version returns exactly one result. + example: + - anomalies: [] + status: complete + items: + $ref: '#/components/schemas/TimeseriesAnomalyInvestigationResult' + maxItems: 1 + minItems: 1 + type: array + required: + - results + type: object + TimeseriesAnomalyInvestigationResponseData: + description: JSON:API resource containing anomaly investigation results. + properties: + attributes: + $ref: '#/components/schemas/TimeseriesAnomalyInvestigationResponseAttributes' + id: + $ref: '#/components/schemas/TimeseriesAnomalyInvestigationResponseID' + type: + $ref: '#/components/schemas/TimeseriesAnomalyInvestigationType' + required: + - id + - type + - attributes + type: object + TimeseriesAnomalyInvestigationResponseID: + description: Stable identifier for an anomaly investigation response resource. + enum: + - "0" + example: "0" + type: string + x-enum-varnames: + - ZERO + TimeseriesAnomalyInvestigationResponseMeta: + description: Timeseries execution metadata for the single request accepted by this API version. + properties: + from_date: + description: Effective start of the timeseries query in milliseconds since the Unix epoch. + example: 1754406000000 + format: int64 + type: integer + interval: + description: Effective timeseries interval in milliseconds. + example: 60000 + format: int64 + minimum: 1 + type: integer + queries: + description: Execution status for the request's queries. + example: + - name: query1 + status: done + items: + $ref: '#/components/schemas/TimeseriesAnomalyInvestigationQueryStatus' + type: array + res_type: + $ref: '#/components/schemas/TimeseriesAnomalyInvestigationMetaType' + results_warnings: + description: Non-fatal warnings produced while executing the investigation. + example: [] + items: + $ref: '#/components/schemas/TimeseriesAnomalyInvestigationResultsWarning' + type: array + to_date: + description: Effective end of the timeseries query in milliseconds since the Unix epoch. + example: 1754423940000 + format: int64 + type: integer + required: + - from_date + - to_date + - interval + - queries + - results_warnings + - res_type + type: object + TimeseriesAnomalyInvestigationResult: + description: Completed result for one timeseries request. The anomalies array is empty when no qualifying anomaly is found. + properties: + anomalies: + description: Detected anomalies. This API version returns at most one anomaly. + example: [] + items: + $ref: '#/components/schemas/TimeseriesAnomalyInvestigationAnomaly' + maxItems: 1 + type: array + status: + $ref: '#/components/schemas/TimeseriesAnomalyInvestigationCompleteStatus' + required: + - status + - anomalies + type: object + TimeseriesAnomalyInvestigationResultsWarning: + description: Non-fatal warning produced while executing the investigation. + properties: + message: + description: Human-readable warning message. + example: "Influential tag analysis failed for at least one detected anomaly." + type: string + name: + description: Machine-readable warning name. + example: tag_analysis_failed + type: string + required: + - name + - message + type: object + TimeseriesAnomalyInvestigationSeries: + description: Logical series on which the anomaly was detected. + properties: + group_tags: + description: Tags identifying the selected group. Empty for a query without grouping. + example: + - "service:api" + items: + description: Tag in `key:value` form. + example: "service:api" + type: string + type: array + label: + description: Display label for the selected series. + example: api + type: string + query_index: + description: Zero-based index of the caller's formula that produced the series. + example: 0 + format: int64 + minimum: 0 + type: integer + required: + - query_index + - group_tags + - label + type: object + TimeseriesAnomalyInvestigationTagAnalysis: + description: 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. + properties: + analyzed_tag_keys: + description: Tag keys analyzed. Present only when analysis completes. + example: + - service + - env + items: + description: Analyzed tag key. + example: service + type: string + type: array + status: + $ref: '#/components/schemas/TimeseriesAnomalyInvestigationTagAnalysisStatus' + tag_keys_analyzed: + description: Number of tag keys analyzed. Present only when analysis completes. + example: 2 + format: int64 + minimum: 0 + type: integer + tag_values_analyzed: + description: Number of tag values analyzed. Present only when analysis completes. + example: 4 + format: int64 + minimum: 0 + type: integer + required: + - status + type: object + TimeseriesAnomalyInvestigationTagAnalysisStatus: + description: Outcome of optional influential-tag enrichment. + enum: + - complete + - unsupported + - failed + example: complete + type: string + x-enum-varnames: + - COMPLETE + - UNSUPPORTED + - FAILED + TimeseriesAnomalyInvestigationTimeseriesRequest: + description: Metrics timeseries request to investigate. + properties: + formulas: + description: Formulas to evaluate. Each formula may contain an explicit `anomalies()` call or a supported metrics expression. + example: + - formula: "anomalies(query1, 'agile', 3)" + items: + $ref: '#/components/schemas/TimeseriesAnomalyInvestigationFormula' + minItems: 1 + type: array + from: + description: Start of the investigation time window in milliseconds since the Unix epoch. + example: 1754406000000 + format: int64 + type: integer + interval: + description: Optional requested aggregation interval in milliseconds. + example: 60000 + format: int64 + minimum: 1 + type: integer + queries: + description: Metrics queries referenced by the formulas. + example: + - data_source: metrics + name: query1 + query: "avg:system.cpu.user{env:prod} by {service}" + items: + $ref: '#/components/schemas/TimeseriesAnomalyInvestigationMetricQuery' + minItems: 1 + type: array + to: + description: End of the investigation time window in milliseconds since the Unix epoch. Must be later than `from`. + example: 1754423940000 + format: int64 + type: integer + required: + - formulas + - from + - to + - queries + type: object + TimeseriesAnomalyInvestigationType: + description: Resource type for a timeseries anomaly investigation. + enum: + - timeseries_anomaly_investigation + example: timeseries_anomaly_investigation + type: string + x-enum-varnames: + - TIMESERIES_ANOMALY_INVESTIGATION TimeseriesFormulaQueryRequest: description: A request wrapper around a single timeseries query to be executed. properties: @@ -219358,6 +219996,141 @@ paths: operator: OR permissions: - test_optimization_read + /api/v2/timeseries-anomaly-investigations: + post: + description: |- + 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. + operationId: CreateTimeseriesAnomalyInvestigation + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + requests: + - formulas: + - formula: "anomalies(query1, 'agile', 3)" + from: 1754406000000 + queries: + - data_source: metrics + name: query1 + query: "avg:system.cpu.user{env:prod} by {service}" + to: 1754423940000 + type: timeseries_anomaly_investigation + schema: + $ref: '#/components/schemas/TimeseriesAnomalyInvestigationRequest' + description: Metrics timeseries request to investigate. + required: true + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + results: + - anomalies: + - anomaly_detection: + configuration_source: request_formula + profile: + detected_interval: + end: 1754406120000 + start: 1754406060000 + display_interval: + end: 1754406150000 + start: 1754406030000 + findings: + - description: "Filtering out service:api flattens the spike." + headline: "service:api is the likely cause" + tag: + influence_type: shape + key: service + rating: 5.0 + synonyms: [] + values: + - api + type: influential_tag + maximum_deviation: + delta_from_boundary: 7.0 + timestamp: 1754406090000 + value: 42.0 + series: + group_tags: + - "service:api" + label: api + query_index: 0 + tag_analysis: + analyzed_tag_keys: + - service + - env + status: complete + tag_keys_analyzed: 2 + tag_values_analyzed: 4 + type: spike + status: complete + id: "0" + type: timeseries_anomaly_investigation + meta: + from_date: 1754406000000 + interval: 60000 + queries: + - name: query1 + status: done + res_type: timeseries_anomaly_investigation + results_warnings: [] + to_date: 1754423940000 + schema: + $ref: '#/components/schemas/TimeseriesAnomalyInvestigationResponse' + description: OK + "400": + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + "401": + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Unauthorized + "403": + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + "422": + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Unprocessable Entity + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - timeseries_query + - metrics_read + summary: Investigate a timeseries anomaly + tags: + - Timeseries Anomaly Investigations + x-codegen-request-body-name: body + x-permission: + operator: AND + permissions: + - timeseries_query + - metrics_read + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). /api/v2/trace/{trace_id}: get: description: |- @@ -223722,6 +224495,8 @@ tags: name: Test Optimization - description: Ingest and manage threat intelligence data for security enrichment and investigation. name: Threat Intelligence + - description: Investigate metrics timeseries anomalies and return deterministic findings. + name: Timeseries Anomaly Investigations - description: |- Manage your Datadog Twilio integration accounts directly through the Datadog API. Create, update, and delete accounts, configure authentication and settings, and diff --git a/examples/v2/timeseries-anomaly-investigations/CreateTimeseriesAnomalyInvestigation.py b/examples/v2/timeseries-anomaly-investigations/CreateTimeseriesAnomalyInvestigation.py new file mode 100644 index 0000000000..1b997a8a7f --- /dev/null +++ b/examples/v2/timeseries-anomaly-investigations/CreateTimeseriesAnomalyInvestigation.py @@ -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) diff --git a/src/datadog_api_client/configuration.py b/src/datadog_api_client/configuration.py index 0afdd78e66..4fab15a8a2 100644 --- a/src/datadog_api_client/configuration.py +++ b/src/datadog_api_client/configuration.py @@ -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, diff --git a/src/datadog_api_client/v2/api/timeseries_anomaly_investigations_api.py b/src/datadog_api_client/v2/api/timeseries_anomaly_investigations_api.py new file mode 100644 index 0000000000..91f70f3051 --- /dev/null +++ b/src/datadog_api_client/v2/api/timeseries_anomaly_investigations_api.py @@ -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) diff --git a/src/datadog_api_client/v2/apis/__init__.py b/src/datadog_api_client/v2/apis/__init__.py index d27b2ec854..58fc2414ac 100644 --- a/src/datadog_api_client/v2/apis/__init__.py +++ b/src/datadog_api_client/v2/apis/__init__.py @@ -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 @@ -287,6 +288,7 @@ "TeamsApi", "TestOptimizationApi", "ThreatIntelligenceApi", + "TimeseriesAnomalyInvestigationsApi", "TwilioIntegrationAccountsApi", "UsageMeteringApi", "UserAuthorizedClientsApi", diff --git a/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_anomaly.py b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_anomaly.py new file mode 100644 index 0000000000..779cdee4dd --- /dev/null +++ b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_anomaly.py @@ -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 diff --git a/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_anomaly_finding.py b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_anomaly_finding.py new file mode 100644 index 0000000000..f3452916ad --- /dev/null +++ b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_anomaly_finding.py @@ -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 diff --git a/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_anomaly_finding_type.py b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_anomaly_finding_type.py new file mode 100644 index 0000000000..ab67d04c0c --- /dev/null +++ b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_anomaly_finding_type.py @@ -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") diff --git a/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_anomaly_type.py b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_anomaly_type.py new file mode 100644 index 0000000000..ea7476bafd --- /dev/null +++ b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_anomaly_type.py @@ -0,0 +1,38 @@ +# 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 TimeseriesAnomalyInvestigationAnomalyType(ModelSimple): + """ + Direction of an anomaly relative to its expected range. + + :param value: Must be one of ["spike", "dip"]. + :type value: str + """ + + allowed_values = { + "spike", + "dip", + } + SPIKE: ClassVar["TimeseriesAnomalyInvestigationAnomalyType"] + DIP: ClassVar["TimeseriesAnomalyInvestigationAnomalyType"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +TimeseriesAnomalyInvestigationAnomalyType.SPIKE = TimeseriesAnomalyInvestigationAnomalyType("spike") +TimeseriesAnomalyInvestigationAnomalyType.DIP = TimeseriesAnomalyInvestigationAnomalyType("dip") diff --git a/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_complete_status.py b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_complete_status.py new file mode 100644 index 0000000000..3757e8a9a3 --- /dev/null +++ b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_complete_status.py @@ -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 TimeseriesAnomalyInvestigationCompleteStatus(ModelSimple): + """ + Status value indicating successful completion. + + :param value: If omitted defaults to "complete". Must be one of ["complete"]. + :type value: str + """ + + allowed_values = { + "complete", + } + COMPLETE: ClassVar["TimeseriesAnomalyInvestigationCompleteStatus"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +TimeseriesAnomalyInvestigationCompleteStatus.COMPLETE = TimeseriesAnomalyInvestigationCompleteStatus("complete") diff --git a/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_configuration_source.py b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_configuration_source.py new file mode 100644 index 0000000000..2fe8eb7afd --- /dev/null +++ b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_configuration_source.py @@ -0,0 +1,42 @@ +# 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 TimeseriesAnomalyInvestigationConfigurationSource(ModelSimple): + """ + Source of the anomaly detection configuration. + + :param value: Must be one of ["request_formula", "watchdog_explains_default"]. + :type value: str + """ + + allowed_values = { + "request_formula", + "watchdog_explains_default", + } + REQUEST_FORMULA: ClassVar["TimeseriesAnomalyInvestigationConfigurationSource"] + WATCHDOG_EXPLAINS_DEFAULT: ClassVar["TimeseriesAnomalyInvestigationConfigurationSource"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +TimeseriesAnomalyInvestigationConfigurationSource.REQUEST_FORMULA = TimeseriesAnomalyInvestigationConfigurationSource( + "request_formula" +) +TimeseriesAnomalyInvestigationConfigurationSource.WATCHDOG_EXPLAINS_DEFAULT = ( + TimeseriesAnomalyInvestigationConfigurationSource("watchdog_explains_default") +) diff --git a/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_data_source.py b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_data_source.py new file mode 100644 index 0000000000..03cc490d09 --- /dev/null +++ b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_data_source.py @@ -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 TimeseriesAnomalyInvestigationDataSource(ModelSimple): + """ + Data source for an anomaly investigation query. + + :param value: If omitted defaults to "metrics". Must be one of ["metrics"]. + :type value: str + """ + + allowed_values = { + "metrics", + } + METRICS: ClassVar["TimeseriesAnomalyInvestigationDataSource"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +TimeseriesAnomalyInvestigationDataSource.METRICS = TimeseriesAnomalyInvestigationDataSource("metrics") diff --git a/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_detection.py b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_detection.py new file mode 100644 index 0000000000..3aded35874 --- /dev/null +++ b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_detection.py @@ -0,0 +1,56 @@ +# 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 Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + none_type, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.timeseries_anomaly_investigation_configuration_source import ( + TimeseriesAnomalyInvestigationConfigurationSource, + ) + + +class TimeseriesAnomalyInvestigationDetection(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.timeseries_anomaly_investigation_configuration_source import ( + TimeseriesAnomalyInvestigationConfigurationSource, + ) + + return { + "configuration_source": (TimeseriesAnomalyInvestigationConfigurationSource,), + "profile": (str, none_type), + } + + attribute_map = { + "configuration_source": "configuration_source", + "profile": "profile", + } + + def __init__( + self_, + configuration_source: TimeseriesAnomalyInvestigationConfigurationSource, + profile: Union[str, none_type], + **kwargs, + ): + """ + Anomaly detection configuration used for the result. + + :param configuration_source: Source of the anomaly detection configuration. + :type configuration_source: TimeseriesAnomalyInvestigationConfigurationSource + + :param profile: Applied Watchdog Explains profile, or null when the request supplied an explicit ``anomalies()`` formula. The current Watchdog profile is ``watchdog_explains_v1``. + :type profile: str, none_type + """ + super().__init__(kwargs) + + self_.configuration_source = configuration_source + self_.profile = profile diff --git a/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_finding.py b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_finding.py new file mode 100644 index 0000000000..4b1c334d16 --- /dev/null +++ b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_finding.py @@ -0,0 +1,53 @@ +# 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 ( + ModelComposed, + cached_property, +) + + +class TimeseriesAnomalyInvestigationFinding(ModelComposed): + def __init__(self, **kwargs): + """ + Deterministic explanation for a detected anomaly. + + :param description: Deterministic explanation of the finding. + :type description: str + + :param headline: Concise, deterministic finding title. + :type headline: str + + :param tag: Structured tag evidence for an influential-tag finding. + :type tag: TimeseriesAnomalyInvestigationFindingTag + + :param type: Finding category for an influential tag. + :type type: TimeseriesAnomalyInvestigationInfluentialTagFindingType + """ + super().__init__(kwargs) + + @cached_property + def _composed_schemas(_): + # we need this here to make our import statements work + # we must store _composed_schemas in here so the code is only run + # when we invoke this method. If we kept this at the class + # level we would get an error because the class level + # code would be run when this module is imported, and these composed + # classes don't exist yet because their module has not finished + # loading + 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, + ) + + return { + "oneOf": [ + TimeseriesAnomalyInvestigationInfluentialTagFinding, + TimeseriesAnomalyInvestigationAnomalyFinding, + ], + } diff --git a/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_finding_synonym.py b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_finding_synonym.py new file mode 100644 index 0000000000..6512c4a86d --- /dev/null +++ b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_finding_synonym.py @@ -0,0 +1,40 @@ +# 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 + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +class TimeseriesAnomalyInvestigationFindingSynonym(ModelNormal): + @cached_property + def openapi_types(_): + return { + "key": (str,), + "values": ([str],), + } + + attribute_map = { + "key": "key", + "values": "values", + } + + def __init__(self_, key: str, values: List[str], **kwargs): + """ + Tag grouped under an influential tag by synonym analysis. + + :param key: Synonymous tag key. + :type key: str + + :param values: Values associated with the synonymous tag. + :type values: [str] + """ + super().__init__(kwargs) + + self_.key = key + self_.values = values diff --git a/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_finding_tag.py b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_finding_tag.py new file mode 100644 index 0000000000..450e7f6670 --- /dev/null +++ b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_finding_tag.py @@ -0,0 +1,89 @@ +# 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, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.timeseries_anomaly_investigation_influence_type import ( + TimeseriesAnomalyInvestigationInfluenceType, + ) + from datadog_api_client.v2.model.timeseries_anomaly_investigation_finding_synonym import ( + TimeseriesAnomalyInvestigationFindingSynonym, + ) + + +class TimeseriesAnomalyInvestigationFindingTag(ModelNormal): + validations = { + "rating": { + "inclusive_maximum": 5, + "inclusive_minimum": 1, + }, + } + + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.timeseries_anomaly_investigation_influence_type import ( + TimeseriesAnomalyInvestigationInfluenceType, + ) + from datadog_api_client.v2.model.timeseries_anomaly_investigation_finding_synonym import ( + TimeseriesAnomalyInvestigationFindingSynonym, + ) + + return { + "influence_type": (TimeseriesAnomalyInvestigationInfluenceType,), + "key": (str,), + "rating": (float,), + "synonyms": ([TimeseriesAnomalyInvestigationFindingSynonym],), + "values": ([str],), + } + + attribute_map = { + "influence_type": "influence_type", + "key": "key", + "rating": "rating", + "synonyms": "synonyms", + "values": "values", + } + + def __init__( + self_, + influence_type: TimeseriesAnomalyInvestigationInfluenceType, + key: str, + rating: float, + synonyms: List[TimeseriesAnomalyInvestigationFindingSynonym], + values: List[str], + **kwargs, + ): + """ + Structured tag evidence for an influential-tag finding. + + :param influence_type: Kind of influence a tag has on a series. + :type influence_type: TimeseriesAnomalyInvestigationInfluenceType + + :param key: Influential tag key. + :type key: str + + :param rating: Influence rating from 1 through 5. + :type rating: float + + :param synonyms: Tags grouped with this tag by Variation of Influence synonym analysis. + :type synonyms: [TimeseriesAnomalyInvestigationFindingSynonym] + + :param values: Influential values for the tag key. + :type values: [str] + """ + super().__init__(kwargs) + + self_.influence_type = influence_type + self_.key = key + self_.rating = rating + self_.synonyms = synonyms + self_.values = values diff --git a/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_formula.py b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_formula.py new file mode 100644 index 0000000000..d577a35312 --- /dev/null +++ b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_formula.py @@ -0,0 +1,61 @@ +# 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 Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.timeseries_anomaly_investigation_formula_limit import ( + TimeseriesAnomalyInvestigationFormulaLimit, + ) + + +class TimeseriesAnomalyInvestigationFormula(ModelNormal): + validations = { + "formula": { + "min_length": 1, + }, + } + + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.timeseries_anomaly_investigation_formula_limit import ( + TimeseriesAnomalyInvestigationFormulaLimit, + ) + + return { + "formula": (str,), + "limit": (TimeseriesAnomalyInvestigationFormulaLimit,), + } + + attribute_map = { + "formula": "formula", + "limit": "limit", + } + + def __init__( + self_, formula: str, limit: Union[TimeseriesAnomalyInvestigationFormulaLimit, UnsetType] = unset, **kwargs + ): + """ + Formula evaluated by the timeseries request. + + :param formula: Formula expression referencing one or more named queries. + :type formula: str + + :param limit: Optional formula limit accepted for compatibility with Timeseries API requests. Formula limits have no effect on timeseries queries. + :type limit: TimeseriesAnomalyInvestigationFormulaLimit, optional + """ + if limit is not unset: + kwargs["limit"] = limit + super().__init__(kwargs) + + self_.formula = formula diff --git a/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_formula_limit.py b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_formula_limit.py new file mode 100644 index 0000000000..3f343b0b30 --- /dev/null +++ b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_formula_limit.py @@ -0,0 +1,64 @@ +# 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 Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.timeseries_anomaly_investigation_formula_limit_order import ( + TimeseriesAnomalyInvestigationFormulaLimitOrder, + ) + + +class TimeseriesAnomalyInvestigationFormulaLimit(ModelNormal): + validations = { + "count": { + "inclusive_minimum": 0, + }, + } + + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.timeseries_anomaly_investigation_formula_limit_order import ( + TimeseriesAnomalyInvestigationFormulaLimitOrder, + ) + + return { + "count": (int,), + "order": (TimeseriesAnomalyInvestigationFormulaLimitOrder,), + } + + attribute_map = { + "count": "count", + "order": "order", + } + + def __init__( + self_, + count: Union[int, UnsetType] = unset, + order: Union[TimeseriesAnomalyInvestigationFormulaLimitOrder, UnsetType] = unset, + **kwargs, + ): + """ + Optional formula limit accepted for compatibility with Timeseries API requests. Formula limits have no effect on timeseries queries. + + :param count: Requested result limit. This field has no effect on a timeseries anomaly investigation. + :type count: int, optional + + :param order: Sort order used when applying a formula series limit. + :type order: TimeseriesAnomalyInvestigationFormulaLimitOrder, optional + """ + if count is not unset: + kwargs["count"] = count + if order is not unset: + kwargs["order"] = order + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_formula_limit_order.py b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_formula_limit_order.py new file mode 100644 index 0000000000..fe624f1227 --- /dev/null +++ b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_formula_limit_order.py @@ -0,0 +1,38 @@ +# 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 TimeseriesAnomalyInvestigationFormulaLimitOrder(ModelSimple): + """ + Sort order used when applying a formula series limit. + + :param value: Must be one of ["asc", "desc"]. + :type value: str + """ + + allowed_values = { + "asc", + "desc", + } + ASC: ClassVar["TimeseriesAnomalyInvestigationFormulaLimitOrder"] + DESC: ClassVar["TimeseriesAnomalyInvestigationFormulaLimitOrder"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +TimeseriesAnomalyInvestigationFormulaLimitOrder.ASC = TimeseriesAnomalyInvestigationFormulaLimitOrder("asc") +TimeseriesAnomalyInvestigationFormulaLimitOrder.DESC = TimeseriesAnomalyInvestigationFormulaLimitOrder("desc") diff --git a/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_influence_type.py b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_influence_type.py new file mode 100644 index 0000000000..6f7933e84a --- /dev/null +++ b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_influence_type.py @@ -0,0 +1,38 @@ +# 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 TimeseriesAnomalyInvestigationInfluenceType(ModelSimple): + """ + Kind of influence a tag has on a series. + + :param value: Must be one of ["shape", "value"]. + :type value: str + """ + + allowed_values = { + "shape", + "value", + } + SHAPE: ClassVar["TimeseriesAnomalyInvestigationInfluenceType"] + VALUE: ClassVar["TimeseriesAnomalyInvestigationInfluenceType"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +TimeseriesAnomalyInvestigationInfluenceType.SHAPE = TimeseriesAnomalyInvestigationInfluenceType("shape") +TimeseriesAnomalyInvestigationInfluenceType.VALUE = TimeseriesAnomalyInvestigationInfluenceType("value") diff --git a/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_influential_tag_finding.py b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_influential_tag_finding.py new file mode 100644 index 0000000000..35de2a316a --- /dev/null +++ b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_influential_tag_finding.py @@ -0,0 +1,75 @@ +# 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_finding_tag import ( + TimeseriesAnomalyInvestigationFindingTag, + ) + from datadog_api_client.v2.model.timeseries_anomaly_investigation_influential_tag_finding_type import ( + TimeseriesAnomalyInvestigationInfluentialTagFindingType, + ) + + +class TimeseriesAnomalyInvestigationInfluentialTagFinding(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.timeseries_anomaly_investigation_finding_tag import ( + TimeseriesAnomalyInvestigationFindingTag, + ) + from datadog_api_client.v2.model.timeseries_anomaly_investigation_influential_tag_finding_type import ( + TimeseriesAnomalyInvestigationInfluentialTagFindingType, + ) + + return { + "description": (str,), + "headline": (str,), + "tag": (TimeseriesAnomalyInvestigationFindingTag,), + "type": (TimeseriesAnomalyInvestigationInfluentialTagFindingType,), + } + + attribute_map = { + "description": "description", + "headline": "headline", + "tag": "tag", + "type": "type", + } + + def __init__( + self_, + description: str, + headline: str, + tag: TimeseriesAnomalyInvestigationFindingTag, + type: TimeseriesAnomalyInvestigationInfluentialTagFindingType, + **kwargs, + ): + """ + Finding that attributes an anomaly to an influential tag. + + :param description: Deterministic explanation of the finding. + :type description: str + + :param headline: Concise, deterministic finding title. + :type headline: str + + :param tag: Structured tag evidence for an influential-tag finding. + :type tag: TimeseriesAnomalyInvestigationFindingTag + + :param type: Finding category for an influential tag. + :type type: TimeseriesAnomalyInvestigationInfluentialTagFindingType + """ + super().__init__(kwargs) + + self_.description = description + self_.headline = headline + self_.tag = tag + self_.type = type diff --git a/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_influential_tag_finding_type.py b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_influential_tag_finding_type.py new file mode 100644 index 0000000000..3c265aac2c --- /dev/null +++ b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_influential_tag_finding_type.py @@ -0,0 +1,37 @@ +# 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 TimeseriesAnomalyInvestigationInfluentialTagFindingType(ModelSimple): + """ + Finding category for an influential tag. + + :param value: If omitted defaults to "influential_tag". Must be one of ["influential_tag"]. + :type value: str + """ + + allowed_values = { + "influential_tag", + } + INFLUENTIAL_TAG: ClassVar["TimeseriesAnomalyInvestigationInfluentialTagFindingType"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +TimeseriesAnomalyInvestigationInfluentialTagFindingType.INFLUENTIAL_TAG = ( + TimeseriesAnomalyInvestigationInfluentialTagFindingType("influential_tag") +) diff --git a/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_interval.py b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_interval.py new file mode 100644 index 0000000000..b74f66c4ec --- /dev/null +++ b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_interval.py @@ -0,0 +1,39 @@ +# 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 ( + ModelNormal, + cached_property, +) + + +class TimeseriesAnomalyInvestigationInterval(ModelNormal): + @cached_property + def openapi_types(_): + return { + "end": (int,), + "start": (int,), + } + + attribute_map = { + "end": "end", + "start": "start", + } + + def __init__(self_, end: int, start: int, **kwargs): + """ + Half-open time interval in milliseconds since the Unix epoch. + + :param end: Exclusive end of the interval. + :type end: int + + :param start: Inclusive start of the interval. + :type start: int + """ + super().__init__(kwargs) + + self_.end = end + self_.start = start diff --git a/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_maximum_deviation.py b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_maximum_deviation.py new file mode 100644 index 0000000000..6dbdb9dde1 --- /dev/null +++ b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_maximum_deviation.py @@ -0,0 +1,51 @@ +# 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 ( + ModelNormal, + cached_property, +) + + +class TimeseriesAnomalyInvestigationMaximumDeviation(ModelNormal): + validations = { + "delta_from_boundary": { + "inclusive_minimum": 0, + }, + } + + @cached_property + def openapi_types(_): + return { + "delta_from_boundary": (float,), + "timestamp": (int,), + "value": (float,), + } + + attribute_map = { + "delta_from_boundary": "delta_from_boundary", + "timestamp": "timestamp", + "value": "value", + } + + def __init__(self_, delta_from_boundary: float, timestamp: int, value: float, **kwargs): + """ + Most anomalous point within the detected interval. + + :param delta_from_boundary: Absolute distance between the observed value and the nearest anomaly boundary. + :type delta_from_boundary: float + + :param timestamp: Point timestamp in milliseconds since the Unix epoch. + :type timestamp: int + + :param value: Observed value at the point. + :type value: float + """ + super().__init__(kwargs) + + self_.delta_from_boundary = delta_from_boundary + self_.timestamp = timestamp + self_.value = value diff --git a/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_meta_type.py b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_meta_type.py new file mode 100644 index 0000000000..d38a9f379d --- /dev/null +++ b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_meta_type.py @@ -0,0 +1,37 @@ +# 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 TimeseriesAnomalyInvestigationMetaType(ModelSimple): + """ + Response metadata type for a timeseries anomaly investigation. + + :param value: If omitted defaults to "timeseries_anomaly_investigation". Must be one of ["timeseries_anomaly_investigation"]. + :type value: str + """ + + allowed_values = { + "timeseries_anomaly_investigation", + } + TIMESERIES_ANOMALY_INVESTIGATION: ClassVar["TimeseriesAnomalyInvestigationMetaType"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +TimeseriesAnomalyInvestigationMetaType.TIMESERIES_ANOMALY_INVESTIGATION = TimeseriesAnomalyInvestigationMetaType( + "timeseries_anomaly_investigation" +) diff --git a/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_metric_query.py b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_metric_query.py new file mode 100644 index 0000000000..23d67e7231 --- /dev/null +++ b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_metric_query.py @@ -0,0 +1,92 @@ +# 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, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.timeseries_anomaly_investigation_data_source import ( + TimeseriesAnomalyInvestigationDataSource, + ) + + +class TimeseriesAnomalyInvestigationMetricQuery(ModelNormal): + validations = { + "cross_org_uuids": { + "max_items": 1, + }, + "name": { + "min_length": 1, + }, + "query": { + "min_length": 1, + }, + } + + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.timeseries_anomaly_investigation_data_source import ( + TimeseriesAnomalyInvestigationDataSource, + ) + + return { + "aggregator": (str,), + "cross_org_uuids": ([str],), + "data_source": (TimeseriesAnomalyInvestigationDataSource,), + "name": (str,), + "query": (str,), + } + + attribute_map = { + "aggregator": "aggregator", + "cross_org_uuids": "cross_org_uuids", + "data_source": "data_source", + "name": "name", + "query": "query", + } + + def __init__( + self_, + data_source: TimeseriesAnomalyInvestigationDataSource, + name: str, + query: str, + aggregator: Union[str, UnsetType] = unset, + cross_org_uuids: Union[List[str], UnsetType] = unset, + **kwargs, + ): + """ + Metrics query referenced by a formula. + + :param aggregator: Optional scalar aggregator accepted for request compatibility. This field is ignored for timeseries queries. + :type aggregator: str, optional + + :param cross_org_uuids: Optional organization UUID used for a cross-organization query. Each query accepts at most one UUID; use separate queries for separate organizations. Influential-tag analysis is currently unsupported for cross-organization queries, but anomaly detection still runs. + :type cross_org_uuids: [str], optional + + :param data_source: Data source for an anomaly investigation query. + :type data_source: TimeseriesAnomalyInvestigationDataSource + + :param name: Name used to reference this query from formulas. + :type name: str + + :param query: Datadog metrics query expression. + :type query: str + """ + if aggregator is not unset: + kwargs["aggregator"] = aggregator + if cross_org_uuids is not unset: + kwargs["cross_org_uuids"] = cross_org_uuids + super().__init__(kwargs) + + self_.data_source = data_source + self_.name = name + self_.query = query diff --git a/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_query_execution_status.py b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_query_execution_status.py new file mode 100644 index 0000000000..aabbb07e41 --- /dev/null +++ b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_query_execution_status.py @@ -0,0 +1,40 @@ +# 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 TimeseriesAnomalyInvestigationQueryExecutionStatus(ModelSimple): + """ + Current execution status for a named query. + + :param value: Must be one of ["running", "done"]. + :type value: str + """ + + allowed_values = { + "running", + "done", + } + RUNNING: ClassVar["TimeseriesAnomalyInvestigationQueryExecutionStatus"] + DONE: ClassVar["TimeseriesAnomalyInvestigationQueryExecutionStatus"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +TimeseriesAnomalyInvestigationQueryExecutionStatus.RUNNING = TimeseriesAnomalyInvestigationQueryExecutionStatus( + "running" +) +TimeseriesAnomalyInvestigationQueryExecutionStatus.DONE = TimeseriesAnomalyInvestigationQueryExecutionStatus("done") diff --git a/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_query_status.py b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_query_status.py new file mode 100644 index 0000000000..7b6faf0935 --- /dev/null +++ b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_query_status.py @@ -0,0 +1,50 @@ +# 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_query_execution_status import ( + TimeseriesAnomalyInvestigationQueryExecutionStatus, + ) + + +class TimeseriesAnomalyInvestigationQueryStatus(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.timeseries_anomaly_investigation_query_execution_status import ( + TimeseriesAnomalyInvestigationQueryExecutionStatus, + ) + + return { + "name": (str,), + "status": (TimeseriesAnomalyInvestigationQueryExecutionStatus,), + } + + attribute_map = { + "name": "name", + "status": "status", + } + + def __init__(self_, name: str, status: TimeseriesAnomalyInvestigationQueryExecutionStatus, **kwargs): + """ + Execution status for one named query. + + :param name: Query name from the request. + :type name: str + + :param status: Current execution status for a named query. + :type status: TimeseriesAnomalyInvestigationQueryExecutionStatus + """ + super().__init__(kwargs) + + self_.name = name + self_.status = status diff --git a/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_request.py b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_request.py new file mode 100644 index 0000000000..bb2f981f98 --- /dev/null +++ b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_request.py @@ -0,0 +1,44 @@ +# 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_request_data import ( + TimeseriesAnomalyInvestigationRequestData, + ) + + +class TimeseriesAnomalyInvestigationRequest(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.timeseries_anomaly_investigation_request_data import ( + TimeseriesAnomalyInvestigationRequestData, + ) + + return { + "data": (TimeseriesAnomalyInvestigationRequestData,), + } + + attribute_map = { + "data": "data", + } + + def __init__(self_, data: TimeseriesAnomalyInvestigationRequestData, **kwargs): + """ + Request to investigate a metrics timeseries for anomalies. + + :param data: JSON:API resource containing an anomaly investigation request. + :type data: TimeseriesAnomalyInvestigationRequestData + """ + super().__init__(kwargs) + + self_.data = data diff --git a/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_request_attributes.py b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_request_attributes.py new file mode 100644 index 0000000000..a06059cdfe --- /dev/null +++ b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_request_attributes.py @@ -0,0 +1,51 @@ +# 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, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.timeseries_anomaly_investigation_timeseries_request import ( + TimeseriesAnomalyInvestigationTimeseriesRequest, + ) + + +class TimeseriesAnomalyInvestigationRequestAttributes(ModelNormal): + validations = { + "requests": { + "max_items": 1, + "min_items": 1, + }, + } + + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.timeseries_anomaly_investigation_timeseries_request import ( + TimeseriesAnomalyInvestigationTimeseriesRequest, + ) + + return { + "requests": ([TimeseriesAnomalyInvestigationTimeseriesRequest],), + } + + attribute_map = { + "requests": "requests", + } + + def __init__(self_, requests: List[TimeseriesAnomalyInvestigationTimeseriesRequest], **kwargs): + """ + Attributes of an anomaly investigation request. + + :param requests: Timeseries requests to investigate. This API version accepts exactly one request. + :type requests: [TimeseriesAnomalyInvestigationTimeseriesRequest] + """ + super().__init__(kwargs) + + self_.requests = requests diff --git a/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_request_data.py b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_request_data.py new file mode 100644 index 0000000000..75c56b8a11 --- /dev/null +++ b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_request_data.py @@ -0,0 +1,57 @@ +# 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_request_attributes import ( + TimeseriesAnomalyInvestigationRequestAttributes, + ) + from datadog_api_client.v2.model.timeseries_anomaly_investigation_type import TimeseriesAnomalyInvestigationType + + +class TimeseriesAnomalyInvestigationRequestData(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.timeseries_anomaly_investigation_request_attributes import ( + TimeseriesAnomalyInvestigationRequestAttributes, + ) + from datadog_api_client.v2.model.timeseries_anomaly_investigation_type import TimeseriesAnomalyInvestigationType + + return { + "attributes": (TimeseriesAnomalyInvestigationRequestAttributes,), + "type": (TimeseriesAnomalyInvestigationType,), + } + + attribute_map = { + "attributes": "attributes", + "type": "type", + } + + def __init__( + self_, + attributes: TimeseriesAnomalyInvestigationRequestAttributes, + type: TimeseriesAnomalyInvestigationType, + **kwargs, + ): + """ + JSON:API resource containing an anomaly investigation request. + + :param attributes: Attributes of an anomaly investigation request. + :type attributes: TimeseriesAnomalyInvestigationRequestAttributes + + :param type: Resource type for a timeseries anomaly investigation. + :type type: TimeseriesAnomalyInvestigationType + """ + super().__init__(kwargs) + + self_.attributes = attributes + self_.type = type diff --git a/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_response.py b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_response.py new file mode 100644 index 0000000000..2a9d4d3d6c --- /dev/null +++ b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_response.py @@ -0,0 +1,61 @@ +# 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_response_data import ( + TimeseriesAnomalyInvestigationResponseData, + ) + from datadog_api_client.v2.model.timeseries_anomaly_investigation_response_meta import ( + TimeseriesAnomalyInvestigationResponseMeta, + ) + + +class TimeseriesAnomalyInvestigationResponse(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.timeseries_anomaly_investigation_response_data import ( + TimeseriesAnomalyInvestigationResponseData, + ) + from datadog_api_client.v2.model.timeseries_anomaly_investigation_response_meta import ( + TimeseriesAnomalyInvestigationResponseMeta, + ) + + return { + "data": (TimeseriesAnomalyInvestigationResponseData,), + "meta": (TimeseriesAnomalyInvestigationResponseMeta,), + } + + attribute_map = { + "data": "data", + "meta": "meta", + } + + def __init__( + self_, + data: TimeseriesAnomalyInvestigationResponseData, + meta: TimeseriesAnomalyInvestigationResponseMeta, + **kwargs, + ): + """ + Response containing the anomaly investigation results and timeseries metadata. + + :param data: JSON:API resource containing anomaly investigation results. + :type data: TimeseriesAnomalyInvestigationResponseData + + :param meta: Timeseries execution metadata for the single request accepted by this API version. + :type meta: TimeseriesAnomalyInvestigationResponseMeta + """ + super().__init__(kwargs) + + self_.data = data + self_.meta = meta diff --git a/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_response_attributes.py b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_response_attributes.py new file mode 100644 index 0000000000..b5ddddcb56 --- /dev/null +++ b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_response_attributes.py @@ -0,0 +1,49 @@ +# 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, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.timeseries_anomaly_investigation_result import TimeseriesAnomalyInvestigationResult + + +class TimeseriesAnomalyInvestigationResponseAttributes(ModelNormal): + validations = { + "results": { + "max_items": 1, + "min_items": 1, + }, + } + + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.timeseries_anomaly_investigation_result import ( + TimeseriesAnomalyInvestigationResult, + ) + + return { + "results": ([TimeseriesAnomalyInvestigationResult],), + } + + attribute_map = { + "results": "results", + } + + def __init__(self_, results: List[TimeseriesAnomalyInvestigationResult], **kwargs): + """ + Attributes of an anomaly investigation response. + + :param results: Results returned in the same order as the submitted requests. This API version returns exactly one result. + :type results: [TimeseriesAnomalyInvestigationResult] + """ + super().__init__(kwargs) + + self_.results = results diff --git a/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_response_data.py b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_response_data.py new file mode 100644 index 0000000000..0fd940d6a6 --- /dev/null +++ b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_response_data.py @@ -0,0 +1,70 @@ +# 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_response_attributes import ( + TimeseriesAnomalyInvestigationResponseAttributes, + ) + from datadog_api_client.v2.model.timeseries_anomaly_investigation_response_id import ( + TimeseriesAnomalyInvestigationResponseID, + ) + from datadog_api_client.v2.model.timeseries_anomaly_investigation_type import TimeseriesAnomalyInvestigationType + + +class TimeseriesAnomalyInvestigationResponseData(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.timeseries_anomaly_investigation_response_attributes import ( + TimeseriesAnomalyInvestigationResponseAttributes, + ) + from datadog_api_client.v2.model.timeseries_anomaly_investigation_response_id import ( + TimeseriesAnomalyInvestigationResponseID, + ) + from datadog_api_client.v2.model.timeseries_anomaly_investigation_type import TimeseriesAnomalyInvestigationType + + return { + "attributes": (TimeseriesAnomalyInvestigationResponseAttributes,), + "id": (TimeseriesAnomalyInvestigationResponseID,), + "type": (TimeseriesAnomalyInvestigationType,), + } + + attribute_map = { + "attributes": "attributes", + "id": "id", + "type": "type", + } + + def __init__( + self_, + attributes: TimeseriesAnomalyInvestigationResponseAttributes, + id: TimeseriesAnomalyInvestigationResponseID, + type: TimeseriesAnomalyInvestigationType, + **kwargs, + ): + """ + JSON:API resource containing anomaly investigation results. + + :param attributes: Attributes of an anomaly investigation response. + :type attributes: TimeseriesAnomalyInvestigationResponseAttributes + + :param id: Stable identifier for an anomaly investigation response resource. + :type id: TimeseriesAnomalyInvestigationResponseID + + :param type: Resource type for a timeseries anomaly investigation. + :type type: TimeseriesAnomalyInvestigationType + """ + super().__init__(kwargs) + + self_.attributes = attributes + self_.id = id + self_.type = type diff --git a/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_response_id.py b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_response_id.py new file mode 100644 index 0000000000..aab1933102 --- /dev/null +++ b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_response_id.py @@ -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 TimeseriesAnomalyInvestigationResponseID(ModelSimple): + """ + Stable identifier for an anomaly investigation response resource. + + :param value: If omitted defaults to "0". Must be one of ["0"]. + :type value: str + """ + + allowed_values = { + "0", + } + ZERO: ClassVar["TimeseriesAnomalyInvestigationResponseID"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +TimeseriesAnomalyInvestigationResponseID.ZERO = TimeseriesAnomalyInvestigationResponseID("0") diff --git a/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_response_meta.py b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_response_meta.py new file mode 100644 index 0000000000..10140650bc --- /dev/null +++ b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_response_meta.py @@ -0,0 +1,101 @@ +# 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, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.timeseries_anomaly_investigation_query_status import ( + TimeseriesAnomalyInvestigationQueryStatus, + ) + from datadog_api_client.v2.model.timeseries_anomaly_investigation_meta_type import ( + TimeseriesAnomalyInvestigationMetaType, + ) + from datadog_api_client.v2.model.timeseries_anomaly_investigation_results_warning import ( + TimeseriesAnomalyInvestigationResultsWarning, + ) + + +class TimeseriesAnomalyInvestigationResponseMeta(ModelNormal): + validations = { + "interval": { + "inclusive_minimum": 1, + }, + } + + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.timeseries_anomaly_investigation_query_status import ( + TimeseriesAnomalyInvestigationQueryStatus, + ) + from datadog_api_client.v2.model.timeseries_anomaly_investigation_meta_type import ( + TimeseriesAnomalyInvestigationMetaType, + ) + from datadog_api_client.v2.model.timeseries_anomaly_investigation_results_warning import ( + TimeseriesAnomalyInvestigationResultsWarning, + ) + + return { + "from_date": (int,), + "interval": (int,), + "queries": ([TimeseriesAnomalyInvestigationQueryStatus],), + "res_type": (TimeseriesAnomalyInvestigationMetaType,), + "results_warnings": ([TimeseriesAnomalyInvestigationResultsWarning],), + "to_date": (int,), + } + + attribute_map = { + "from_date": "from_date", + "interval": "interval", + "queries": "queries", + "res_type": "res_type", + "results_warnings": "results_warnings", + "to_date": "to_date", + } + + def __init__( + self_, + from_date: int, + interval: int, + queries: List[TimeseriesAnomalyInvestigationQueryStatus], + res_type: TimeseriesAnomalyInvestigationMetaType, + results_warnings: List[TimeseriesAnomalyInvestigationResultsWarning], + to_date: int, + **kwargs, + ): + """ + Timeseries execution metadata for the single request accepted by this API version. + + :param from_date: Effective start of the timeseries query in milliseconds since the Unix epoch. + :type from_date: int + + :param interval: Effective timeseries interval in milliseconds. + :type interval: int + + :param queries: Execution status for the request's queries. + :type queries: [TimeseriesAnomalyInvestigationQueryStatus] + + :param res_type: Response metadata type for a timeseries anomaly investigation. + :type res_type: TimeseriesAnomalyInvestigationMetaType + + :param results_warnings: Non-fatal warnings produced while executing the investigation. + :type results_warnings: [TimeseriesAnomalyInvestigationResultsWarning] + + :param to_date: Effective end of the timeseries query in milliseconds since the Unix epoch. + :type to_date: int + """ + super().__init__(kwargs) + + self_.from_date = from_date + self_.interval = interval + self_.queries = queries + self_.res_type = res_type + self_.results_warnings = results_warnings + self_.to_date = to_date diff --git a/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_result.py b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_result.py new file mode 100644 index 0000000000..33fbd3eaf2 --- /dev/null +++ b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_result.py @@ -0,0 +1,67 @@ +# 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, 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 import ( + TimeseriesAnomalyInvestigationAnomaly, + ) + from datadog_api_client.v2.model.timeseries_anomaly_investigation_complete_status import ( + TimeseriesAnomalyInvestigationCompleteStatus, + ) + + +class TimeseriesAnomalyInvestigationResult(ModelNormal): + validations = { + "anomalies": { + "max_items": 1, + }, + } + + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.timeseries_anomaly_investigation_anomaly import ( + TimeseriesAnomalyInvestigationAnomaly, + ) + from datadog_api_client.v2.model.timeseries_anomaly_investigation_complete_status import ( + TimeseriesAnomalyInvestigationCompleteStatus, + ) + + return { + "anomalies": ([TimeseriesAnomalyInvestigationAnomaly],), + "status": (TimeseriesAnomalyInvestigationCompleteStatus,), + } + + attribute_map = { + "anomalies": "anomalies", + "status": "status", + } + + def __init__( + self_, + anomalies: List[TimeseriesAnomalyInvestigationAnomaly], + status: TimeseriesAnomalyInvestigationCompleteStatus, + **kwargs, + ): + """ + Completed result for one timeseries request. The anomalies array is empty when no qualifying anomaly is found. + + :param anomalies: Detected anomalies. This API version returns at most one anomaly. + :type anomalies: [TimeseriesAnomalyInvestigationAnomaly] + + :param status: Status value indicating successful completion. + :type status: TimeseriesAnomalyInvestigationCompleteStatus + """ + super().__init__(kwargs) + + self_.anomalies = anomalies + self_.status = status diff --git a/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_results_warning.py b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_results_warning.py new file mode 100644 index 0000000000..9da92b17fb --- /dev/null +++ b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_results_warning.py @@ -0,0 +1,39 @@ +# 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 ( + ModelNormal, + cached_property, +) + + +class TimeseriesAnomalyInvestigationResultsWarning(ModelNormal): + @cached_property + def openapi_types(_): + return { + "message": (str,), + "name": (str,), + } + + attribute_map = { + "message": "message", + "name": "name", + } + + def __init__(self_, message: str, name: str, **kwargs): + """ + Non-fatal warning produced while executing the investigation. + + :param message: Human-readable warning message. + :type message: str + + :param name: Machine-readable warning name. + :type name: str + """ + super().__init__(kwargs) + + self_.message = message + self_.name = name diff --git a/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_series.py b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_series.py new file mode 100644 index 0000000000..87e219dff8 --- /dev/null +++ b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_series.py @@ -0,0 +1,52 @@ +# 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 + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +class TimeseriesAnomalyInvestigationSeries(ModelNormal): + validations = { + "query_index": { + "inclusive_minimum": 0, + }, + } + + @cached_property + def openapi_types(_): + return { + "group_tags": ([str],), + "label": (str,), + "query_index": (int,), + } + + attribute_map = { + "group_tags": "group_tags", + "label": "label", + "query_index": "query_index", + } + + def __init__(self_, group_tags: List[str], label: str, query_index: int, **kwargs): + """ + Logical series on which the anomaly was detected. + + :param group_tags: Tags identifying the selected group. Empty for a query without grouping. + :type group_tags: [str] + + :param label: Display label for the selected series. + :type label: str + + :param query_index: Zero-based index of the caller's formula that produced the series. + :type query_index: int + """ + super().__init__(kwargs) + + self_.group_tags = group_tags + self_.label = label + self_.query_index = query_index diff --git a/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_tag_analysis.py b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_tag_analysis.py new file mode 100644 index 0000000000..a989628b76 --- /dev/null +++ b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_tag_analysis.py @@ -0,0 +1,83 @@ +# 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, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.timeseries_anomaly_investigation_tag_analysis_status import ( + TimeseriesAnomalyInvestigationTagAnalysisStatus, + ) + + +class TimeseriesAnomalyInvestigationTagAnalysis(ModelNormal): + validations = { + "tag_keys_analyzed": { + "inclusive_minimum": 0, + }, + "tag_values_analyzed": { + "inclusive_minimum": 0, + }, + } + + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.timeseries_anomaly_investigation_tag_analysis_status import ( + TimeseriesAnomalyInvestigationTagAnalysisStatus, + ) + + return { + "analyzed_tag_keys": ([str],), + "status": (TimeseriesAnomalyInvestigationTagAnalysisStatus,), + "tag_keys_analyzed": (int,), + "tag_values_analyzed": (int,), + } + + attribute_map = { + "analyzed_tag_keys": "analyzed_tag_keys", + "status": "status", + "tag_keys_analyzed": "tag_keys_analyzed", + "tag_values_analyzed": "tag_values_analyzed", + } + + def __init__( + self_, + status: TimeseriesAnomalyInvestigationTagAnalysisStatus, + analyzed_tag_keys: Union[List[str], UnsetType] = unset, + tag_keys_analyzed: Union[int, UnsetType] = unset, + tag_values_analyzed: Union[int, UnsetType] = unset, + **kwargs, + ): + """ + 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. + + :param analyzed_tag_keys: Tag keys analyzed. Present only when analysis completes. + :type analyzed_tag_keys: [str], optional + + :param status: Outcome of optional influential-tag enrichment. + :type status: TimeseriesAnomalyInvestigationTagAnalysisStatus + + :param tag_keys_analyzed: Number of tag keys analyzed. Present only when analysis completes. + :type tag_keys_analyzed: int, optional + + :param tag_values_analyzed: Number of tag values analyzed. Present only when analysis completes. + :type tag_values_analyzed: int, optional + """ + if analyzed_tag_keys is not unset: + kwargs["analyzed_tag_keys"] = analyzed_tag_keys + if tag_keys_analyzed is not unset: + kwargs["tag_keys_analyzed"] = tag_keys_analyzed + if tag_values_analyzed is not unset: + kwargs["tag_values_analyzed"] = tag_values_analyzed + super().__init__(kwargs) + + self_.status = status diff --git a/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_tag_analysis_status.py b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_tag_analysis_status.py new file mode 100644 index 0000000000..007d0ef384 --- /dev/null +++ b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_tag_analysis_status.py @@ -0,0 +1,43 @@ +# 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 TimeseriesAnomalyInvestigationTagAnalysisStatus(ModelSimple): + """ + Outcome of optional influential-tag enrichment. + + :param value: Must be one of ["complete", "unsupported", "failed"]. + :type value: str + """ + + allowed_values = { + "complete", + "unsupported", + "failed", + } + COMPLETE: ClassVar["TimeseriesAnomalyInvestigationTagAnalysisStatus"] + UNSUPPORTED: ClassVar["TimeseriesAnomalyInvestigationTagAnalysisStatus"] + FAILED: ClassVar["TimeseriesAnomalyInvestigationTagAnalysisStatus"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +TimeseriesAnomalyInvestigationTagAnalysisStatus.COMPLETE = TimeseriesAnomalyInvestigationTagAnalysisStatus("complete") +TimeseriesAnomalyInvestigationTagAnalysisStatus.UNSUPPORTED = TimeseriesAnomalyInvestigationTagAnalysisStatus( + "unsupported" +) +TimeseriesAnomalyInvestigationTagAnalysisStatus.FAILED = TimeseriesAnomalyInvestigationTagAnalysisStatus("failed") diff --git a/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_timeseries_request.py b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_timeseries_request.py new file mode 100644 index 0000000000..c59fa7c98c --- /dev/null +++ b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_timeseries_request.py @@ -0,0 +1,97 @@ +# 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, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + 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, + ) + + +class TimeseriesAnomalyInvestigationTimeseriesRequest(ModelNormal): + validations = { + "formulas": { + "min_items": 1, + }, + "interval": { + "inclusive_minimum": 1, + }, + "queries": { + "min_items": 1, + }, + } + + @cached_property + def openapi_types(_): + 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, + ) + + return { + "formulas": ([TimeseriesAnomalyInvestigationFormula],), + "_from": (int,), + "interval": (int,), + "queries": ([TimeseriesAnomalyInvestigationMetricQuery],), + "to": (int,), + } + + attribute_map = { + "formulas": "formulas", + "_from": "from", + "interval": "interval", + "queries": "queries", + "to": "to", + } + + def __init__( + self_, + formulas: List[TimeseriesAnomalyInvestigationFormula], + _from: int, + queries: List[TimeseriesAnomalyInvestigationMetricQuery], + to: int, + interval: Union[int, UnsetType] = unset, + **kwargs, + ): + """ + Metrics timeseries request to investigate. + + :param formulas: Formulas to evaluate. Each formula may contain an explicit ``anomalies()`` call or a supported metrics expression. + :type formulas: [TimeseriesAnomalyInvestigationFormula] + + :param _from: Start of the investigation time window in milliseconds since the Unix epoch. + :type _from: int + + :param interval: Optional requested aggregation interval in milliseconds. + :type interval: int, optional + + :param queries: Metrics queries referenced by the formulas. + :type queries: [TimeseriesAnomalyInvestigationMetricQuery] + + :param to: End of the investigation time window in milliseconds since the Unix epoch. Must be later than ``from``. + :type to: int + """ + if interval is not unset: + kwargs["interval"] = interval + super().__init__(kwargs) + + self_.formulas = formulas + self_._from = _from + self_.queries = queries + self_.to = to diff --git a/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_type.py b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_type.py new file mode 100644 index 0000000000..22b9daf12c --- /dev/null +++ b/src/datadog_api_client/v2/model/timeseries_anomaly_investigation_type.py @@ -0,0 +1,37 @@ +# 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 TimeseriesAnomalyInvestigationType(ModelSimple): + """ + Resource type for a timeseries anomaly investigation. + + :param value: If omitted defaults to "timeseries_anomaly_investigation". Must be one of ["timeseries_anomaly_investigation"]. + :type value: str + """ + + allowed_values = { + "timeseries_anomaly_investigation", + } + TIMESERIES_ANOMALY_INVESTIGATION: ClassVar["TimeseriesAnomalyInvestigationType"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +TimeseriesAnomalyInvestigationType.TIMESERIES_ANOMALY_INVESTIGATION = TimeseriesAnomalyInvestigationType( + "timeseries_anomaly_investigation" +) diff --git a/src/datadog_api_client/v2/models/__init__.py b/src/datadog_api_client/v2/models/__init__.py index 6e882ce1c4..d2a7bb7a9d 100644 --- a/src/datadog_api_client/v2/models/__init__.py +++ b/src/datadog_api_client/v2/models/__init__.py @@ -10714,6 +10714,102 @@ from datadog_api_client.v2.model.timeline_cell_resource_type import TimelineCellResourceType from datadog_api_client.v2.model.timeline_cell_type import TimelineCellType from datadog_api_client.v2.model.timeline_response import TimelineResponse +from datadog_api_client.v2.model.timeseries_anomaly_investigation_anomaly import TimeseriesAnomalyInvestigationAnomaly +from datadog_api_client.v2.model.timeseries_anomaly_investigation_anomaly_finding import ( + TimeseriesAnomalyInvestigationAnomalyFinding, +) +from datadog_api_client.v2.model.timeseries_anomaly_investigation_anomaly_finding_type import ( + TimeseriesAnomalyInvestigationAnomalyFindingType, +) +from datadog_api_client.v2.model.timeseries_anomaly_investigation_anomaly_type import ( + TimeseriesAnomalyInvestigationAnomalyType, +) +from datadog_api_client.v2.model.timeseries_anomaly_investigation_complete_status import ( + TimeseriesAnomalyInvestigationCompleteStatus, +) +from datadog_api_client.v2.model.timeseries_anomaly_investigation_configuration_source import ( + TimeseriesAnomalyInvestigationConfigurationSource, +) +from datadog_api_client.v2.model.timeseries_anomaly_investigation_data_source import ( + TimeseriesAnomalyInvestigationDataSource, +) +from datadog_api_client.v2.model.timeseries_anomaly_investigation_detection import ( + TimeseriesAnomalyInvestigationDetection, +) +from datadog_api_client.v2.model.timeseries_anomaly_investigation_finding import TimeseriesAnomalyInvestigationFinding +from datadog_api_client.v2.model.timeseries_anomaly_investigation_finding_synonym import ( + TimeseriesAnomalyInvestigationFindingSynonym, +) +from datadog_api_client.v2.model.timeseries_anomaly_investigation_finding_tag import ( + TimeseriesAnomalyInvestigationFindingTag, +) +from datadog_api_client.v2.model.timeseries_anomaly_investigation_formula import TimeseriesAnomalyInvestigationFormula +from datadog_api_client.v2.model.timeseries_anomaly_investigation_formula_limit import ( + TimeseriesAnomalyInvestigationFormulaLimit, +) +from datadog_api_client.v2.model.timeseries_anomaly_investigation_formula_limit_order import ( + TimeseriesAnomalyInvestigationFormulaLimitOrder, +) +from datadog_api_client.v2.model.timeseries_anomaly_investigation_influence_type import ( + TimeseriesAnomalyInvestigationInfluenceType, +) +from datadog_api_client.v2.model.timeseries_anomaly_investigation_influential_tag_finding import ( + TimeseriesAnomalyInvestigationInfluentialTagFinding, +) +from datadog_api_client.v2.model.timeseries_anomaly_investigation_influential_tag_finding_type import ( + TimeseriesAnomalyInvestigationInfluentialTagFindingType, +) +from datadog_api_client.v2.model.timeseries_anomaly_investigation_interval import TimeseriesAnomalyInvestigationInterval +from datadog_api_client.v2.model.timeseries_anomaly_investigation_maximum_deviation import ( + TimeseriesAnomalyInvestigationMaximumDeviation, +) +from datadog_api_client.v2.model.timeseries_anomaly_investigation_meta_type import ( + TimeseriesAnomalyInvestigationMetaType, +) +from datadog_api_client.v2.model.timeseries_anomaly_investigation_metric_query import ( + TimeseriesAnomalyInvestigationMetricQuery, +) +from datadog_api_client.v2.model.timeseries_anomaly_investigation_query_execution_status import ( + TimeseriesAnomalyInvestigationQueryExecutionStatus, +) +from datadog_api_client.v2.model.timeseries_anomaly_investigation_query_status import ( + TimeseriesAnomalyInvestigationQueryStatus, +) +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_response import TimeseriesAnomalyInvestigationResponse +from datadog_api_client.v2.model.timeseries_anomaly_investigation_response_attributes import ( + TimeseriesAnomalyInvestigationResponseAttributes, +) +from datadog_api_client.v2.model.timeseries_anomaly_investigation_response_data import ( + TimeseriesAnomalyInvestigationResponseData, +) +from datadog_api_client.v2.model.timeseries_anomaly_investigation_response_id import ( + TimeseriesAnomalyInvestigationResponseID, +) +from datadog_api_client.v2.model.timeseries_anomaly_investigation_response_meta import ( + TimeseriesAnomalyInvestigationResponseMeta, +) +from datadog_api_client.v2.model.timeseries_anomaly_investigation_result import TimeseriesAnomalyInvestigationResult +from datadog_api_client.v2.model.timeseries_anomaly_investigation_results_warning import ( + TimeseriesAnomalyInvestigationResultsWarning, +) +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_tag_analysis_status import ( + TimeseriesAnomalyInvestigationTagAnalysisStatus, +) +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 from datadog_api_client.v2.model.timeseries_formula_query_request import TimeseriesFormulaQueryRequest from datadog_api_client.v2.model.timeseries_formula_query_response import TimeseriesFormulaQueryResponse from datadog_api_client.v2.model.timeseries_formula_request import TimeseriesFormulaRequest @@ -18673,6 +18769,44 @@ "TimelineCellResourceType", "TimelineCellType", "TimelineResponse", + "TimeseriesAnomalyInvestigationAnomaly", + "TimeseriesAnomalyInvestigationAnomalyFinding", + "TimeseriesAnomalyInvestigationAnomalyFindingType", + "TimeseriesAnomalyInvestigationAnomalyType", + "TimeseriesAnomalyInvestigationCompleteStatus", + "TimeseriesAnomalyInvestigationConfigurationSource", + "TimeseriesAnomalyInvestigationDataSource", + "TimeseriesAnomalyInvestigationDetection", + "TimeseriesAnomalyInvestigationFinding", + "TimeseriesAnomalyInvestigationFindingSynonym", + "TimeseriesAnomalyInvestigationFindingTag", + "TimeseriesAnomalyInvestigationFormula", + "TimeseriesAnomalyInvestigationFormulaLimit", + "TimeseriesAnomalyInvestigationFormulaLimitOrder", + "TimeseriesAnomalyInvestigationInfluenceType", + "TimeseriesAnomalyInvestigationInfluentialTagFinding", + "TimeseriesAnomalyInvestigationInfluentialTagFindingType", + "TimeseriesAnomalyInvestigationInterval", + "TimeseriesAnomalyInvestigationMaximumDeviation", + "TimeseriesAnomalyInvestigationMetaType", + "TimeseriesAnomalyInvestigationMetricQuery", + "TimeseriesAnomalyInvestigationQueryExecutionStatus", + "TimeseriesAnomalyInvestigationQueryStatus", + "TimeseriesAnomalyInvestigationRequest", + "TimeseriesAnomalyInvestigationRequestAttributes", + "TimeseriesAnomalyInvestigationRequestData", + "TimeseriesAnomalyInvestigationResponse", + "TimeseriesAnomalyInvestigationResponseAttributes", + "TimeseriesAnomalyInvestigationResponseData", + "TimeseriesAnomalyInvestigationResponseID", + "TimeseriesAnomalyInvestigationResponseMeta", + "TimeseriesAnomalyInvestigationResult", + "TimeseriesAnomalyInvestigationResultsWarning", + "TimeseriesAnomalyInvestigationSeries", + "TimeseriesAnomalyInvestigationTagAnalysis", + "TimeseriesAnomalyInvestigationTagAnalysisStatus", + "TimeseriesAnomalyInvestigationTimeseriesRequest", + "TimeseriesAnomalyInvestigationType", "TimeseriesFormulaQueryRequest", "TimeseriesFormulaQueryResponse", "TimeseriesFormulaRequest", diff --git a/tests/v2/features/timeseries_anomaly_investigations.feature b/tests/v2/features/timeseries_anomaly_investigations.feature new file mode 100644 index 0000000000..78dfb223cb --- /dev/null +++ b/tests/v2/features/timeseries_anomaly_investigations.feature @@ -0,0 +1,27 @@ +@endpoint(timeseries-anomaly-investigations) @endpoint(timeseries-anomaly-investigations-v2) +Feature: Timeseries Anomaly Investigations + Investigate metrics timeseries anomalies and return deterministic + findings. + + Background: + Given a valid "apiKeyAuth" key in the system + And a valid "appKeyAuth" key in the system + And an instance of "TimeseriesAnomalyInvestigations" API + And operation "CreateTimeseriesAnomalyInvestigation" enabled + And new "CreateTimeseriesAnomalyInvestigation" request + And body with value {"data": {"attributes": {"requests": [{"formulas": [{"formula": "anomalies(query1, 'agile', 3)"}], "from": 1754406000000, "queries": [{"data_source": "metrics", "name": "query1", "query": "avg:system.cpu.user{env:prod} by {service}"}], "to": 1754423940000}]}, "type": "timeseries_anomaly_investigation"}} + + @generated @skip @team:DataDog/dataviz-backend-maintainers + Scenario: Investigate a timeseries anomaly returns "Bad Request" response + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/dataviz-backend-maintainers + Scenario: Investigate a timeseries anomaly returns "OK" response + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/dataviz-backend-maintainers + Scenario: Investigate a timeseries anomaly returns "Unprocessable Entity" response + When the request is sent + Then the response status is 422 Unprocessable Entity diff --git a/tests/v2/features/undo.json b/tests/v2/features/undo.json index 960023eb2f..a0b26605ec 100644 --- a/tests/v2/features/undo.json +++ b/tests/v2/features/undo.json @@ -10116,6 +10116,12 @@ "type": "safe" } }, + "CreateTimeseriesAnomalyInvestigation": { + "tag": "Timeseries Anomaly Investigations", + "undo": { + "type": "safe" + } + }, "GetTraceByID": { "tag": "APM Trace", "undo": {