-

-Cachet Monitor plugin

- -

This is a monitoring plugin for CachetHQ.

- -

+
+
+
+

screenshot

-Features

+Features
  • [x] Creates & Resolves Incidents
  • -
  • [x] Posts monitor lag every second
  • +
  • [x] Posts monitor lag to cachet graphs
  • [x] Updates Component to Partial Outage
  • -
  • [x] Updates Component to Major Outage if in Partial Outage
  • +
  • [x] Updates Component to Major Outage if already in Partial Outage (works well with distributed monitoring)
  • [x] Can be run on multiple servers and geo regions

-Docker Quickstart

- -
    -
  1. Create a configuration json
  2. -
  3. -
- -
docker run -d \
-  --name cachet-monitor \
-  -h cachet-monitor \
-  -v `pwd`/config.json:/etc/cachet-monitor.config.json \
-  castawaylabs/cachet-monitor
-
- -

-Configuration

+Configuration
{
-  "api_url": "https://demo.cachethq.io/api",
-  "api_token": "9yMHsdioQosnyVK4iCVR",
-  "monitors": [
-    {
-      "name": "nodegear frontend",
-      "url": "https://nodegear.io/ping",
-      "metric_id": 0,
-      "component_id": 0,
-      "threshold": 80,
-      "component_id": null,
-      "expected_status_code": 200,
-      "strict_tls": true
-    }
-  ],
-  "insecure_api": false
+  // URL for the API. Note: Must end with /api/v1
+  "api_url": "https://<cachet domain>/api/v1",
+  // Your API token for Cachet
+  "api_token": "<cachet api token>",
+  // optional, false default, set if your certificate is self-signed/untrusted
+  "insecure_api": false,
+  "monitors": [{
+    // required, friendly name for your monitor
+    "name": "Name of your monitor",
+    // required, url to probe
+    "url": "Ping URL",
+    // optional, http method (defaults GET)
+    "method": "get",
+    // self-signed ssl certificate
+    "strict_tls": true,
+    // seconds between checks
+    "interval": 10,
+    // post lag to cachet metric (graph)
+    // note either metric ID or component ID are required
+    "metric_id": <metric id>,
+    // post incidents to this component
+    "component_id": <component id>,
+    // If % of downtime is over this threshold, open an incident
+    "threshold": 80,
+    // optional, expected status code (either status code or body must be supplied)
+    "expected_status_code": 200,
+    // optional, regular expression to match body content
+    "expected_body": "P.*NG"
+  }],
+  // optional, system name to identify bot (uses hostname by default)
+  "system_name": "",
+  // optional, defaults to stdout
+  "log_path": ""
 }
 
-

Notes:

- -
    -
  • -metric_id is optional
  • -
  • -insecure_api if true it will ignore HTTPS certificate errors (eg if self-signed)
  • -
  • -strict_tls if false (true is default) it will ignore HTTPS certificate errors (eg if monitor uses self-signed certificate)
  • -
  • -component_id is optional
  • -
  • -threshold is a percentage
  • -
  • -expected_status_code is a http response code
  • -
  • GET request will be performed on the url -
  • -
-

-How to run

- -

Example:

+Installation
    -
  1. Set up Go +
  2. Download binary from release page
  3. -
  4. go install github.com/castawaylabs/cachet-monitor
  5. -
  6. cachet-monitor -c https://raw.githubusercontent.com/CastawayLabs/cachet-monitor/master/example.config.json
  7. +
  8. Create your configuration (example)
  9. +
  10. cachet-monitor -c /etc/cachet-monitor.config.json
-

Production:

- -
    -
  1. Download the example config and save to /etc/cachet-monitor.config.json -
  2. -
  3. Run in background: nohup cachet-monitor 2>&1 > /var/log/cachet-monitor.log & -
  4. -
+

pro tip: run in background using nohup cachet-monitor 2>&1 > /var/log/cachet-monitor.log &

Usage of cachet-monitor:
   -c="/etc/cachet-monitor.config.json": Config path
@@ -121,7 +100,7 @@
 

-Environment variables

+Environment variables @@ -134,26 +113,55 @@ - + - + + + + + +
CACHET_APIhttp://demo.cachethq.io/apihttp://demo.cachethq.io/api/v1 URL endpoint for cachet api
CACHET_TOKENrandomvalueAPIToken123 API Authentication token
CACHET_DEV1Strips logging
- +

We made this tool because we felt the need to have our own monitoring software (leveraging on Cachet). +The idea is a stateless program which collects data and pushes it to a central cachet instance.

-
+

This gives us power to have an army of geographically distributed loggers and reveal issues in both latency & downtime on client websites.

+ +

+Package usage

+ +

When using cachet-monitor as a package in another program, you should follow what cli/main.go does. It is important to call ValidateConfiguration on CachetMonitor and all the monitors inside.

+ +

API Documentation

+