-
Notifications
You must be signed in to change notification settings - Fork 33
Marathon tasks example
Ben Tullis edited this page Oct 1, 2015
·
1 revision
Marathon is a cluster-aware init system for creating distributed, fault-tolerant applications on to of Apache Mesos.
It features a REST API that provides JSON formatted output.
One way of using the check_http_json
script with this API is to verify that the number of tasks running for each application is within a particular threshold. An example is shown below.
Sample Command Definition
# Marathon Task Check #
define command {
command_name check_marathon_tasks
command_line $USER2$/check_http_json.rb -u 'http://marathon:8080/v2/apps/$ARG1$' -e app.tasksRunning -p app.instances,app.tasksRunning --status_level 404:2 -w '$ARG2$' -c '$ARG3$'
}
The --status_level 404:2
allows the check to return a critical condition if the application has been deleted from Marathon altogether. In this instance Marathon returns a 404 response for the API query.
The -p app.instances,app.tasksRunning
allows these values to be included in the performance metrics sent by the check command.
Sample Service Definition
# Check that the correct number of tasks is running.
# Return a warning if it is not exactly 20
# Return a critical if it is less than 15 or more than 25
define service {
name myapp-tasks
description My Application Tasks
hosts marathon
check_command check_marathon_tasks!myapp!20:20!15:25
}