Search code examples
node.jscassandracassandra-driver

How to check the status of cassandra using node.js?


I am using cassandra-driver module in node.js. My usecase is that I have emit notification in the UI saying "DB is in down state" when Cassandra node goes down due to some reason.

Basically, I should be able to capture the information as soon as the casssandra goes down using cassandra-driver in node.js

Any help is appreciated .


Solution

  • client.hosts does not work, for the temporary solution I am using

    client.on('log', (level, className, message, furtherInfo) => {
    
    if(level === 'error' && ['NoHostAvailableError', 'OperationTimedOutError'].includes(furtherInfo.name)) {
    
    emitNotification('DB_IS_DOWN');
    
    });
    

    If any one has better solution, you are highly welcome.

    Note: This solution works for me very well !!