create_omni_slo
async
¶
create_omni_slo(
space_id: SpaceId,
name: SloName,
service_attributes: SloServiceAttributes,
sli: Sli,
objective: SloObjective,
*,
config_overrides: Optional[AsyncCloudWatchOmniClientConfig] = None,
description: Optional[SloDescription] = None,
tags: Optional[TagMap] = None,
client_token: Optional[ClientToken] = None,
) -> CreateOmniSloOutput
Creates a service level objective (SLO) within a space. The SLO measures a service against a reliability target over a time window.
Parameters:
-
space_id(SpaceId) –The unique ID of the space to create the SLO in.
-
name(SloName) –The display name of the SLO. Not unique within a space; the sloId returned in the response identifies the SLO.
-
description(Optional[SloDescription], default:None) –An optional description of the SLO.
-
service_attributes(SloServiceAttributes) –The service the SLO is about. Descriptive only: it is not checked against the SLI and never used for authorization.
-
sli(Sli) –What the SLO measures.
-
objective(SloObjective) –The reliability target, the warning threshold and the window the target is measured over.
-
tags(Optional[TagMap], default:None) –The tags to associate with the SLO.
-
client_token(Optional[ClientToken], default:None) –Idempotency token for safe retries. Retrying with the same token returns the original SLO instead of creating a duplicate.
Raises:
-
AccessDeniedException–The caller is not authorized to perform this action.
-
ConflictException–The operation could not be completed because of a conflict with the current state of the resource.
-
InternalServerException–An unexpected error occurred while processing the request.
-
ResourceNotFoundException–The specified resource does not exist.
-
ServiceQuotaExceededException–A service quota was exceeded.
-
ThrottlingException–The request was throttled due to exceeding the allowed request rate.
-
ValidationException–A parameter is specified incorrectly.
-
UnknownServiceError–The service returned an error code this client does not model.
Examples:
Create a request-based SLO The following example creates an SLO that 99.9 percent of checkout API requests succeed over a rolling 30 days, and enters the WARNING state once 75 percent of the error budget is consumed. The good and total queries count events over the range the service substitutes for $__interval. The client token makes a retry return this SLO instead of creating a second one. A new SLO has not been evaluated yet, so the response has no state. Payloads are shown as JSON; on the wire they are CBOR-encoded.
>>> await client.create_omni_slo(space_id='a1b2c3d4-5e6f-4a3b-8c9d-0e1f2a3b4c5d', name='checkout-api-availability', description='99.9 percent of checkout API requests succeed over a rolling 30 days.', service_attributes={'serviceName': 'checkout-api', 'serviceNamespace': 'retail', 'cloudProvider': 'aws', 'cloudAccountId': '123456789012', 'cloudRegion': 'us-east-1', 'deploymentEnvironmentName': 'prod'}, sli={'events': {'good': {'language': 'PROMQL', 'expression': 'sum(increase({"http.server.request.duration_count", "service.name"="checkout-api", "http.response.status_code"!~"5.."}[$__interval]))'}, 'total': {'language': 'PROMQL', 'expression': 'sum(increase({"http.server.request.duration_count", "service.name"="checkout-api"}[$__interval]))'}}}, objective={'target': 99.9, 'warningBudgetConsumedRatio': 0.75, 'timeWindow': {'rolling': {'days': 30}}}, tags={'team': 'payments'}, client_token='3f1c9a2e-7b4d-4e8a-9c6f-1d2e3f4a5b6c')
Create a time-slice SLO over a calendar week
The following example creates an SLO that judges each 1-minute period good when its p99 latency is at most 300 milliseconds, with a target of 99.9 percent of periods in each calendar week, starting on Monday in the America/New_York time zone. The error budget is counted in periods and restarts at each week boundary. No warning ratio is set, so the SLO is never in the WARNING state. A new SLO has not been evaluated yet, so the response has no state. Payloads are shown as JSON; on the wire they are CBOR-encoded.
>>> await client.create_omni_slo(space_id='a1b2c3d4-5e6f-4a3b-8c9d-0e1f2a3b4c5d', name='checkout-api-latency-p99', service_attributes={'serviceName': 'checkout-api', 'deploymentEnvironmentName': 'prod'}, sli={'periods': {'periodMinutes': 1, 'query': {'language': 'PROMQL', 'expression': 'histogram_quantile(0.99, sum by (le) (rate({"http.server.request.duration_bucket", "service.name"="checkout-api"}[$__interval])))'}, 'good': {'comparator': 'LTE', 'threshold': 0.3}}}, objective={'target': 99.9, 'timeWindow': {'calendar': {'unit': 'WEEK', 'weekStartDay': 'MONDAY', 'timeZone': 'America/New_York'}}})
Source code in docs_src/capo_cloudwatchomni/_services/async_cloud_watch_omni.py
1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 | |