Skip to content

Conversation

@hclaria
Copy link

@hclaria hclaria commented Oct 31, 2025

Hey team 👋

First off : huge thanks for ClickHouse and kubenetmon maintainers 🙏


Context

In our setup, we’re running a single shared ClickHouse cluster dedicated to kubenetmon.
This cluster is shared across roughly a dozen EKS clusters, and each EKS cluster writes to its own database (one DB per cluster).
This lets us isolate data and manage permissions cleanly : each kubenetmon instance has INSERT rights only on its own DB.


The issue

Currently, even if the database field is set in the configuration, the worker.flush() function always writes to:

INSERT INTO default.network_flows_0 (...)

So all inserts end up in the default database, regardless of what was configured.
In our case, that meant the service tried to write into DBs it didn’t have permissions for, causing errors like:

code: 497, message: Not enough privileges. To execute this query, it's necessary to have the grant INSERT(...) ON <db>.network_flows_0

🧩 This PR in a nutshell

  • Passes the configured Database value from ClickHouseOptions into each worker
  • Updates worker.flush() to dynamically use that database instead of hardcoding default

So instead of:

INSERT INTO default.network_flows_0 (...)

we now correctly get:

INSERT INTO my_cluster_db.network_flows_0 (...)


✅ Result

  • Enables running multiple kubenetmon instances across many EKS clusters, all writing safely to a shared ClickHouse deployment
  • Prevents privilege errors when users are restricted to their own database
  • Makes the database configuration field actually effective (previously ignored?)

🛠 Notes

To stay robust, the PR uses fmt.Sprintf for building the query string.
If needed, we could add identifier quoting (backticks) or validation to handle special DB names safely.

@hclaria hclaria changed the title Pull request creation failed. Validation failed: must be a collaborator Respect database config when inserting data (was always using default) Oct 31, 2025
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.

2 participants