Get a single service definition
https://api.datadoghq.com/api/v2/services/definitions/{service_name}https://api.us3.datadoghq.com/api/v2/services/definitions/{service_name}https://api.us5.datadoghq.com/api/v2/services/definitions/{service_name}https://api.datadoghq.eu/api/v2/services/definitions/{service_name}https://api.ap1.datadoghq.com/api/v2/services/definitions/{service_name}https://api.ap2.datadoghq.com/api/v2/services/definitions/{service_name}https://api.uk1.datadoghq.com/api/v2/services/definitions/{service_name}https://api.ddog-gov.com/api/v2/services/definitions/{service_name}https://api.us2.ddog-gov.com/api/v2/services/definitions/{service_name}Overview
Get a single service definition from the Datadog Service Catalog.
OAuth apps require the apm_service_catalog_read authorization scope to access this endpoint.
Arguments
Path Parameters
service_name [required]The name of the service.
Query Strings
schema_versionThe schema version desired in the response.
v1, v2, v2.1, v2.2Response
OK
Get service definition response.
dataService definition data.
attributesService definition attributes.
metaMetadata about a service definition.
github-html-urlGitHub HTML URL.
ingested-schema-versionIngestion schema version.
ingestion-sourceIngestion source of the service definition.
last-modified-timeLast modified time of the service definition.
originUser defined origin of the service definition.
origin-detailUser defined origin's detail of the service definition.
warningsA list of schema validation warnings.
instance-locationThe warning instance location.
keyword-locationThe warning keyword location.
messageThe warning message.
schemaService definition schema.
<schema-version=v1>DEPRECATED Deprecated - Service definition V1 for providing additional service metadata and integrations.
contactContact information about the service.
emailService owner’s email.
slackService owner’s Slack channel.
extensionsExtensions to V1 schema.
external-resourcesA list of external links related to the services.
name [required]Link name.
type [required]Link type.
doc, wiki, runbook, url, repo, dashboard, oncall, code, linkurl [required]Link URL.
info [required]Basic information about a service.
dd-service [required]Unique identifier of the service. Must be unique across all services and is used to match with a service in Datadog.
descriptionA short description of the service.
display-nameA friendly name of the service.
service-tierService tier.
integrationsThird party integrations that Datadog supports.
pagerdutyPagerDuty service URL for the service.
orgOrg related information about the service.
applicationApp feature this service supports.
teamTeam that owns the service.
schema-version [required]Schema version being used.
v1v1tagsA set of custom tags.
<schema-version=v2>Service definition V2 for providing service metadata and integrations.
contactsA list of contacts related to the services.
<type=email>Service owner's email.
contact [required]Contact value.
nameContact email.
type [required]Contact type.
email<type=slack>Service owner's Slack channel.
contact [required]Slack Channel.
nameContact Slack.
type [required]Contact type.
slack<type=microsoft-teams>Service owner's Microsoft Teams.
contact [required]Contact value.
nameContact Microsoft Teams.
type [required]Contact type.
microsoft-teamsdd-service [required]Unique identifier of the service. Must be unique across all services and is used to match with a service in Datadog.
dd-teamExperimental feature. A Team handle that matches a Team in the Datadog Teams product.
docsA list of documentation related to the services.
name [required]Document name.
providerDocument provider.
url [required]Document URL.
extensionsExtensions to V2 schema.
integrationsThird party integrations that Datadog supports.
opsgenieOpsgenie integration for the service.
regionOpsgenie instance region.
US, EUservice-url [required]Opsgenie service url.
pagerdutyPagerDuty service URL for the service.
linksA list of links related to the services.
name [required]Link name.
type [required]Link type.
doc, wiki, runbook, url, repo, dashboard, oncall, code, linkurl [required]Link URL.
reposA list of code repositories related to the services.
name [required]Repository name.
providerRepository provider.
url [required]Repository URL.
schema-version [required]Schema version being used.
v2v2tagsA set of custom tags.
teamTeam that owns the service.
<schema-version=v2.1>Service definition v2.1 for providing service metadata and integrations.
applicationIdentifier for a group of related services serving a product feature, which the service is a part of.
contactsA list of contacts related to the services.
<type=email>Service owner's email.
contact [required]Contact value.
nameContact email.
type [required]Contact type.
email<type=slack>Service owner's Slack channel.
contact [required]Slack Channel.
nameContact Slack.
type [required]Contact type.
slack<type=microsoft-teams>Service owner's Microsoft Teams.
contact [required]Contact value.
nameContact Microsoft Teams.
type [required]Contact type.
microsoft-teamsdd-service [required]Unique identifier of the service. Must be unique across all services and is used to match with a service in Datadog.
descriptionA short description of the service.
extensionsExtensions to v2.1 schema.
integrationsThird party integrations that Datadog supports.
opsgenieOpsgenie integration for the service.
regionOpsgenie instance region.
US, EUservice-url [required]Opsgenie service url.
pagerdutyPagerDuty integration for the service.
service-urlPagerDuty service url.
lifecycleThe current life cycle phase of the service.
linksA list of links related to the services.
name [required]Link name.
providerLink provider.
type [required]Link type.
doc, repo, runbook, dashboard, otherurl [required]Link URL.
schema-version [required]Schema version being used.
v2.1v2.1tagsA set of custom tags.
teamTeam that owns the service. It is used to locate a team defined in Datadog Teams if it exists.
tierImportance of the service.
<schema-version=v2.2>Service definition v2.2 for providing service metadata and integrations.
applicationIdentifier for a group of related services serving a product feature, which the service is a part of.
ci-pipeline-fingerprintsA set of CI fingerprints.
contactsA list of contacts related to the services.
contact [required]Contact value.
nameContact Name.
type [required]Contact type. Datadog recognizes the following types: email, slack, and microsoft-teams.
dd-service [required]Unique identifier of the service. Must be unique across all services and is used to match with a service in Datadog.
descriptionA short description of the service.
extensionsExtensions to v2.2 schema.
integrationsThird party integrations that Datadog supports.
opsgenieOpsgenie integration for the service.
regionOpsgenie instance region.
US, EUservice-url [required]Opsgenie service url.
pagerdutyPagerDuty integration for the service.
service-urlPagerDuty service url.
languagesThe service's programming language. Datadog recognizes the following languages: dotnet, go, java, js, php, python, ruby, and c++.
lifecycleThe current life cycle phase of the service.
linksA list of links related to the services.
name [required]Link name.
providerLink provider.
type [required]Link type. Datadog recognizes the following types: runbook, doc, repo, dashboard, and other.
url [required]Link URL.
schema-version [required]Schema version being used.
v2.2v2.2tagsA set of custom tags.
teamTeam that owns the service. It is used to locate a team defined in Datadog Teams if it exists.
tierImportance of the service.
typeThe type of service.
idService definition id.
typeService definition type.
{
"data": {
"attributes": {
"meta": {
"github-html-url": "string",
"ingested-schema-version": "string",
"ingestion-source": "string",
"last-modified-time": "string",
"origin": "string",
"origin-detail": "string",
"warnings": [
{
"instance-location": "string",
"keyword-location": "string",
"message": "string"
}
]
},
"schema": {
"contact": {
"email": "contact@datadoghq.com",
"slack": "https://yourcompany.slack.com/archives/channel123"
},
"extensions": {
"myorg/extension": "extensionValue"
},
"external-resources": [
{
"name": "Runbook",
"type": "runbook",
"url": "https://my-runbook"
}
],
"info": {
"dd-service": "myservice",
"description": "A shopping cart service",
"display-name": "My Service",
"service-tier": "Tier 1"
},
"integrations": {
"pagerduty": "https://my-org.pagerduty.com/service-directory/PMyService"
},
"org": {
"application": "E-Commerce",
"team": "my-team"
},
"schema-version": "v1",
"tags": [
"my:tag",
"service:tag"
]
}
},
"id": "string",
"type": "string"
}
}Bad Request
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Forbidden
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Not Found
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Conflict
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Too many requests
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Code Example
# Path parameters
export service_name="my-service"
# Set your Datadog site and credentials
export DD_SITE="datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X GET "https://api.${DD_SITE}/api/v2/services/definitions/${service_name}" \
-H "Accept: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}"# Path parameters
export service_name="my-service"
# Set your Datadog site and credentials
export DD_SITE="us3.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X GET "https://api.${DD_SITE}/api/v2/services/definitions/${service_name}" \
-H "Accept: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}"# Path parameters
export service_name="my-service"
# Set your Datadog site and credentials
export DD_SITE="us5.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X GET "https://api.${DD_SITE}/api/v2/services/definitions/${service_name}" \
-H "Accept: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}"# Path parameters
export service_name="my-service"
# Set your Datadog site and credentials
export DD_SITE="datadoghq.eu"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X GET "https://api.${DD_SITE}/api/v2/services/definitions/${service_name}" \
-H "Accept: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}"# Path parameters
export service_name="my-service"
# Set your Datadog site and credentials
export DD_SITE="ap1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X GET "https://api.${DD_SITE}/api/v2/services/definitions/${service_name}" \
-H "Accept: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}"# Path parameters
export service_name="my-service"
# Set your Datadog site and credentials
export DD_SITE="ap2.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X GET "https://api.${DD_SITE}/api/v2/services/definitions/${service_name}" \
-H "Accept: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}"# Path parameters
export service_name="my-service"
# Set your Datadog site and credentials
export DD_SITE="uk1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X GET "https://api.${DD_SITE}/api/v2/services/definitions/${service_name}" \
-H "Accept: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}"# Path parameters
export service_name="my-service"
# Set your Datadog site and credentials
export DD_SITE="ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X GET "https://api.${DD_SITE}/api/v2/services/definitions/${service_name}" \
-H "Accept: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}"# Path parameters
export service_name="my-service"
# Set your Datadog site and credentials
export DD_SITE="us2.ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X GET "https://api.${DD_SITE}/api/v2/services/definitions/${service_name}" \
-H "Accept: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}"// Get a single service definition returns "OK" response
package main
import (
"context"
"encoding/json"
"fmt"
"os"
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
)
func main() {
ctx := datadog.NewDefaultContext(context.Background())
ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewServiceDefinitionApi(apiClient)
resp, r, err := api.GetServiceDefinition(ctx, "service-definition-test", *datadogV2.NewGetServiceDefinitionOptionalParameters().WithSchemaVersion(datadogV2.SERVICEDEFINITIONSCHEMAVERSIONS_V2_1))
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `ServiceDefinitionApi.GetServiceDefinition`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `ServiceDefinitionApi.GetServiceDefinition`:\n%s\n", responseContent)
}
Instructions
First install the library and its dependencies and then save the example to main.go and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"// Get a single service definition returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.ServiceDefinitionApi;
import com.datadog.api.client.v2.api.ServiceDefinitionApi.GetServiceDefinitionOptionalParameters;
import com.datadog.api.client.v2.model.ServiceDefinitionGetResponse;
import com.datadog.api.client.v2.model.ServiceDefinitionSchemaVersions;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
ServiceDefinitionApi apiInstance = new ServiceDefinitionApi(defaultClient);
try {
ServiceDefinitionGetResponse result =
apiInstance.getServiceDefinition(
"service-definition-test",
new GetServiceDefinitionOptionalParameters()
.schemaVersion(ServiceDefinitionSchemaVersions.V2_1));
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling ServiceDefinitionApi#getServiceDefinition");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Instructions
First install the library and its dependencies and then save the example to Example.java and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java""""
Get a single service definition returns "OK" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.service_definition_api import ServiceDefinitionApi
from datadog_api_client.v2.model.service_definition_schema_versions import ServiceDefinitionSchemaVersions
configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
api_instance = ServiceDefinitionApi(api_client)
response = api_instance.get_service_definition(
service_name="service-definition-test",
schema_version=ServiceDefinitionSchemaVersions.V2_1,
)
print(response)
Instructions
First install the library and its dependencies and then save the example to example.py and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"# Get a single service definition returns "OK" response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
end
api_instance = DatadogAPIClient::V2::ServiceDefinitionAPI.new
opts = {
schema_version: ServiceDefinitionSchemaVersions::V2_1,
}
p api_instance.get_service_definition("service-definition-test", opts)
Instructions
First install the library and its dependencies and then save the example to example.rb and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"// Get a single service definition returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_service_definition::GetServiceDefinitionOptionalParams;
use datadog_api_client::datadogV2::api_service_definition::ServiceDefinitionAPI;
use datadog_api_client::datadogV2::model::ServiceDefinitionSchemaVersions;
#[tokio::main]
async fn main() {
let configuration = datadog::Configuration::new();
let api = ServiceDefinitionAPI::with_config(configuration);
let resp = api
.get_service_definition(
"service-definition-test".to_string(),
GetServiceDefinitionOptionalParams::default()
.schema_version(ServiceDefinitionSchemaVersions::V2_1),
)
.await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
Instructions
First install the library and its dependencies and then save the example to src/main.rs and run following commands:
DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us3.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us5.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="datadoghq.eu" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ap1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ap2.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="uk1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run/**
* Get a single service definition returns "OK" response
*/
import { client, v2 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration({
authMethods: {
AuthZ: {
accessToken: process.env.DD_BEARER_TOKEN as string,
},
},
});
const apiInstance = new v2.ServiceDefinitionApi(configuration);
const params: v2.ServiceDefinitionApiGetServiceDefinitionRequest = {
serviceName: "service-definition-test",
schemaVersion: "v2.1",
};
apiInstance
.getServiceDefinition(params)
.then((data: v2.ServiceDefinitionGetResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
Instructions
First install the library and its dependencies and then save the example to example.ts and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"