forked from OCA/server-tools
-
Notifications
You must be signed in to change notification settings - Fork 1
[ADD] auditlog_clickhouse_write: add module #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tendil
wants to merge
3
commits into
18.0
Choose a base branch
from
18.0-t5246-auditlog_clickhouse-add_module
base: 18.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,172 @@ | ||
| ============================= | ||
| Store Audit Log in Clickhouse | ||
| ============================= | ||
|
|
||
| .. | ||
| !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
| !! This file is generated by oca-gen-addon-readme !! | ||
| !! changes will be overwritten. !! | ||
| !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
| !! source digest: sha256:11aaa38bad24a890554c0d34d74d31e13b933facbba3fea31f4cbf22ae8fd842 | ||
| !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
|
|
||
| .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png | ||
| :target: https://odoo-community.org/page/development-status | ||
| :alt: Beta | ||
| .. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png | ||
| :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
| :alt: License: AGPL-3 | ||
| .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github | ||
| :target: https://github.com/OCA/server-tools/tree/18.0/auditlog_clickhouse_write | ||
| :alt: OCA/server-tools | ||
| .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
| :target: https://translation.odoo-community.org/projects/server-tools-18-0/server-tools-18-0-auditlog_clickhouse_write | ||
| :alt: Translate me on Weblate | ||
| .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png | ||
| :target: https://runboat.odoo-community.org/builds?repo=OCA/server-tools&target_branch=18.0 | ||
| :alt: Try me on Runboat | ||
|
|
||
| |badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
|
||
| This module implements buffered asynchronous transfers audit of logs | ||
| from PostgreSQL to ClickHouse. Storing audit data in a columnar database | ||
| that is write-only prevents database bloat, makes audit records | ||
| effectively immutable, and allows for scaling to very large volumes of | ||
| logs without slowing down normal transactions. Audit logs are written | ||
| asynchronously to reduce the load on business operations. | ||
|
|
||
| **Table of contents** | ||
|
|
||
| .. contents:: | ||
| :local: | ||
|
|
||
| Use Cases / Context | ||
| =================== | ||
|
|
||
| The auditlog module stores audit data in PostgreSQL. In production | ||
| systems with extensive audit rules, these tables grow without limits, | ||
| causing three issues: | ||
|
|
||
| - Database bloat; | ||
| - Immutability gap: Members of group_auditlog_manager (implied by | ||
| base.group_system) have full CRUD access to audit tables, allowing | ||
| audit records to be altered or deleted via UI, ORM, or SQL; | ||
| - Performance overhead: Audit logging runs synchronously in the same | ||
| transaction and performs multiple ORM create() calls, adding latency | ||
| to audited operations. | ||
|
|
||
| Configuration | ||
| ============= | ||
|
|
||
| This module requires: | ||
|
|
||
| - A reachable ClickHouse server. | ||
| - Python dependency ``clickhouse-driver`` available in the Odoo | ||
| environment. | ||
| - A ClickHouse database created in advance (the module does **not** | ||
| create databases/users/grants). | ||
| - A ClickHouse user with at least: | ||
|
|
||
| - ``INSERT`` and ``CREATE TABLE`` privileges on the target database. | ||
|
|
||
| .. | ||
|
|
||
| ClickHouse installation (Docker guide): | ||
| ``https://clickhouse.com/docs/install/docker`` | ||
|
|
||
| Steps: | ||
|
|
||
| - Make sure ``clickhouse-driver`` is available in your system. | ||
| - Install the module. | ||
| - Configure the connection parameters in Odoo: | ||
|
|
||
| - **Settings > Technical > Auditlog > Clickhouse configuration** | ||
| - Fill in the following parameters: | ||
|
|
||
| +---------------------------------------+ | ||
| | Field | | ||
| +=======================================+ | ||
| | Hostname or IP | | ||
| +---------------------------------------+ | ||
| | TCP port | | ||
| +---------------------------------------+ | ||
| | ClickHouse database name | | ||
| +---------------------------------------+ | ||
| | ClickHouse user | | ||
| +---------------------------------------+ | ||
| | ClickHouse Password | | ||
| +---------------------------------------+ | ||
| | queue_job_batch_size (default = 1000) | | ||
| +---------------------------------------+ | ||
| | channel_id (default root) | | ||
| +---------------------------------------+ | ||
|
|
||
| - Click **Test connection**. | ||
| - Optionally, click **Create Auditlog Tables** to create the tables in | ||
| the target database. | ||
|
|
||
| Usage | ||
| ===== | ||
|
|
||
| Once auditlog_clickhouse_write is installed and configured: | ||
|
|
||
| - Users perform tracked operations (create, write, unlink, read, export) | ||
| on models with active auditlog.rule subscriptions. This behavior is | ||
| unchanged from the base auditlog module. | ||
| - Log data is serialized and stored in the local auditlog.log.buffer | ||
| table instantly. The standard auditlog tables are not populated. | ||
| - Every 5 minutes (default), the Cron job runs, pushes data to | ||
| ClickHouse, and cleans the local buffer. | ||
| - Data is permanently stored in ClickHouse and cannot be modified or | ||
| deleted via Odoo. | ||
|
|
||
| Bug Tracker | ||
| =========== | ||
|
|
||
| Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-tools/issues>`_. | ||
| In case of trouble, please check there if your issue has already been reported. | ||
| If you spotted it first, help us to smash it by providing a detailed and welcomed | ||
| `feedback <https://github.com/OCA/server-tools/issues/new?body=module:%20auditlog_clickhouse_write%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
|
||
| Do not contact contributors directly about support or help with technical issues. | ||
|
|
||
| Credits | ||
| ======= | ||
|
|
||
| Authors | ||
| ------- | ||
|
|
||
| * Cetmix | ||
|
|
||
| Contributors | ||
| ------------ | ||
|
|
||
| - `Cetmix <https://cetmix.com/>`__ | ||
|
|
||
| - Ivan Sokolov | ||
| - George Smirnov | ||
| - Dmitry Meita | ||
|
|
||
| Other credits | ||
| ------------- | ||
|
|
||
| The development of this module has been financially supported by: | ||
|
|
||
| - Geschäftsstelle Sozialinfo | ||
|
|
||
| Maintainers | ||
| ----------- | ||
|
|
||
| This module is maintained by the OCA. | ||
|
|
||
| .. image:: https://odoo-community.org/logo.png | ||
| :alt: Odoo Community Association | ||
| :target: https://odoo-community.org | ||
|
|
||
| OCA, or the Odoo Community Association, is a nonprofit organization whose | ||
| mission is to support the collaborative development of Odoo features and | ||
| promote its widespread use. | ||
|
|
||
| This module is part of the `OCA/server-tools <https://github.com/OCA/server-tools/tree/18.0/auditlog_clickhouse_write>`_ project on GitHub. | ||
|
|
||
| You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| from . import models |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| { | ||
| "name": "Store Audit Log in Clickhouse", | ||
| "version": "18.0.1.0.0", | ||
| "summary": "Asynchronous audit log storage in ClickHouse", | ||
| "category": "Tools", | ||
| "license": "AGPL-3", | ||
| "author": "Odoo Community Association (OCA), Cetmix", | ||
| "website": "https://github.com/OCA/server-tools", | ||
| "depends": [ | ||
| "auditlog", | ||
| "queue_job", | ||
| ], | ||
| "external_dependencies": { | ||
| "python": ["clickhouse-driver"], | ||
| }, | ||
| "data": [ | ||
| "security/ir.model.access.csv", | ||
| "data/auditlog_clickhouse_queue.xml", | ||
| "views/auditlog_clickhouse_config_views.xml", | ||
| ], | ||
| } |
27 changes: 27 additions & 0 deletions
27
auditlog_clickhouse_write/data/auditlog_clickhouse_queue.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| <odoo noupdate="1"> | ||
| <record id="ir_cron_auditlog_clickhouse_write_enqueue_flush" model="ir.cron"> | ||
| <field name="name">Auditlog ClickHouse Write: enqueue buffer flush</field> | ||
| <field name="model_id" ref="model_auditlog_log_buffer" /> | ||
| <field name="state">code</field> | ||
| <field name="code">model._cron_flush_to_clickhouse()</field> | ||
| <field name="interval_number">5</field> | ||
| <field name="interval_type">minutes</field> | ||
| <field name="active">True</field> | ||
| <field name="user_id" ref="base.user_root" /> | ||
| </record> | ||
|
|
||
| <record | ||
| id="action_configure_auditlog_clickhouse_write_cron" | ||
| model="ir.actions.act_window" | ||
| > | ||
| <field name="name">Edit buffer flush schedule</field> | ||
| <field name="res_model">ir.cron</field> | ||
| <field | ||
| name="res_id" | ||
| ref="auditlog_clickhouse_write.ir_cron_auditlog_clickhouse_write_enqueue_flush" | ||
| /> | ||
| <field name="type">ir.actions.act_window</field> | ||
| <field name="view_mode">form</field> | ||
| <field name="target">new</field> | ||
| </record> | ||
| </odoo> | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.