Skip to content

Conversation

@v0idpwn
Copy link
Contributor

@v0idpwn v0idpwn commented Nov 20, 2025

Add support for running Logflare in single tenant mode with ClickHouse as the backend. This follows the same virtual backend pattern used for PostgreSQL single tenant mode, where backend_id is nil and configuration is read from environment variables.

Query/search functionality is excluded from this implementation, as bigger changes are required to support them.

Add support for running Logflare in single tenant mode with ClickHouse as the
backend for log ingestion. This follows the same virtual backend pattern used
for PostgreSQL single tenant mode, where backend_id is nil and configuration
is read from environment variables.

Query/search functionality is intentionally excluded from this implementation.
@v0idpwn v0idpwn marked this pull request as ready for review November 21, 2025 19:08
@v0idpwn v0idpwn changed the title feat: add ClickHouse single tenant mode ingestion support feat: add ClickHouse single tenant mode (ingestion only) Nov 21, 2025
Copy link
Contributor

@Ziinc Ziinc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor tweaks needed

)

System.get_env("LOGFLARE_SINGLE_TENANT", "false") == "true" &&
not is_nil(System.get_env("CLICKHOUSE_URL")) ->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
not is_nil(System.get_env("CLICKHOUSE_URL")) ->
not is_nil(System.get_env("CLICKHOUSE_BACKEND_URL")) ->

config :logflare,
:clickhouse_backend_adapter,
filter_nil_kv_pairs.(
url: System.get_env("CLICKHOUSE_URL"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
url: System.get_env("CLICKHOUSE_URL"),
url: System.get_env("CLICKHOUSE_BACKEND_URL"),

:clickhouse_backend_adapter,
filter_nil_kv_pairs.(
url: System.get_env("CLICKHOUSE_URL"),
database: System.get_env("CLICKHOUSE_DATABASE"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
database: System.get_env("CLICKHOUSE_DATABASE"),
database: System.get_env("CLICKHOUSE_BACKEND_DATABASE"),

filter_nil_kv_pairs.(
url: System.get_env("CLICKHOUSE_URL"),
database: System.get_env("CLICKHOUSE_DATABASE"),
username: System.get_env("CLICKHOUSE_USERNAME"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
username: System.get_env("CLICKHOUSE_USERNAME"),
username: System.get_env("CLICKHOUSE_BACKEND_USERNAME"),

url: System.get_env("CLICKHOUSE_URL"),
database: System.get_env("CLICKHOUSE_DATABASE"),
username: System.get_env("CLICKHOUSE_USERNAME"),
password: System.get_env("CLICKHOUSE_PASSWORD")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
password: System.get_env("CLICKHOUSE_PASSWORD")
password: System.get_env("CLICKHOUSE_BACKEND_PASSWORD")

end

def clickhouse_conn_manager_children do
if SingleTenant.clickhouse_backend?() do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This child spec shouldn't be needed as it should be supervised by QueryConnectionSup


start.st.ch: ERL_NAME = st_ch
start.st.ch: PORT ?= 4000
start.st.ch: ENV_FILE = .single_tenant_ch.env
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will. Need a ch env file as well

@Ziinc
Copy link
Contributor

Ziinc commented Nov 25, 2025

Also need to add self hosting documentation and new env vars to table

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants