You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/admin/database/postgresql.md
+46-54Lines changed: 46 additions & 54 deletions
Original file line number
Diff line number
Diff line change
@@ -9,10 +9,21 @@ The EventDB is a database (usually [PostgreSQL](https://postgresql.org/)) that
9
9
gets filled with with data from IntelMQ using the SQL Output
10
10
Bot.
11
11
12
-
## intelmq_psql_initdb
12
+
## Setup
13
+
14
+
You have two basic choices to run PostgreSQL:
15
+
16
+
1. on the same machine as intelmq, then you could use Unix sockets if available on your platform
17
+
2. on a different machine. In which case you would need to use a TCP connection and make sure you give the right
18
+
connection parameters to each psql or client call. On the networking side, make sure the connections are allowed, postgresql-server is listening on the correct interface and the user is allowed to connect (`pg_hba.conf`).
19
+
20
+
### PostgreSQL Server Version
21
+
22
+
Any supported version of PostgreSQL should work (v>=13 as of January 2025) [[1]](https://www.postgresql.org/support/versioning/).
IntelMQ comes with the `intelmq_psql_initdb` command line tool designed to help with creating the
15
-
EventDB. It creates in the first line:
26
+
EventDB tabls. It generates these SQL commands for you:
16
27
17
28
- A `CREATE TABLE events` statement with all valid IntelMQ fields as columns and correct types
18
29
- Several indexes as examples for a good read & search performance
@@ -21,16 +32,45 @@ Having an `events` table as outlined in the SQL file, IntelMQ's SQL Output Bot c
21
32
22
33
In addition, the script supports some additional features supporting use cases described later in this document:
23
34
24
-
-`--partition-key` - for generating schema aligned with TimescaleDB or partitioned tables,
25
-
-`--separate-raws` - for generating views and triggers needed to `eventdb_raws_table` (works also together with adjustments for partitioning).
35
+
-`--partition-key` - for generating schema aligned with TimescaleDB or partitioned tables
36
+
-`--separate-raws` - for generating views and triggers needed to `eventdb_raws_table` (works also together with adjustments for partitioning). This can increase the performance by separating data in two tables. See section [Separating raw values in PostgreSQL using view and trigger](#separating-raw-values-in-postgresql-using-view-and-trigger) below for more information.
26
37
27
38
For a full list of supported parameters, call the script help using `-h` parameter.
28
39
29
40
All elements of the generated SQL file can be adapted and extended before running the SQL file against a database, especially the indexes. Please review the generated script before applying.
30
41
31
42
Be aware that if you create tables using another DB user that is used later by the output bot, you may need to adjust ownership or privileges in the database. If you have problems with database permissions,
32
-
refer to `PostgreSQL documentation <https://www.postgresql.org/docs/current/ddl-priv.html>`.
43
+
refer to [PostgreSQL documentation](https://www.postgresql.org/docs/current/ddl-priv.html).
44
+
45
+
### Installation
46
+
47
+
First, install the PostgreSQL on your server using system packages or using any installation variant supported by the project: [PostgreSQL server installation](https://www.postgresql.org/download/)
33
48
49
+
You need a PostgreSQL database-user to own the resulting database. The recommendation is to use the name `intelmq`
50
+
. There may already be such a user for the PostgreSQL database-cluster to be used by other bots. (For example from
51
+
setting up the expert/certbund_contact bot.)
52
+
53
+
Therefore if still necessary: create the database-user as postgresql superuser, which usually is done via the system
The encoding parameter should ensure the right encoding on platform where this is not the default. Template `template1` has encoding `SQL_ASCII`, so in order to use UTF8, `template0` is required.
67
+
68
+
Now initialize it as database-user `intelmq` (in this example a network connection to localhost is used, so you would
69
+
get to test if the user `intelmq` can authenticate):
Some scripts related to the EventDB are located in the
@@ -181,55 +221,7 @@ The last steps brings us several advantages:
181
221
The complete SQL script can be generated using the `intelmq_psql_initdb`. It does *not* cover step 2 to avoid accidental
182
222
data loss - you need to do this step manually.
183
223
184
-
185
-
### Other docs
186
-
187
-
You have two basic choices to run PostgreSQL:
188
-
189
-
1. on the same machine as intelmq, then you could use Unix sockets if available on your platform
190
-
2. on a different machine. In which case you would need to use a TCP connection and make sure you give the right
191
-
connection parameters to each psql or client call.
192
-
193
-
Make sure to consult your PostgreSQL documentation about how to allow network connections and authentication in case 2.
194
-
195
-
**PostgreSQL Version**
196
-
197
-
Any supported version of PostgreSQL should work (v>=9.2 as of Oct 2016) [[1]](https://www.postgresql.org/support/versioning/).
198
-
199
-
If you use PostgreSQL server v >= 9.4, it gives you the possibility to use the time-zone [formatting string](https://www.postgresql.org/docs/9.4/static/images/functions-formatting.html) "OF" for date-times and the [GiST index for the CIDR type](https://www.postgresql.org/docs/9.4/static/images/release-9-4.html#AEN120769). This may be useful depending on how you plan to use the events that this bot writes into the database.
200
-
201
-
**How to install**
202
-
203
-
Use `intelmq_psql_initdb` to create initial SQL statements from `harmonization.conf`. The script will create the
204
-
required table layout and save it as `/tmp/initdb.sql`
205
-
206
-
You need a PostgreSQL database-user to own the result database. The recommendation is to use the name `intelmq`
207
-
. There may already be such a user for the PostgreSQL database-cluster to be used by other bots. (For example from
208
-
setting up the expert/certbund_contact bot.)
209
-
210
-
Therefore if still necessary: create the database-user as postgresql superuser, which usually is done via the system
0 commit comments