Collector for NGINX logs to Clickhouse written by Elixir
High-performance and scalable log collector with on-the-fly parsing that stores records in ClickHouse for subsequent analysis.
- Put your database settings to
config/config.exs - Put your secrets to
envs/.env(seeenvs/example.env) - See
nginx.conffor update your nginx config andclickhouse_schema.sqlfor Clickhouse migration. You need synchronize schema fornginx.confandclickhouse_schema.sql. If you need modify access log schema, usemix generate_configs(lib/mix/tasks/generate_configs.ex).
This is a typical Elixir application that use mix:
- Clone this repo;
- Run
mix deps.get; - Run
mix compileoriex -S mixfor devel. process; - For build prod version run
mix release.
For production use ./scripts:
- Clone this repo;
cd logexch./scripts/build.sh- [OPTIONAL]:
mix generate_configsfor generate systemd unit and nginx/clickhouse compatible schema ./scripts/install.sh
Now you can run and stop logexch system service:
systemctl start logexch.service
systemctl status logexch.service
systemctl stop logexch.service
- You describe the data schema you want to store in Clickhouse or use the default one.
- You generate configurations and build this application.
- Modify your nginx.conf. Migrate by Clickhouse schema.
- Run system service
logexch. The application listens to a UDP port, where NGINX will send logs in JSON format. - Logs are parsed, collected in a queue, and written to your Clichhouse locally or remotely.
- The throughput is amazing.