Skip to main content

Service-Level objectives

  • Reference

Management API for service-level objectives, templates and evaluating service-level objectives

Latest (V1)
npm install @dynatrace-sdk/client-service-level-objectives

objectiveTemplatesClient

import { objectiveTemplatesClient } from '@dynatrace-sdk/client-service-level-objectives';

getObjectiveTemplateById

objectiveTemplatesClient.getObjectiveTemplateById(config): Promise<ObjectiveTemplate>

Get an objective template by ID

One of the following scopes is required:

  • slo:objective-templates:read
  • slo:slos:read

Parameters

NameTypeDescription
config.id*requiredstringobjective template ID

Returns

Return typeStatus codeDescription
ObjectiveTemplate200A single objective template

Throws

Error TypeError Message
BadRequestMalformed request or invalid parameters.
UnauthorizedAPI token or tenant missing or corrupt.
ForbiddenAccess forbidden. This usually happens because the user lacks the permission to access the specific endpoint, or because the target entity isn't accessible to the user.
NotFoundNot found.
TooManyRequestsThe client has sent too many requests in a given amount of time and has been rate-limited.
InternalServerErrorInternal server error.

Code example

import { objectiveTemplatesClient } from "@dynatrace-sdk/client-service-level-objectives";

const data =
await objectiveTemplatesClient.getObjectiveTemplateById({
id: "...",
});

getObjectiveTemplates

objectiveTemplatesClient.getObjectiveTemplates(config): Promise<ObjectiveTemplateList>

List objective templates

One of the following scopes is required:

  • slo:objective-templates:read
  • slo:slos:read

Parameters

NameTypeDescription
config.filterstring

The filter parameter, as explained here.

Filtering is supported on the following fields:

  • id
  • name
  • builtIn
  • deprecated
  • applicableScope
  • tag.key and tag.value
config.pagenumberThe page number to retrieve, 1-indexed. Can't be used together with page-key.
config.pageKeystringCursor for the next page of results, obtained from nextPageKey in the previous response. Can't be used together with page.
config.pageSizenumberHow many items to return at one time (max 500)
config.sortstring

The sort parameter, as explained here.

Sorting is supported on the following fields:

  • name

Returns

Return typeStatus codeDescription
ObjectiveTemplateList200A paged array of objective templates

Throws

Error TypeError Message
BadRequestMalformed request or invalid parameters.
UnauthorizedAPI token or tenant missing or corrupt.
ForbiddenAccess forbidden. This usually happens because the user lacks the permission to access the specific endpoint, or because the target entity isn't accessible to the user.
TooManyRequestsThe client has sent too many requests in a given amount of time and has been rate-limited.
InternalServerErrorInternal server error.

Code example

import { objectiveTemplatesClient } from "@dynatrace-sdk/client-service-level-objectives";

const data =
await objectiveTemplatesClient.getObjectiveTemplates();

serviceLevelObjectivesClient

import { serviceLevelObjectivesClient } from '@dynatrace-sdk/client-service-level-objectives';

createSlo

serviceLevelObjectivesClient.createSlo(config): Promise<Slo>

Add a new service-level objective

Required scope: slo:slos:write

Parameters

NameType
config.body*requiredSloConfig

Returns

Return typeStatus codeDescription
Slo201Created

Throws

Error TypeError Message
BadRequestMalformed request or invalid parameters.
UnauthorizedAPI token or tenant missing or corrupt.
ForbiddenAccess forbidden. This usually happens because the user lacks the permission to access the specific endpoint, or because the target entity isn't accessible to the user.
TooManyRequestsThe client has sent too many requests in a given amount of time and has been rate-limited.
InternalServerErrorInternal server error.

Code example

import { serviceLevelObjectivesClient } from "@dynatrace-sdk/client-service-level-objectives";

const data = await serviceLevelObjectivesClient.createSlo({
body: {
name: "New SLO",
sliReference: {
templateId: "...",
variables: [
{
name: "hostIds",
value: '"HOST-123456789ABCDEFG"',
},
],
},
customSli: {
indicator: "timeseries sli=avg(dt.host.cpu.idle)",
},
criteria: [{ timeframeFrom: "now-7d", target: 99.8 }],
},
});

deleteSlo

serviceLevelObjectivesClient.deleteSlo(config): Promise<void>

Delete a service-level objective by ID

Required scope: slo:slos:write

Parameters

NameTypeDescription
config.id*requiredstringservice-level objective ID
config.optimisticLockingVersion*requiredstring

The version of the object for optimistic locking. You can use it to detect simultaneous modifications by different users.

It's generated upon retrieval (GET requests). If set on update (PUT request) or deletion, the update/deletion will be allowed only if there wasn't any change between the retrieval and the update.

Returns

Return typeStatus codeDescription
void204No Content

Throws

Error TypeError Message
BadRequestMalformed request or invalid parameters.
UnauthorizedAPI token or tenant missing or corrupt.
ForbiddenAccess forbidden. This usually happens because the user lacks the permission to access the specific endpoint, or because the target entity isn't accessible to the user.
NotFoundNot found.
TooManyRequestsThe client has sent too many requests in a given amount of time and has been rate-limited.
InternalServerErrorInternal server error.

Code example

import { serviceLevelObjectivesClient } from "@dynatrace-sdk/client-service-level-objectives";

const data = await serviceLevelObjectivesClient.deleteSlo({
id: "...",
optimisticLockingVersion: "...",
});

getSloById

serviceLevelObjectivesClient.getSloById(config): Promise<Slo>

Get a service-level objective by ID

Required scope: slo:slos:read

Parameters

NameType
config.id*requiredstring

Returns

Return typeStatus codeDescription
Slo200A single service-level objective

Throws

Error TypeError Message
BadRequestMalformed request or invalid parameters.
UnauthorizedAPI token or tenant missing or corrupt.
ForbiddenAccess forbidden. This usually happens because the user lacks the permission to access the specific endpoint, or because the target entity isn't accessible to the user.
NotFoundNot found.
TooManyRequestsThe client has sent too many requests in a given amount of time and has been rate-limited.
InternalServerErrorInternal server error.

Code example

import { serviceLevelObjectivesClient } from "@dynatrace-sdk/client-service-level-objectives";

const data = await serviceLevelObjectivesClient.getSloById({
id: "...",
});

getSlos

serviceLevelObjectivesClient.getSlos(config): Promise<SloObjectsList>

List service-level objectives

Required scope: slo:slos:read

Parameters

NameTypeDescription
config.filterstring

The filter parameter, as explained here.

Filtering is supported on the following fields:

  • id
  • name
  • tag.key and tag.value
config.pagenumberThe page number to retrieve, 1-indexed. Can't be used together with page-key.
config.pageKeystringCursor for the next page of results, obtained from nextPageKey in the previous response. Can't be used together with page.
config.pageSizenumberHow many items to return at one time (max 500)
config.sortstring

The sort parameter, as explained here.

Sorting is supported on the following fields:

  • name

Returns

Return typeStatus codeDescription
SloObjectsList200A paged array of service-level objectives

Throws

Error TypeError Message
BadRequestMalformed request or invalid parameters.
UnauthorizedAPI token or tenant missing or corrupt.
ForbiddenAccess forbidden. This usually happens because the user lacks the permission to access the specific endpoint, or because the target entity isn't accessible to the user.
TooManyRequestsThe client has sent too many requests in a given amount of time and has been rate-limited.
InternalServerErrorInternal server error.

Code example

import { serviceLevelObjectivesClient } from "@dynatrace-sdk/client-service-level-objectives";

const data = await serviceLevelObjectivesClient.getSlos();

updateSlo

serviceLevelObjectivesClient.updateSlo(config): Promise<void>

Update a service-level objective by ID

Required scope: slo:slos:write

Parameters

NameTypeDescription
config.body*requiredSloConfig
config.id*requiredstringservice-level objective ID
config.optimisticLockingVersion*requiredstring

The version of the object for optimistic locking. You can use it to detect simultaneous modifications by different users.

It's generated upon retrieval (GET requests). If set on update (PUT request) or deletion, the update/deletion will be allowed only if there wasn't any change between the retrieval and the update.

Returns

Return typeStatus codeDescription
void200Updated

Throws

Error TypeError Message
BadRequestMalformed request or invalid parameters.
UnauthorizedAPI token or tenant missing or corrupt.
ForbiddenAccess forbidden. This usually happens because the user lacks the permission to access the specific endpoint, or because the target entity isn't accessible to the user.
NotFoundNot found.
ConflictOptimistic locking failed, or the document is actively locked\ \ by another user, or some other conflict.
TooManyRequestsThe client has sent too many requests in a given amount of time and has been rate-limited.
InternalServerErrorInternal server error.

Code example

import { serviceLevelObjectivesClient } from "@dynatrace-sdk/client-service-level-objectives";

const data = await serviceLevelObjectivesClient.updateSlo({
id: "...",
optimisticLockingVersion: "...",
body: {
name: "New SLO",
sliReference: {
templateId: "...",
variables: [
{
name: "hostIds",
value: '"HOST-123456789ABCDEFG"',
},
],
},
customSli: {
indicator: "timeseries sli=avg(dt.host.cpu.idle)",
},
criteria: [{ timeframeFrom: "now-7d", target: 99.8 }],
},
});

serviceLevelObjectivesEvaluationClient

import { serviceLevelObjectivesEvaluationClient } from '@dynatrace-sdk/client-service-level-objectives';

cancelSloEvaluation

serviceLevelObjectivesEvaluationClient.cancelSloEvaluation(config): Promise<void | SloEvaluationCancelResponse>

Cancels the SLO evaluation and returns the result if the evaluation was already finished, otherwise discards it.

Required scope: slo:slos:read

For information about the required Grail permissions, see the Bucket and table permissions in Grail documentation.

Parameters

NameType
config.evaluationToken*requiredstring

Returns

Return typeStatus codeDescription
SloEvaluationCancelResponse200SLO evaluation result
void202The SLO evaluation was still running and is now cancelled.

Throws

Error TypeError Message
BadRequestMalformed request or invalid parameters.
UnauthorizedAPI token or tenant missing or corrupt.
ForbiddenAccess forbidden. This usually happens because the user lacks the permission to access the specific endpoint, or because the target entity isn't accessible to the user.
GoneThe SLO Evaluation for the given evaluationToken isn't available anymore.
TooManyRequestsThe client has sent too many requests in a given amount of time and has been rate-limited.
InternalServerErrorInternal server error.

Code example

import { serviceLevelObjectivesEvaluationClient } from "@dynatrace-sdk/client-service-level-objectives";

const data =
await serviceLevelObjectivesEvaluationClient.cancelSloEvaluation(
{ evaluationToken: "FQ5aVZERXZNMjR1SzVnPT0ifQ==" },
);

pollSloEvaluation

serviceLevelObjectivesEvaluationClient.pollSloEvaluation(config): Promise<SloEvaluationResponse>

Polls an SLO evaluation

Required scope: slo:slos:read

For information about the required Grail permissions, see the Bucket and table permissions in Grail documentation.

Parameters

NameTypeDescription
config.evaluationToken*requiredstring
config.requestTimeoutMillisecondsnumberHow long to wait for the evaluation result before returning in milliseconds. If the evaluation finishes within this time, the result is returned directly (200). If not, the response contains the evaluationToken for further polling.

Returns

Return typeStatus codeDescription
SloEvaluationResponse200SLO evaluation result

Throws

Error TypeError Message
BadRequestMalformed request or invalid parameters.
UnauthorizedAPI token or tenant missing or corrupt.
ForbiddenAccess forbidden. This usually happens because the user lacks the permission to access the specific endpoint, or because the target entity isn't accessible to the user.
GoneThe SLO Evaluation for the given evaluationToken isn't available anymore.
TooManyRequestsThe client has sent too many requests in a given amount of time and has been rate-limited.
InternalServerErrorInternal server error.

Code example

import { serviceLevelObjectivesEvaluationClient } from "@dynatrace-sdk/client-service-level-objectives";

const data =
await serviceLevelObjectivesEvaluationClient.pollSloEvaluation(
{ evaluationToken: "FQ5aVZERXZNMjR1SzVnPT0ifQ==" },
);

startSloEvaluation

serviceLevelObjectivesEvaluationClient.startSloEvaluation(config): Promise<SloEvaluationResponse>

Starts an SLO evaluation

Required scope: slo:slos:read

For information about the required Grail permissions, see the Bucket and table permissions in Grail documentation.

Parameters

NameType
config.body*requiredSloEvaluationRequest

Returns

Return typeStatus codeDescription
SloEvaluationResponse200SLO evaluation result
SloEvaluationResponse202SLO evaluation started

Throws

Error TypeError Message
BadRequestMalformed request or invalid parameters.
UnauthorizedAPI token or tenant missing or corrupt.
ForbiddenAccess forbidden. This usually happens because the user lacks the permission to access the specific endpoint, or because the target entity isn't accessible to the user.
TooManyRequestsThe client has sent too many requests in a given amount of time and has been rate-limited.
InternalServerErrorInternal server error.

Code example

import { serviceLevelObjectivesEvaluationClient } from "@dynatrace-sdk/client-service-level-objectives";

const data =
await serviceLevelObjectivesEvaluationClient.startSloEvaluation(
{
body: {
id: "A5LTU5YTVjNTcxODI5OL7vVN4V2t6t",
customTimeframe: { timeframeFrom: "now-7d" },
},
},
);

Types

ConstraintViolation

Contains information about a constraint violation caused by invalid input.

NameTypeDescription
message*requiredstringThe constraint violation description message
pathstringThe path of the parameter that caused the constraint violation

Criteria

NameTypeDescription
target*requirednumber
timeframeFrom*requiredstringThe start of the timeframe. Supports relative time expressions (e.g. now-7d) and ISO 8601 timestamps.
timeframeTostringThe end of the timeframe. Supports relative time expressions (e.g. now-7d) and ISO 8601 timestamps. Defaults to now if omitted.
warningnumber

CustomSli

NameTypeDescription
filterSegmentsFilterSegmentsRepresents a collection of filter segments.
indicator*requiredstring

Deprecation

NameTypeDescription
deprecated*requiredbooleanTrue if this template is deprecated and shouldn't be used for new SLOs.
replacementTemplateIdstringIf deprecated=true, this field may contain the ID of the template to use instead.

Error

An error response as defined here.

NameTypeDescription
code*requirednumber
detailsErrorDetailsOptional details of the error
message*requiredstring

ErrorDetails

Optional details of the error

NameTypeDescription
constraintViolationsArray<ConstraintViolation>A list of constraint violations of input parameters (path, query, request body)
errorRefstringreference to the error occurrence in the internal self-monitoring, logging, etc.

ErrorEnvelope

NameTypeDescription
error*requiredErrorAn error response as defined here.

FilterSegment

A filter segment is identified by an ID.

NameTypeDescription
id*requiredstringThe identifier of the filter segment.
variablesArray<FilterSegmentVariable>

FilterSegmentVariable

Defines a variable with a name and a list of values.

NameTypeDescription
name*requiredstringThe name of the variable.
values*requiredArray<string>The list of values for this variable.

FilterSegments

Represents a collection of filter segments.

type: Array<FilterSegment>

Metadata

NameTypeDescription
evaluatedSliQuery*requiredstringThe resolved DQL query that was actually executed for this evaluation.

MetadataResponse

NameType
metadata*requiredMetadata

ObjectiveTemplate

NameTypeDescription
applicableScope*required"SERVICE" | "HOST" | "APPLICATION" | "CLOUD_APPLICATION" | "KUBERNETES_CLUSTER" | "CLOUD_APPLICATION_NAMESPACE" | "ALL"
builtIn*requiredboolean
deprecationDeprecation
descriptionstring
externalIdstringAn optional user-provided external identifier for the objective template. Must be unique across all objective templates.
id*requiredstring
indicator*requiredstring
name*requiredstring
tagsArray<string>A list of tags for this objective template. Tags can be plain strings (e.g. myTag) or key-value pairs separated by a colon (e.g. Stage:DEV). To include a literal colon in a tag, escape it with a backslash (e.g. key\:value).
variables*requiredArray<TemplateVariable>
versionstring

The version of the object for optimistic locking. You can use it to detect simultaneous modifications by different users.

It's generated upon retrieval (GET requests). If set on update (PUT request) or deletion, the update/deletion will be allowed only if there wasn't any change between the retrieval and the update.

ObjectiveTemplateConfig

NameTypeDescription
applicableScope*required"SERVICE" | "HOST" | "APPLICATION" | "CLOUD_APPLICATION" | "KUBERNETES_CLUSTER" | "CLOUD_APPLICATION_NAMESPACE" | "ALL"
descriptionstring
externalIdstringAn optional user-provided external identifier for the objective template. Must be unique across all objective templates.
indicator*requiredstring
name*requiredstring
tagsArray<string>A list of tags for this objective template. Tags can be plain strings (e.g. myTag) or key-value pairs separated by a colon (e.g. Stage:DEV). To include a literal colon in a tag, escape it with a backslash (e.g. key\:value).
variables*requiredArray<TemplateVariable>

ObjectiveTemplateList

NameTypeDescription
items*requiredArray<ObjectiveTemplate>
nextPageKeystring

The cursor for the next page of results. Has the value of null on the last page.

Use it in the page-key query parameter to obtain subsequent pages of the result.

totalCount*requirednumberThe total number of entries in the result.

SliReference

NameTypeDescription
templateId*requiredstringThe id of the objective template to use as the SLI definition.
variables*requiredArray<SliReferenceVariable>

SliReferenceVariable

NameType
name*requiredstring
value*requiredstring

Slo

Configuration for a service-level objective. Exactly one of sliReference or customSli must be provided. Providing both or neither results in a 400 Bad Request.

NameTypeDescription
criteria*requiredArray<Criteria>
customSliCustomSli
descriptionstring
externalIdstringAn optional user-provided external identifier for the SLO. Must be unique across all SLOs.
id*requiredstring
name*requiredstring
sliReferenceSliReference
tagsArray<string>A list of tags for this SLO. Tags can be plain strings (e.g. myTag) or key-value pairs separated by a colon (e.g. Stage:DEV). To include a literal colon in a tag, escape it with a backslash (e.g. key\:value).
version*requiredstring

The version of the object for optimistic locking. You can use it to detect simultaneous modifications by different users.

It's generated upon retrieval (GET requests). If set on update (PUT request) or deletion, the update/deletion will be allowed only if there wasn't any change between the retrieval and the update.

SloConfig

Configuration for a service-level objective. Exactly one of sliReference or customSli must be provided. Providing both or neither results in a 400 Bad Request.

NameTypeDescription
criteria*requiredArray<Criteria>
customSliCustomSli
descriptionstring
externalIdstringAn optional user-provided external identifier for the SLO. Must be unique across all SLOs.
name*requiredstring
sliReferenceSliReference
tagsArray<string>A list of tags for this SLO. Tags can be plain strings (e.g. myTag) or key-value pairs separated by a colon (e.g. Stage:DEV). To include a literal colon in a tag, escape it with a backslash (e.g. key\:value).

SloEvaluationBaseResponse

NameType
evaluationResultsArray<SloEvaluationResult>
metadata*requiredMetadata

SloEvaluationCancelResponse

NameType
definition*requiredSlo
evaluationResultsArray<SloEvaluationResult>
metadata*requiredMetadata

SloEvaluationRequest

NameTypeDescription
customTimeframeTimeframe
filterSegmentsArray<FilterSegment>Filter segments to apply during this evaluation. The effective filter for each segment is the intersection of the segment defined on the SLO and the segment provided here. If only one side defines a segment, that segment is used as-is.
id*requiredstring
requestTimeoutMillisecondsnumberHow long to wait for the evaluation result before returning in milliseconds. If the evaluation finishes within this time, the result is returned directly (200). If not, a 202 is returned with an evaluationToken that can be used to poll for the result. default: 1000

SloEvaluationResponse

NameTypeDescription
definition*requiredSlo
evaluationResultsArray<SloEvaluationResult>
evaluationTokenstringToken to pass to evaluation:poll or evaluation:cancel to retrieve or discard the evaluation result.
metadata*requiredMetadata
ttlSecondsnumber

SloEvaluationResult

NameTypeDescription
criteria*requiredstring
errorBudgetnumber
messagestring
status*required"SUCCESS" | "WARNING" | "FAILURE" | "ERROR"The status of an SLO evaluation. SUCCESS and WARNING indicate the SLO was evaluated successfully (target met or warning threshold breached respectively). FAILURE means the SLO target wasn't met. ERROR means the evaluation couldn't be completed due to a system or query error.
valuenumberThe evaluated SLO compliance as a percentage (0–100).

SloObjectsList

NameTypeDescription
nextPageKeystring

The cursor for the next page of results. Has the value of null on the last page.

Use it in the page-key query parameter to obtain subsequent pages of the result.

slos*requiredArray<Slo>
totalCount*requirednumberThe total number of entries in the result.

TemplateVariable

NameTypeDescription
name*requiredstring
scope*required"CUSTOM" | "SERVICE" | "SMARTSCAPE_SERVICE" | "HOST" | "SMARTSCAPE_HOST" | "APPLICATION" | "CLOUD_APPLICATION" | "KUBERNETES_CLUSTER" | "SMARTSCAPE_K8S_CLUSTER" | "CLOUD_APPLICATION_NAMESPACE" | "SMARTSCAPE_K8S_NAMESPACE"The scope of a template variable. Use SMARTSCAPE_* variants when referencing Smartscape objective templates.

Timeframe

NameTypeDescription
timeframeFrom*requiredstringThe start of the timeframe. Supports relative time expressions (e.g. now-7d) and ISO 8601 timestamps.
timeframeTostringThe end of the timeframe. Supports relative time expressions (e.g. now-7d) and ISO 8601 timestamps. Defaults to now if omitted.

Enums

EvaluationStatus

⚠️ Deprecated Use literal values.

The status of an SLO evaluation. SUCCESS and WARNING indicate the SLO was evaluated successfully (target met or warning threshold breached respectively). FAILURE means the SLO target wasn't met. ERROR means the evaluation couldn't be completed due to a system or query error.

Enum keys

Error | Failure | Success | Warning

TemplateScope

⚠️ Deprecated Use literal values.

Enum keys

All | Application | CloudApplication | CloudApplicationNamespace | Host | KubernetesCluster | Service

VariableScope

⚠️ Deprecated Use literal values.

The scope of a template variable. Use SMARTSCAPE_* variants when referencing Smartscape objective templates.

Enum keys

Application | CloudApplication | CloudApplicationNamespace | Custom | Host | KubernetesCluster | Service | SmartscapeHost | SmartscapeK8SCluster | SmartscapeK8SNamespace | SmartscapeService

Still have questions?
Find answers in the Dynatrace Community