Datadog API Node.JS Client
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

52 lines
1.3 KiB

const client = require("../client");
/*section: infrastructure
*comment: |
* search for metrics or hosts
*params:
* query: |
* the query to use for search see [datadog docs](http://docs.datadoghq.com/api/#search)
* for examples of the query (e.g. "hosts:database", "metrics:system" or "test")
* callback: function(err, res)
*example: |
* ```javascript
* const dogapi = require("dogapi");
* const options = {
* api_key: "api_key",
* app_key: "app_key"
* };
* dogapi.initialize(options);
* dogapi.infrastructure.search("hosts:database", function(err, res){
* console.dir(res);
* });
* ```
*/
function search(query, callback){
const params = {
query: {
q: query
}
};
client.request("GET", "/search", params, callback);
}
module.exports = {
search: search,
getUsage: function(){
return [
" dogapi infrastructure search <query>"
]
},
getHelp: function(){
return [
"Infrastructure:",
" Subcommands:",
" search <query> query for hosts or metrics with <query> (see http://docs.datadoghq.com/api/#search)",
];
},
handleCli: function(subcommand, args, callback){
const query = args._[4];
search(query, callback);
}
};