cachet-api fork
Why?
The docker image provided by cachet has a nginx with cache set up
in front of it. We want to get incidents in "realtime", so we don't
want cached results.
The PR adding this feature was not accepted by the author of the
original lib (and that's ok), so we forked it.
Original readme:
cachet-api
A Node.js API client for Cachet.
Cachet is a beautiful and powerful open source status page system, a free replacement to services such as StatusPage.io, Status.io and others.
Usage
First, install the package using npm:
npm install cachet-api --save
Then, start using the package by importing and configuring it:
var CachetAPI = require('cachet-api');
var cachet = new CachetAPI({
url: 'https://demo.cachethq.io',
apiKey: 'a1b2c3d4e5f6g7h8i9'
});
Make sure to fill in your Cachet status page url
as well as your Cachet admin account's apiKey
, which you can find in the Cachet dashboard.
Get Component Info
Use cachet.getComponentById(id)
to fetch details about an existing component:
var componentId = 1;
cachet.getComponentById(componentId)
.then(function (component) {
console.log('Component', component);
}).catch(function (err) {
console.log('Fatal Error', err);
});
Publish a Metric Point
Use cachet.publishMetricPoint(point)
to publish a new metric point to an existing metric:
var metricPoint = {
id: 1,
value: 3.37,
timestamp: Math.round(new Date().getTime() / 1000)
};
cachet.publishMetricPoint(metricPoint)
.then(function (response) {
console.log('Metric point published at ' + response.data.created_at);
}).catch(function (err) {
console.log('Fatal Error', err);
});
Report an Incident
Use cachet.reportIncident(incident)
to report a new status incident:
var incident = {
name: 'Database connectivity issues',
message: 'We\'re investigating connectivity issues with the main DB.',
status: 'Investigating',
visible: true,
notify: true,
component_id: 1,
component_status: 'Partial Outage'
};
cachet.reportIncident(incident)
.then(function (response) {
console.log('New incident reported at ' + response.data.created_at);
}).catch(function (err) {
console.log('Fatal Error', err);
});
License
Apache 2.0