L’endpoint de check de service vous permet d’envoyer des statuts de check afin de les utiliser avec les monitors.
Les messages de check de service ne peuvent pas dépasser 500 caractères. Si un check est envoyé avec un message contenant plus de 500 caractères, seuls les 500 premiers caractères seront affichés. Les messages sont envoyés uniquement pour les checks dont le statut est Critical ou Warning, mais pas pour les checks dont le statut est OK.
[En savoir plus sur les monitors de check de service.][1]
[En savoir plus sur les monitors de check de processus.][2]
[En savoir plus sur les monitors de check réseau.][3]
[En savoir plus sur les monitors de check custom.][4]
[En savoir plus sur les checks de service et les codes de statut.][5]
// Submit a Service Check returns "Payload accepted" response
packagemainimport("context""encoding/json""fmt""os""github.com/DataDog/datadog-api-client-go/v2/api/datadog""github.com/DataDog/datadog-api-client-go/v2/api/datadogV1")funcmain(){body:=[]datadogV1.ServiceCheck{{Check:"app.ok",HostName:"host",Status:datadogV1.SERVICECHECKSTATUS_OK,Tags:[]string{"test:ExampleServiceCheck",},},}ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()apiClient:=datadog.NewAPIClient(configuration)api:=datadogV1.NewServiceChecksApi(apiClient)resp,r,err:=api.SubmitServiceCheck(ctx,body)iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `ServiceChecksApi.SubmitServiceCheck`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `ServiceChecksApi.SubmitServiceCheck`:\n%s\n",responseContent)}
"""
Submit a Service Check returns "Payload accepted" response
"""fromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v1.api.service_checks_apiimportServiceChecksApifromdatadog_api_client.v1.model.service_checkimportServiceCheckfromdatadog_api_client.v1.model.service_check_statusimportServiceCheckStatusfromdatadog_api_client.v1.model.service_checksimportServiceChecksbody=ServiceChecks([ServiceCheck(check="app.ok",host_name="host",status=ServiceCheckStatus.OK,tags=["test:ExampleServiceCheck",],),])configuration=Configuration()withApiClient(configuration)asapi_client:api_instance=ServiceChecksApi(api_client)response=api_instance.submit_service_check(body=body)print(response)
require'rubygems'require'dogapi'api_key='<DATADOG_API_KEY>'app_key='<DATADOG_APPLICATION_KEY>'dog=Dogapi::Client.new(api_key,app_key)# submitting a check doesn't require an app_keydog=Dogapi::Client.new(api_key)dog.service_check('app.is_ok','app1',0,:message=>'Response: 200 OK',:tags=>['env:test'])
# Submit a Service Check returns "Payload accepted" responserequire"datadog_api_client"api_instance=DatadogAPIClient::V1::ServiceChecksAPI.newbody=[DatadogAPIClient::V1::ServiceCheck.new({check:"app.ok",host_name:"host",status:DatadogAPIClient::V1::ServiceCheckStatus::OK,tags:["test:ExampleServiceCheck",],}),]papi_instance.submit_service_check(body)
// Submit a Service Check returns "Payload accepted" response
usedatadog_api_client::datadog;usedatadog_api_client::datadogV1::api_service_checks::ServiceChecksAPI;usedatadog_api_client::datadogV1::model::ServiceCheck;usedatadog_api_client::datadogV1::model::ServiceCheckStatus;#[tokio::main]asyncfnmain(){letbody=vec![ServiceCheck::new("app.ok".to_string(),"host".to_string(),ServiceCheckStatus::OK,vec!["test:ExampleServiceCheck".to_string()],)];letconfiguration=datadog::Configuration::new();letapi=ServiceChecksAPI::with_config(configuration);letresp=api.submit_service_check(body).await;ifletOk(value)=resp{println!("{:#?}",value);}else{println!("{:#?}",resp.unwrap_err());}}
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com"DD_API_KEY="<DD_API_KEY>"cargo run
/**
* Submit a Service Check returns "Payload accepted" response
*/import{client,v1}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv1.ServiceChecksApi(configuration);constparams: v1.ServiceChecksApiSubmitServiceCheckRequest={body:[{check:"app.ok",hostName:"host",status: 0,tags:["test:ExampleServiceCheck"],},],};apiInstance.submitServiceCheck(params).then((data: v1.IntakePayloadAccepted)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));