Skip to content

JobMon API Job

Brian Brewder edited this page Oct 17, 2016 · 1 revision

A job in JobMon represents an automated task. A job can be any task that can be launched using a command-line. This includes scripts, executables, etc. If you can define a command-line for it, it can be a job.

Job Schema

  • _id: The unique identifier for the document. Set by MongoDB.
  • name: Used by JobMon to identify a job. This field should not change between versions of the job. This field is not displayed. A GUID is recommended. STRING, REQUIRED, UNIQUE
  • displayName: The name that is displayed for this job. STRING, REQUIRED
  • description: A description of the job. STRING
  • status: Determines the status of the job. ENUM [Enabled, Disabled, Error], REQUIRED
  • minLogLevel: Determines what log messages are stored. ENUM [Trace, Debug, Info, Warn, Error, Fatal], REQUIRED
  • maxInstances: The maximum number of instances that can be running at a time. INT, MIN=1
  • maxInstancesToKeep: The maximum number of instances that will be stored. Oldest instance and associated logs will be deleted as new instances are created. INT, MIN=1
  • maxTimeToCompleteInMinutes: The maximum amount of time allowed for a job to run. INT, MIN=1
  • autoComplete: Determines what to do if the job runs for too long.
    true: Job marked as completed. It will continue to run until it stops, but should stop the next time it checks the server.
    false (default): the job will go into an error state. BOOLEAN
  • fileHash: A hash of the last uploaded job file. Set by JobMon. STRING
  • fileLastUpdated: The last time the file was uploaded. Set by JobMon. DATE

Job Status

There are 3 possible values for job status.

  • Enabled: The job can be started.
  • Disabled: The job cannot be started. Any running instances should shut down the next time they check the server.
  • Error: Something bad happened and the job should be reviewed before re-enabling it. This value should only be set by JobMon.

GET /api/jobs

This will return a list of jobs. Can be used with query parameters.

Possible Errors (status 400):

  • QueryError: Error returned by MongoDB due to a problem with the query.

POST /api/jobs

Installs a job in JobMon. Review Create A Job to learn how to create the job file. The only thing that is supported for this API call is a single upload file named "job". The jobmon.json file should contain all the required values to successfully create a new job.

Possible Errors (status 400):

  • FileMissing: The Job file wasn't uploaded.
  • InvalidJobFile: The job file doesn't contain a jobmon.json file.
  • CopyFile: Unable to copy the job file to the download directory.

GET /api/jobs/{job._id}

Gets the document for the requested job. This document will include a link to the download file for the job.

PATCH /api/jobs/{job._id}

Updates just the supplied values. The only field that can be updated is the status field. If any other fields need to be updated, re-upload the job with the corrected values.

DELETE /api/jobs/{job._id}

Removes the job, including any files, logs, instances, etc.

Clone this wiki locally