Using ClickHouse Cloud with ntopng

Posted · Add Comment

We are happy to announce that from the latest ntopng dev (6.1) version, ntopng supports exporting data (flows & alerts) to ClickHouse Cloud. Below you can find a step-by-step guide.

Quick Start

First of all let’s start by creating our account and service on the ClickHouse Cloud (you can find the official guide here); remember to save the ClickHouse username and password used for accessing your database.

After that we have to jump to the ‘Connect’ section:

Then, we have to select MySQL, turn on “Enable the MySQL protocol” and collect 3 information needed to the ntopng configuration file:

  • The MySQL Username (it’s an other username, different from the one configured at the start)
  • The Hostname (used to connect to the right Host)
  • The Port (MySQL port, to connect in order to run queries)

After collecting these 3 info, let’s jump back to ntopng and let’s edit the configuration file.

Here we have to add (or modify if already there) the -F option, by following the ntopng documentation (here):

  • clickhouse-cloud;<host[@[<tcp-port>,]<mysql-port>s]|socket>;<dbname>;<clickhouse-user>,<mysql-user>;<pw>;

So let’s suppose that our previously collected info are the following:

  • ClickHouse username: CH-USER (by default it should be the ‘default’ username, it is provided when creating the Service)
  • MySQL username: MYSQL-USER
  • TCP-Port: by default it’s the 9440
  • MySQL Port: 3306 (default one). Note that you need to add a s after the port as this means that we’re pushing data over TLS.
  • Password: CH-PASSWORD (the password  used to access the DB, provided when creating the Service)
  • Hostname: CH-HOST

Then our -F option should look like:

-F=”clickhouse-cloud;CH-HOST@9440,3306s;ntopng;CH-USER,MYSQL-USER;CH-PASSWORD”

Note:

  • Both data export and query connections are encrypted and protected by TLS.
  • clickhouse-client is needed on the local machine (where ntopng is) in order to correctly push data to the ClickHouse Cloud. This means that you need to install it as described here.

If you want you can read all this in the ntopng user’s guide.

Enjoy!