mkdir $HOME/workspace/clickhouse/db/db
docker run -d -p 8123:8123 -p 9000:9000 --name grafana-clickhouse-server --ulimit nofile=262144:262144 --volume=$HOME/workspace/clickhouse/db/db:/var/lib/clickhouse clickhouse/clickhouse-server
docker run -it --rm --link grafana-clickhouse-server:clickhouse-server clickhouse/clickhouse-client --host clickhouse-server
https://clickhouse.com/docs/en/getting-started/example-datasets/brown-benchmark/
Create database and tables using commands from above link (can use a SQL Editor like DBeaver: https://dbeaver.io/)
sudo cat $HOME/workspace/clickhouse/mgbench/mgbench1.csv | docker run -i --rm --link grafana-clickhouse-server:clickhouse-server clickhouse/clickhouse-client -m --host clickhouse-server --query="INSERT INTO mgbench.logs1 FORMAT CSVWithNames"
sudo cat $HOME/workspace/clickhouse/mgbench/mgbench2.csv | docker run -i --rm --link grafana-clickhouse-server:clickhouse-server clickhouse/clickhouse-client -m --host clickhouse-server --query="INSERT INTO mgbench.logs2 FORMAT CSVWithNames"
sudo cat $HOME/workspace/clickhouse/mgbench/mgbench3.csv | docker run -i --rm --link grafana-clickhouse-server:clickhouse-server clickhouse/clickhouse-client -m --host clickhouse-server --query="INSERT INTO mgbench.logs3 FORMAT CSVWithNames"
server address: localhost server port: 9000
docker run -d -p 8443:8443 -p 9440:9440 --name secure-clickhouse-server --ulimit nofile=262144:262144 -v $PWD/config:/etc/clickhouse-server clickhouse/clickhouse-server
- Create the CA cert
./scripts/ca.sh
- Create the Server cert from the CA
./scripts/ca-cert.sh
- The Common/SAN name is "foo". Add an entry to your hosts file on the host.
127.0.0.1 foo
docker run -d -p 8443:8443 -p 9440:9440 -p 9000:9000 -p 8123:8123 --name secure-clickhouse-server --ulimit nofile=262144:262144 -v $PWD/config-secure:/etc/clickhouse-server clickhouse/clickhouse-server
docker exec -it secure-clickhouse-server bash cp /etc/clickhouse-server/my-own-ca.crt /usr/local/share/ca-certificates/root.ca.crt update-ca-certificates
Column hints are used within the query builder and SQL generator to enable flexible and dynamic queries.
Here's an example of some column hints:
ColumnHint.Time
ColumnHint.LogMessage
ColumnHint.LogLevel
ColumnHint.TraceId
The easiest example is the time hint (ColumnHint.Time
). When building a Logs query, we need to know what the primary log time column is:
const logTimeColumn: SelectedColumn = { name: 'my_time_column_on_my_table', hint: ColumnHint.Time, alias: 'logTime' };
Using the column hint, we can add an ORDER BY
statement to the query without having to know the actual column name:
const logsOrderBy: OrderBy = { name: '', hint: ColumnHint.Time, dir: OrderByDirection.ASC };
Notice how name
can be left empty, this is because the SQL generator knows to find the final column/alias by the time hint:
// Input options
const queryBuilderOptions: QueryBuilderOptions = {
table: 'logs',
columns: [logTimeColumn],
orderBy: [logsOrderBy],
. . .
};
-- Final output from SQL generator
SELECT my_time_column_on_my_table as logTime FROM logs ORDER BY logTime ASC
By adding a simple hint, we can apply filters, orderBys, and other behaviors to the SQL generator without having to reference specific columns. This simplifies the UI logic and user experience by reducing the number of places where a column name needs to be updated.