Runs REST API monitoring tests on an interval and notifies you when there are error. The REST API monitors are defined with frisby.js. Frisby.js is very robust and flexible that is designed to specifically test REST API with an easy syntax.
API-Monitor-Runner is a node.js application but it can test any REST API application.
First clone out this repository:
git clone https://github.com/AutoDevBot/API-Monitor-Runner.git
Install this applications npm modules. Change directory into this repo and run:
npm install
Run the application:
node app.js
Another easy way to run this is with Docker.io. This is a pre-built container containing the latest code from this project ready to go. You can find the project here:
https://registry.hub.docker.com/u/garland/api-monitor-runner
Any of the parameters in the config.js.sample file can be passed into the application via the docker env parameters on start.
One easy way to try this docker container without having to setup a Docker server is to run it on a Docker.io container hosting service such as Tutum.
With Docker containers, you only need to pass in the environment params that you want to change from the default config.js file.
docker run \
--env GITHUB_URL=https://github.com/AutoDevBot/API-Monitor-Runner.git \
--env GITHUB_TOKEN=my_auth_token \
garland/api-monitor-runner
The config.js file controls how the application behaves. There is a default config.js file at the root of this application. These settings can be set in the file or via the system environment variables. If a parameter is set via the environment variable it will override what is in the config.js file.
GITHUB_URL
=> An http URL to a Github repository holding API monitoring tests you want this application to run.GITHUB_TOKEN
=> This token allows you to access your private github.com repos with an application key. Generate an github access token to clone a private repo: https://help.github.com/articles/creating-an-access-token-for-command-line-use
REPOSITORY_PATH
=> Local directory to clone the repository toRESULT_OUTPUT_PATH
=> Local directory to put the results
MONITOR_INTERVAL
=> Sets how often to run the monitoring tests. This value is in milliseconds
SERVER_PORT
=> local application server's portSERVER_HOST
=> IP to bind server to
TRIGGER_ON_ALL
=> true|false - If set to true, every monitor that runs is triggered and the "trigger actions" will take effect even for successfull monitors runsTRIGGER_ON_ERROR
=> true|false - only trigger if there are monitor errorsTRIGGER_ON_FAILURES
=> true|false - only trigger if there are monitor failures
TRIGGER_EMAIL
=> true|false - enable email notification. Configuration belowTRIGGER_PAGER_DUTY
=> true|false - enable PagerDuty notification. Configuration belowTRIGGER_WEBHOOK
=> true|false - enable a generic webhook notification. Configuration belowTRIGGER_HIPCHAT
=> true|false - enable HipChat notification. Configuration below
THRESHOLD_ERRORS
=> int - set to 0 or moreTHRESHOLD_FAILURES
=> int - set to 0 or more
ACTION_WEBHOOK_PROTOCOL
=> http|httpsACTION_WEBHOOK_METHOD
=> GET|POST|PUTACTION_WEBHOOK_HOST
=> fully qualified hostname: example.comACTION_WEBHOOK_ENDPOINT
=> REST endpoint to call. Example: /notification
Action config - email to emailer server - https://github.com/AutoDevBot/Email-Notification
ACTION_EMAIL_PROTOCOL
=> http|httpsACTION_EMAIL_HOST
=> GET|POST|PUTACTION_EMAIL_ENDPOINT
=> /email - this is fixed for this serverACTION_EMAIL_HTTP_METHOD
=> httpACTION_EMAIL_FROM
=> From email addressACTION_EMAIL_TO
=> To email addressACTION_EMAIL_SUBJECT
=> Subject line in email
Documentation for the PagerDuty values are here
ACTION_PAGERDUTY_PROTOCOL
=> httpsACTION_PAGERDUTY_HOST
=> events.pagerduty.com - this is fixed for the PagerDuty API hostACTION_PAGERDUTY_METHOD
=> POST - this is fixed for this action's methodACTION_PAGERDUTY_ENDPOINT
=> /generic/2010-04-15/create_event.json - this is fixed for this action's endpointACTION_PAGERDUTY_SERVICE_KEY
=> see PagerDuty's documentationACTION_PAGERDUTY_INCIDENT_KEY
=> see PagerDuty's documentationACTION_PAGERDUTY_EVENT_TYPE
=> see PagerDuty's documentationACTION_PAGERDUTY_DESCRIPTION
=> see PagerDuty's documentationACTION_PAGERDUTY_CLIENT
=> see PagerDuty's documentationACTION_PAGERDUTY_CLIENT_URL
=> see PagerDuty's documentation
documentation for the HipChat values are here
ACTION_HIPCHAT_PROTOCOL
=> httpsACTION_HIPCHAT_HOST
=> api.hipchat.com - this is fixed for the HipChat APIACTION_HIPCHAT_METHOD
=> POST - this is fixed for the HipChat APIACTION_HIPCHAT_ENDPOINT
=> /v2/room/{id_or_name}/notification - you will need to replace {id_or_name} with the room you want the notification to gotoACTION_HIPCHAT_AUTHTOKEN
=> authentication token for your HipChat account. See HipChat documentation on how to get this.ACTION_HIPCHAT_MSG_COLOR
=> see HipChat documenationACTION_HIPCHAT_MSG_NOTIFY
=> see HipChat documenationACTION_HIPCHAT_MSG_FORMAT
=> see HipChat documenation