Checks de service
Rapport de recherche Datadog : Bilan sur l'adoption de l'informatique sans serveur Rapport : Bilan sur l'adoption de l'informatique sans serveur

Checks de service

L’endpoint de check de service vous permet d’envoyer des statuts de check afin de les utiliser avec des 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.

Envoyer un check de service

POST https://api.datadoghq.eu/api/v1/check_runhttps://api.datadoghq.com/api/v1/check_run

Présentation

Envoyez une liste de checks de service.

Remarque : une clé d’API valide est requise.

Requête

Body Data (required)

Corps de requête pour l’envoi de check de service.

Expand All

Champ

Type

Description

check

string

The check.

host_name

string

The host name correlated with the check.

message

string

Message containing check status.

status

enum

The status of a service check. Allowed enum values: 0,1,2,3

tags

[string]

Tags related to a check.

timestamp

int64

Time of check.

{
  "check": "app.ok",
  "host_name": "app.host1",
  "message": "app is running",
  "status": 0,
  "tags": [
    "environment:test"
  ],
  "timestamp": "integer"
}

Réponse

Payload accepted

The payload accepted for intake.

Expand All

Champ

Type

Description

status

string

The status of the intake payload.

{
  "status": "ok"
}

Bad Request

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Authentication Error

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Request timeout

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Payload too large

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Exemple de code


                                        # Curl command
curl -X POST "https://api.datadoghq.eu"https://api.datadoghq.com/api/v1/check_run?api_key=${DD_CLIENT_API_KEY}" \
-H "Content-Type: application/json" \
-d @- << EOF
{
  "check": "app.ok",
  "host_name": "app.host1",
  "status": 0,
  "tags": [
    "environment:test"
  ]
}
EOF
from datadog import initialize, api
from datadog.api.constants import CheckStatus

options = {'api_key': '<DATADOG_API_KEY>',
           'app_key': '<DATADOG_APPLICATION_KEY>'}

initialize(**options)

check = 'app.ok'
host = 'app1'
status = CheckStatus.OK  # equals 0
tags = ['env:test']

api.ServiceCheck.check(check=check, host_name=host, status=status, message='Response: 200 OK', tags=tags)
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_key
dog = Dogapi::Client.new(api_key)

dog.service_check('app.is_ok', 'app1', 0, :message => 'Response: 200 OK', :tags => ['env:test'])