-
Notifications
You must be signed in to change notification settings - Fork 0
JobMon API
The JobMon API is, in most cases, not intended to be used directly by your code. It is used by the JobMon Dashboard which you can use to configure and monitor your jobs, the JobMon Agent which is installed on any server you wish to run JobMon jobs, the JobMon Scheduler which is used to identify when a job should be started and handles other necessary tasks for JobMon, and by the JobMon frameworks that you can reference in your code to make working with JobMon easier. If you do need to work directly with the JobMon API, this guide should help you understand it better.
The JobMon API follows common REST principles. It has a strong naming convention, so if you are looking for a list of all the jobs, you would call GET /api/jobs, agents would be GET /api/agents, etc. To create a new job, you would call POST /api/jobs and send the necessary JSON in the body using the header Content-Type=application/json. To determine which JobMon entities support what HTTP methods, check out the individual sections.
- Job: an automated task
- Agent: a server that can run JobMon jobs
- Install: a job that is installed on an agent.
- Instance: a running job.
- Message: a logged message.
Each JobMon entity supports the ability to query it. Using the GET /api/xxx call, you can pass a MongoDB JSON query object in order to query the database. Pass this query using the q=... parameter (make sure you URL encode the JSON object).
Example: GET /api/instances?q=%7B%22started%22%3A%7B%22%24ne%22%3Anull%7D%2C%22completed%22%3A%7B%22%24eq%22%3Anull%7D%7D
You can also pass a select=... parameter in order to limit which fields are returned. This is a space-delimited list of fields that you would like to return. If you want to use a blacklist, just place a - in front of the field name and that field will be excluded.
Example: GET /api/instances?select=started%20completed
Some queries might return an excessive number of records. In order to prevent major performance issues, JobMon limits the number of records that are returned to 50. If you want to change the default page size, you can send in a query string parameter of pageSize=##. The maximum value for this is 1000.
Example: GET /api/instances?pageSize=100
You can navigate pages by sending in the query string parameter page=##. This will just to whatever page you requested.
Example: GET /api/instances?page=3
The JSON response will include the data, plus a number of other fields that are useful in determining paging.
- data: Contains the data that you requested.
- page: The page number that this data represents.
-
pageSize: The maximum number of records in the page. Check
data.lengthfor the actual number of records. - total: The total number of records that were found in the query.
-
links: Includes
prevandnextlinks in order to navigate the pages. You can check for the existence of theprevornextto determine if there are any other pages.
Example: GET /api/messages?pageSize=1 (uses test data, page size set to show paging)
{
"data": [
{
"_id": "58004dfdb34879ac2cd4349f",
"job": "58004dfdb34879ac2cd43490",
"instance": "58004dfdb34879ac2cd4349d",
"logLevel": "Info",
"message": "This is a test info message",
"__v": 0,
"created": "2016-10-14T03:16:13.932Z"
}
],
"page": 1,
"pageSize": 1,
"total": 2,
"links": {
"prev": null,
"next": "http://localhost:8000/api/messages?pageSize=1&page=2"
}
}