Open daluu opened 8 years ago
Warning: It's been a while since I've dug through the code but here goes
I think it works roughly like this:
tcpClient = riemann.createClient({transport:'tcp'});
// Wait for connection to be ready etc
var query = {
string:"my query as a string"
}
tcpClient.Query(query)
I don't think I've ever actually used the query feature so I don't know for sure, but from what I can read of the protobuf message spec you just supply the query as string (yeah, that is ugly). I don't know how you format multiple conditions in that string unfortunately but I think this file may prove helpful in working it out https://github.com/riemann/riemann/blob/5c6a1c6a63953f48f18a2983fa2589e89b06a997/src/riemann/query.clj (I think that file is the one responsible for parsing whatever string we stick in the query object.
Let me know if you this is at all helpful
Thanks for the response, I did get it roughly working earlier with this type of code:
//already have riemann client instantiated, for TCP
function runQuery(callback){
client.on('data', function(result) {
callback(result);
});
client.send(client.Query({string: 'service = "some service name"'}));
}
runQuery(function(data){
console.log(JSON.stringify(data));
client.disconnect(); //this is assume we do nothing besides run a single query in node.js
});
As this is a fork of the original, and the original seemed to incorporate query support in some form (albeit without any examples)
I'm assuming this version also has query support? If there is support, please clarify how to query riemann with an example. If no support, please consider adding it.
Looking through the source code, I haven't figured out how to perform a query thus far.