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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 52 additions & 12 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12338,33 +12338,73 @@ components:
type: object
SLOCountDefinition:
description: 'A count-based (metric) SLI specification, composed of three parts:
the good events formula, the total events formula,
the good events formula,

and the underlying queries.'
the bad or total events formula, and the underlying queries.

Exactly one of `total_events_formula` or `bad_events_formula` must be provided.'
example:
good_events_formula: query1 - query2
bad_events_formula: query2
good_events_formula: query1
queries:
- data_source: metrics
name: query1
query: sum:trace.servlet.request.hits{*} by {env}.as_count()
query: sum:trace.servlet.request.hits{!http.status_code:500} by {env}.as_count()
- data_source: metrics
name: query2
query: sum:trace.servlet.request.errors{*} by {env}.as_count()
total_events_formula: query1
query: sum:trace.servlet.request.hits{http.status_code:500} by {env}.as_count()
oneOf:
- $ref: '#/components/schemas/SLOCountDefinitionWithTotalEventsFormula'
- $ref: '#/components/schemas/SLOCountDefinitionWithBadEventsFormula'
SLOCountDefinitionWithBadEventsFormula:
additionalProperties: false
properties:
bad_events_formula:
$ref: '#/components/schemas/SLOFormula'
description: The bad events formula (recommended). Total events queries
can be defined using the `total_events_formula` field as an alternative.
Only one of `total_events_formula` or `bad_events_formula` must be provided.
good_events_formula:
$ref: '#/components/schemas/SLOFormula'
queries:
example:
- data_source: metrics
name: query1
query: sum:trace.servlet.request.hits{*} by {env}.as_count()
query: sum:trace.servlet.request.hits{!http.status_code:500} by {env}.as_count()
- data_source: metrics
name: query2
query: sum:trace.servlet.request.hits{http.status_code:500} by {env}.as_count()
items:
$ref: '#/components/schemas/SLODataSourceQueryDefinition'
minItems: 1
type: array
required:
- good_events_formula
- bad_events_formula
- queries
type: object
SLOCountDefinitionWithTotalEventsFormula:
additionalProperties: false
properties:
good_events_formula:
$ref: '#/components/schemas/SLOFormula'
queries:
example:
- data_source: metrics
name: query1
query: sum:trace.servlet.request.hits{!http.status_code:500} by {env}.as_count()
- data_source: metrics
name: query2
query: sum:trace.servlet.request.hits{http.status_code:500} by {env}.as_count()
items:
$ref: '#/components/schemas/SLODataSourceQueryDefinition'
minItems: 1
type: array
total_events_formula:
$ref: '#/components/schemas/SLOFormula'
description: The total events formula. Bad events queries can be defined
using the `bad_events_formula` field as an alternative. Only one of `total_events_formula`
or `bad_events_formula` must be provided.
required:
- good_events_formula
- total_events_formula
Expand All @@ -12375,15 +12415,15 @@ components:
description: A metric SLI specification.
example:
count:
good_events_formula: query1 - query2
bad_events_formula: query2
good_events_formula: query1
queries:
- data_source: metrics
name: query1
query: sum:trace.servlet.request.hits{*} by {env}.as_count()
query: sum:trace.servlet.request.hits{!http.status_code:500} by {env}.as_count()
- data_source: metrics
name: query2
query: sum:trace.servlet.request.errors{*} by {env}.as_count()
total_events_formula: query1
query: sum:trace.servlet.request.hits{http.status_code:500} by {env}.as_count()
properties:
count:
$ref: '#/components/schemas/SLOCountDefinition'
Expand Down Expand Up @@ -13519,7 +13559,7 @@ components:
name: query1
query: sum:trace.servlet.request.hits{*} by {env}.as_count()
- data_source: metrics
name: query1
name: query2
query: sum:trace.servlet.request.errors{*} by {env}.as_count()
threshold: 5
properties:
Expand Down
5 changes: 5 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42913,6 +42913,11 @@ components:

**Supported pipeline types:** logs, metrics'
properties:
address_key:
description: Name of the environment variable or secret that holds the listen
address for the Datadog Agent source.
example: DATADOG_AGENT_ADDRESS
type: string
id:
description: The unique identifier for this component. Used in other parts
of the pipeline to reference this component (for example, as the `input`
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"2026-02-25T17:45:38.518Z"
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
{
"log": {
"_recordingName": "Service Level Objectives/Create a new metric SLO object using bad events formula returns \"OK\" response",
"creator": {
"comment": "persister:fs",
"name": "Polly.JS",
"version": "6.0.5"
},
"entries": [
{
"_id": "d5693d5eee1eafa788d069277375e5d9",
"_order": 0,
"cache": {},
"request": {
"bodySize": 690,
"cookies": [],
"headers": [
{
"_fromType": "array",
"name": "accept",
"value": "application/json"
},
{
"_fromType": "array",
"name": "content-type",
"value": "application/json"
}
],
"headersSize": 547,
"httpVersion": "HTTP/1.1",
"method": "POST",
"postData": {
"mimeType": "application/json",
"params": [],
"text": "{\"description\":\"Metric SLO using sli_specification\",\"name\":\"Test-Create_a_new_metric_SLO_object_using_bad_events_formula_returns_OK_response-1772041538\",\"sli_specification\":{\"count\":{\"bad_events_formula\":{\"formula\":\"query2\"},\"good_events_formula\":{\"formula\":\"query1 - query2\"},\"queries\":[{\"data_source\":\"metrics\",\"name\":\"query1\",\"query\":\"sum:httpservice.hits{*}.as_count()\"},{\"data_source\":\"metrics\",\"name\":\"query2\",\"query\":\"sum:httpservice.errors{*}.as_count()\"}]}},\"tags\":[\"env:prod\",\"type:count\"],\"target_threshold\":99,\"thresholds\":[{\"target\":99,\"target_display\":\"99.0\",\"timeframe\":\"7d\",\"warning\":99.5,\"warning_display\":\"99.5\"}],\"timeframe\":\"7d\",\"type\":\"metric\",\"warning_threshold\":99.5}"
},
"queryString": [],
"url": "https://api.datadoghq.com/api/v1/slo"
},
"response": {
"bodySize": 1196,
"content": {
"mimeType": "application/json",
"size": 1196,
"text": "{\"data\":[{\"id\":\"7309ff3752fd519f80f65a2ed3247dbb\",\"name\":\"Test-Create_a_new_metric_SLO_object_using_bad_events_formula_returns_OK_response-1772041538\",\"tags\":[\"env:prod\",\"type:count\"],\"monitor_tags\":[],\"thresholds\":[{\"timeframe\":\"7d\",\"target\":99.0,\"target_display\":\"99.\",\"warning\":99.5,\"warning_display\":\"99.5\"}],\"type\":\"metric\",\"type_id\":1,\"description\":\"Metric SLO using sli_specification\",\"timeframe\":\"7d\",\"warning_threshold\":99.5,\"target_threshold\":99,\"query\":{\"numerator\":\"sum:httpservice.hits{*}.as_count() - sum:httpservice.errors{*}.as_count()\",\"denominator\":\"(sum:httpservice.hits{*}.as_count() - sum:httpservice.errors{*}.as_count()) + (sum:httpservice.errors{*}.as_count())\"},\"creator\":{\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"email\":\"team-intg-tools-libs-spam@datadoghq.com\"},\"created_at\":1772041538,\"modified_at\":1772041538,\"sli_specification\":{\"count\":{\"bad_events_formula\":{\"formula\":\"query2\"},\"good_events_formula\":{\"formula\":\"query1 - query2\"},\"queries\":[{\"data_source\":\"metrics\",\"name\":\"query1\",\"query\":\"sum:httpservice.hits{*}.as_count()\"},{\"data_source\":\"metrics\",\"name\":\"query2\",\"query\":\"sum:httpservice.errors{*}.as_count()\"}]}}}],\"error\":null}\n"
},
"cookies": [],
"headers": [
{
"name": "content-type",
"value": "application/json"
}
],
"headersSize": 678,
"httpVersion": "HTTP/1.1",
"redirectURL": "",
"status": 200,
"statusText": "OK"
},
"startedDateTime": "2026-02-25T17:45:38.526Z",
"time": 172
},
{
"_id": "c0933b3f30b7b24a0ddbdcdf3c1ea62d",
"_order": 0,
"cache": {},
"request": {
"bodySize": 0,
"cookies": [],
"headers": [
{
"_fromType": "array",
"name": "accept",
"value": "application/json"
}
],
"headersSize": 528,
"httpVersion": "HTTP/1.1",
"method": "DELETE",
"queryString": [],
"url": "https://api.datadoghq.com/api/v1/slo/7309ff3752fd519f80f65a2ed3247dbb"
},
"response": {
"bodySize": 59,
"content": {
"mimeType": "application/json",
"size": 59,
"text": "{\"data\":[\"7309ff3752fd519f80f65a2ed3247dbb\"],\"error\":null}\n"
},
"cookies": [],
"headers": [
{
"name": "content-type",
"value": "application/json"
}
],
"headersSize": 674,
"httpVersion": "HTTP/1.1",
"redirectURL": "",
"status": 200,
"statusText": "OK"
},
"startedDateTime": "2026-02-25T17:45:38.707Z",
"time": 219
}
],
"pages": [],
"version": "1.2"
}
}
15 changes: 14 additions & 1 deletion features/v1/service_level_objectives.feature
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,19 @@ Feature: Service Level Objectives
When the request is sent
Then the response status is 200 OK

@team:DataDog/slo-app
Scenario: Create a new metric SLO object using bad events formula returns "OK" response
Given new "CreateSLO" request
And body with value {"type":"metric","description":"Metric SLO using sli_specification","name":"{{ unique }}","sli_specification":{"count":{"good_events_formula":{"formula":"query1 - query2"},"bad_events_formula":{"formula":"query2"},"queries":[{"data_source":"metrics","name":"query1","query":"sum:httpservice.hits{*}.as_count()"},{"data_source":"metrics","name":"query2","query":"sum:httpservice.errors{*}.as_count()"}]}},"tags":["env:prod","type:count"],"thresholds":[{"target":99.0,"target_display":"99.0","timeframe":"7d","warning":99.5,"warning_display":"99.5"}],"timeframe":"7d","target_threshold":99.0,"warning_threshold":99.5}
When the request is sent
Then the response status is 200 OK
And the response "data[0]" has field "sli_specification"
And the response "data[0].sli_specification" has field "count"
And the response "data[0].sli_specification.count" has field "good_events_formula"
And the response "data[0].sli_specification.count" has field "bad_events_formula"
And the response "data[0].sli_specification.count" has field "queries"
And the response "data[0].sli_specification.count.queries" has length 2

@team:DataDog/slo-app
Scenario: Create a new metric SLO object using sli_specification returns "OK" response
Given new "CreateSLO" request
Expand Down Expand Up @@ -247,7 +260,7 @@ Feature: Service Level Objectives
Scenario: Update an SLO returns "Not Found" response
Given new "UpdateSLO" request
And request contains "slo_id" parameter from "REPLACE.ME"
And body with value {"description": null, "groups": ["env:prod", "role:mysql"], "monitor_ids": [], "monitor_tags": [], "name": "Custom Metric SLO", "query": {"denominator": "sum:my.custom.metric{*}.as_count()", "numerator": "sum:my.custom.metric{type:good}.as_count()"}, "sli_specification": {"time_slice": {"comparator": "<", "query": {"formulas": [{"formula": "query2/query1"}], "queries": [{"data_source": "metrics", "name": "query1", "query": "sum:trace.servlet.request.hits{*} by {env}.as_count()"}, {"data_source": "metrics", "name": "query1", "query": "sum:trace.servlet.request.errors{*} by {env}.as_count()"}]}, "threshold": 5}}, "tags": ["env:prod", "app:core"], "target_threshold": 99.9, "thresholds": [{"target": 95, "timeframe": "7d"}, {"target": 95, "timeframe": "30d", "warning": 97}], "timeframe": "30d", "type": "metric", "warning_threshold": 99.95}
And body with value {"description": null, "groups": ["env:prod", "role:mysql"], "monitor_ids": [], "monitor_tags": [], "name": "Custom Metric SLO", "query": {"denominator": "sum:my.custom.metric{*}.as_count()", "numerator": "sum:my.custom.metric{type:good}.as_count()"}, "sli_specification": {"time_slice": {"comparator": "<", "query": {"formulas": [{"formula": "query2/query1"}], "queries": [{"data_source": "metrics", "name": "query1", "query": "sum:trace.servlet.request.hits{*} by {env}.as_count()"}, {"data_source": "metrics", "name": "query2", "query": "sum:trace.servlet.request.errors{*} by {env}.as_count()"}]}, "threshold": 5}}, "tags": ["env:prod", "app:core"], "target_threshold": 99.9, "thresholds": [{"target": 95, "timeframe": "7d"}, {"target": 95, "timeframe": "30d", "warning": 97}], "timeframe": "30d", "type": "metric", "warning_threshold": 99.95}
When the request is sent
Then the response status is 404 Not Found

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import { ObservabilityPipelineTls } from "./ObservabilityPipelineTls";
* **Supported pipeline types:** logs, metrics
*/
export class ObservabilityPipelineDatadogAgentSource {
/**
* Name of the environment variable or secret that holds the listen address for the Datadog Agent source.
*/
"addressKey"?: string;
/**
* The unique identifier for this component. Used in other parts of the pipeline to reference this component (for example, as the `input` to downstream components).
*/
Expand Down Expand Up @@ -36,6 +40,10 @@ export class ObservabilityPipelineDatadogAgentSource {
* @ignore
*/
static readonly attributeTypeMap: AttributeTypeMap = {
addressKey: {
baseName: "address_key",
type: "string",
},
id: {
baseName: "id",
type: "string",
Expand Down
2 changes: 2 additions & 0 deletions services/service_level_objectives/src/v1/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ export { SLOCorrectionResponseAttributes } from "./models/SLOCorrectionResponseA
export { SLOCorrectionResponseAttributesModifier } from "./models/SLOCorrectionResponseAttributesModifier";
export { SLOCorrectionType } from "./models/SLOCorrectionType";
export { SLOCountDefinition } from "./models/SLOCountDefinition";
export { SLOCountDefinitionWithBadEventsFormula } from "./models/SLOCountDefinitionWithBadEventsFormula";
export { SLOCountDefinitionWithTotalEventsFormula } from "./models/SLOCountDefinitionWithTotalEventsFormula";
export { SLOCountSpec } from "./models/SLOCountSpec";
export { SLOCreator } from "./models/SLOCreator";
export { SLODataSourceQueryDefinition } from "./models/SLODataSourceQueryDefinition";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,64 +1,14 @@
import { AttributeTypeMap } from "@datadog/datadog-api-client";
import { UnparsedObject } from "@datadog/datadog-api-client";

import { SLODataSourceQueryDefinition } from "./SLODataSourceQueryDefinition";
import { SLOFormula } from "./SLOFormula";
import { SLOCountDefinitionWithBadEventsFormula } from "./SLOCountDefinitionWithBadEventsFormula";
import { SLOCountDefinitionWithTotalEventsFormula } from "./SLOCountDefinitionWithTotalEventsFormula";

/**
* A count-based (metric) SLI specification, composed of three parts: the good events formula, the total events formula,
* and the underlying queries.
* A count-based (metric) SLI specification, composed of three parts: the good events formula,
* the bad or total events formula, and the underlying queries.
* Exactly one of `total_events_formula` or `bad_events_formula` must be provided.
*/
export class SLOCountDefinition {
/**
* A formula that specifies how to combine the results of multiple queries.
*/
"goodEventsFormula": SLOFormula;
"queries": Array<SLODataSourceQueryDefinition>;
/**
* A formula that specifies how to combine the results of multiple queries.
*/
"totalEventsFormula": SLOFormula;
/**
* A container for additional, undeclared properties.
* This is a holder for any undeclared properties as specified with
* the 'additionalProperties' keyword in the OAS document.
*/
"additionalProperties"?: { [key: string]: any };
/**
* @ignore
*/
"_unparsed"?: boolean;

/**
* @ignore
*/
static readonly attributeTypeMap: AttributeTypeMap = {
goodEventsFormula: {
baseName: "good_events_formula",
type: "SLOFormula",
required: true,
},
queries: {
baseName: "queries",
type: "Array<SLODataSourceQueryDefinition>",
required: true,
},
totalEventsFormula: {
baseName: "total_events_formula",
type: "SLOFormula",
required: true,
},
additionalProperties: {
baseName: "additionalProperties",
type: "{ [key: string]: any; }",
},
};

/**
* @ignore
*/
static getAttributeTypeMap(): AttributeTypeMap {
return SLOCountDefinition.attributeTypeMap;
}

public constructor() {}
}
export type SLOCountDefinition =
| SLOCountDefinitionWithTotalEventsFormula
| SLOCountDefinitionWithBadEventsFormula
| UnparsedObject;
Loading
Loading