Skip to content

Installation & Usage

Lorenzo Mangani edited this page Apr 18, 2022 · 28 revisions


Installation

This wiki page will help new users install and activate their clickhouse-powered cLoki as a service

Docker

If you use Docker, just add our container to your stack and send traffic. cLoki instances are stateless and load-balancer friendly.

cloki:
    image: qxip/cloki:latest
    ports:
      - "3100:3100"
    environment:
      - CLICKHOUSE_SERVER=http://user:pass@clickhouse:8123

Manual

READY

The following requirements must be in place before proceeding:

  • clickhouse-server server w/ HTTP + authentication
  • nodejs 14.x or 16.x w/ npm installed

SET

Install cloki and pm2 using npm

sudo npm install -g cloki pm2

Start cloki with pm2 and connect using your clickhouse-server instance details (ip/hostname and authentication)

cd $(dirname $(readlink -f `which cloki`)) \
  && CLICKHOUSE_SERVER="localhost" CLICKHOUSE_AUTH="default:password" CLICKHOUSE_DB="cloki" \
  pm2 start cloki --name "cloki"

Alternatively, cloki instances can be initiated and managed using pm2 ecosystem files

module.exports = {
  apps : [{
    name   : "cloki_custom",
    script : "cd $(dirname $(readlink -f `which cloki`)) && ./cloki.js",
    env: {
      "UUID": "cloki_custom",
      "CLICKHOUSE_SERVER": "localhost",
      "CLICKHOUSE_PORT": 8123,
      "CLICKHOUSE_AUTH": "default:password",
      "CLICKHOUSE_DB": "cloki_custom",
      "CLOKI_USER": "demo",
      "CLOKI_PASSWORD": "demo",
      "LABELS_DAYS": 7,
      "SAMPLES_DAYS": 7,
      "PORT": 3100,
      "DEBUG": false
    }
  }]
}

Check the status of your service

pm2 status cloki

No errors? Great! Save your service and enable it for startup

pm2 save
pm2 startup

GO

Your cloki instance should now be running, ready to write/read logs or access any clickhouse table for metrics

Clone this wiki locally