diff --git a/README.md b/README.md index f1e19cf..84c1b23 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,48 @@ cd ./node-dogapi npm install ``` +## API + +`dogapi` implements all available functions in the official datadog api, http://docs.datadoghq.com/api/. + +* `dogapi.stream(start, end, [[filter], callback])` + * function used to retrieve all events that have occured between +* `dogapi.get_event(event_id, callback)` + * method used to retrieve a single event's data +* `dogapi.add_event(event, callback)` + * method used to add a new event to datadog +* `dogapi.add_comment(comment, [callback])` + * method used to add a new comment to datadog +* `dogapi.update_comment(comment_id, comment, callback)` + * method used to update a comment that already exists in datadog +* `dogapi.delete_comment(comment_id, callback)` + * method used to remove a comment from datadog +* `dogapi.add_alert(alert, [callback])` + * add a new alert to datadog +* `dogapi.update_alert(alert_id, alert, [callback])` + * update an existing alert +* `dogapi.get_alert(alert_id, [callback])` + * get the details of an alert from the given id +* `dogapi.delete_alert(alert_id, [callback])` + * delete the given alert from datadog +* `dogapi.get_all_alerts([callback])` + * get the details of all alerts in datadog +* `dogapi.mute_alerts([callback])` + * mute all alerts +* `dogapi.unmute_alerts([callback])` + * unmute all alerts +* `dogapi.get_dashboard(dash_id, [callback])` + * method to get a single dashboard information +* `dogapi.get_all_dashboards([callback])` + * method to retrieve all dashboards in datadog +* `dogapi.create_dashboard(dashboard, [callback])` + * method used to create a new dashboard in datadog +* `dogapi.update_dashboard(dash_id, dashboard, [callback])` + * method used to update the dashboard with the provided `dash_id` +* `dogapi.delete_dashboard(dash_id, [callback])` + * method to remove a dashboard from datadog + + ## Sample Usage: **Example:** get all events since this time yesterday: @@ -41,10 +83,9 @@ api.stream(start, end, function(error, result, status_code){ console.log('Status Code: ', status_code); return; } - + result['events'].forEach(function(event){ console.log(event['id'] + ': ' + event['title']); }); }); - ``` diff --git a/lib/api/metric.js b/lib/api/metric.js index 883ab93..7e391a3 100644 --- a/lib/api/metric.js +++ b/lib/api/metric.js @@ -4,6 +4,21 @@ var v8type = require('v8type'); var metric_api = function(){}; metric_api.prototype.add_metric = function(metric, callback){ + /* + * metric_api.add_metric(metric, [callback]) + * + * method used to add a single metric to datadog + * + * `metric` an object representation of the metric + * metric: *required*, the name of the metric + * points: *required*, an array of elements [ timestamp, value ] + * host: name of the host that produced the event + * tags: array of tags to associate with the event + * type: "guage" or "counter" + * + * `callback` an optional function to call with the results + * callback(metric, [callback]) + */ var metrics = { 'series': [metric] }; @@ -11,6 +26,17 @@ metric_api.prototype.add_metric = function(metric, callback){ }; metric_api.prototype.add_metrics = function(metrics, callback){ + /* + * metric_api.add_metrics(metrics, [callback]) + * + * method used to add multiple metrics to datadog + * + * `metrics` an object representation of the metric: + * series: an array of `metrics` to add + * + * `callback` an optional function to call with the results + * callback(metric, [callback]) + */ if(!v8type.is(metrics, v8type.OBJECT)){ throw new Error('`metrics` parameter must be an object'); }