How Can I Submit A Custom Status Check?

Custom status checks can be submitted either through the Datadog API, DogStatsD, or through a custom agent check. All status checks must have one of the following status codes:

'0': 'OK'

'1': 'Warning'

'2': 'Critical'

'3': 'Unknown

 

Submitting a check with the API

When submitting a status check through the Datadog API, you must specify a check name, the host submitting the check, and the status; with optional parameters including a timestamp, a message describing the status, and any tags you wish to associate with the check. An example call with all of these options through the shell API would look like:

currenttime=$(date +%s)
curl  -X POST -H "Content-type: application/json" \
-d "{
      \"check\": \"app.is_ok\",
      \"host_name\": \"app1\",
      \"status\": 0,
\"timestamp\": $currenttime,
\"message\": \"App1 is up and running\",
\"tags\":[\"environment:production\", \"role:webserver\"] }" \
'https://app.datadoghq.com/api/v1/check_run?api_key=<api_key>'



Submitting a check with DogStatsD

When submitting a status check through DogStatsD, you must specify a check name and a check status with optional parameters including tags you wish to associate with the check, a timestamp for the check status, the host submitting the check, and a message describing the status. An example call using the datadogpy library would look like:

statsd.service_check('app.is_ok', 0, tags=['environment:production','role:webserver'], hostname='app1', message='App1 is up and running')

 

Submitting a check through a custom agent check

When submitting a status check through a custom agent check, the predefined service_check function in the AgentCheck class can be used to pass the agent check along to Datadog. A call to this function must include a check name and a check status with optional parameters including tags you wish to associate with the check, a timestamp for the check status, the host submitting the check, and a message describing the status. An example call to the service_check function within a custom agent check would look like:

self.service_check('app.is_ok', 0, tags=['environment:production','role:webserver'], hostname='app1', message='App1 is up and running')
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.
Powered by Zendesk