https://github.com/wizecore/graylog2-output-jdbc
Plugin to add graylog capability to send log messages to relational database (MySQL, PostgreSQL, etcz)
https://github.com/wizecore/graylog2-output-jdbc
graylog jdbc mysql rdmbs
Last synced: 5 months ago
JSON representation
Plugin to add graylog capability to send log messages to relational database (MySQL, PostgreSQL, etcz)
- Host: GitHub
- URL: https://github.com/wizecore/graylog2-output-jdbc
- Owner: wizecore
- License: apache-2.0
- Created: 2015-12-12T21:06:06.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2023-07-06T20:48:18.000Z (almost 3 years ago)
- Last Synced: 2024-03-26T20:03:28.571Z (about 2 years ago)
- Topics: graylog, jdbc, mysql, rdmbs
- Language: Java
- Homepage: https://www.graylog.org/
- Size: 9.88 MB
- Stars: 11
- Watchers: 4
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Graylog output plugin JDBC
Sends log from a steam to a traditional RDMBS database via JDBC.
## How to build
- Use `mvn clean package` to create JAR
- See **Providing JDBC driver** on how to adjust JAR for your RDBMS
- Put prepared JAR inside **Graylog** plugins folder
- Put a JDBC driver inside **Graylog** plugins folder
- Restart Graylog
- Create new output globally or inside stream
- Connect output to your stream
- Make sure your RDBMS commit speed is sufficient to handle output message rate
## Providing JDBC driver
Graylog does not ship with JDBC drivers.
You must add your driver JAR manually to plugins folder and **update** graylog-output-jdbc-2.5.1.jar accordingly.
Add following line to graylog2-output-jdbc-2.5.1.jar/META-INF/MANIFEST.MF
```
Class-Path: driver.jar
```
Example:
```
Class-Path: mysql-connector-java-8.0.17.jar
```
### How to update using command line?
Create `my-manifest.mf` and use jar tool from JDK:
```
jar -uvmf my-manifest.mf target/graylog-output-jdbc-2.5.1.jar
```
## Output options
#### Driver class to use (optional)
Driver class to initialize. Needed so URL can be handled properly. Recent JDK 8+ have autodiscovery of JDBC drivers so it might be not needed.
Default value: NONE
Example: `com.mysql.jdbc.Driver`
#### JDBC URL
Fully qualified JDBC url to connect to.
Default value: NONE
Example: `jdbc:mysql://localhost:3307/graylog`
#### Username (optional)
Username to connect to RDBMS as. If not specified, no password will be passed to driver.
Default value: NONE
#### Password (optional)
Password for user.
Default value: NONE
#### Additional fields (optional)
Comma separated list of additional attributes for Message insert query. I.e. if you have custom attribute defined in your log i.e. `hostname`, specify it here and adjust a query accordingly, i.e. `insert into log (message_date, message_id, source, message, hostname) values (?, ?, ?, ?, ?)`
This way you don`t need to use log_attribute table, greatly increasing commit speed.
Default value: NONE
#### Message insert query
Query to execute to add log entry. Must contain required 4 columns and optional (see Additional fields). Must produce generated key (ID).
Default value: `insert into log (message_date, message_id, source, message) values (?, ?, ?, ?)`
#### Attribute insert query (optional)
If specified all attributes will be added using this query.
Default value: `insert into log_attribute (log_id, name, value) values (?, ?, ?)`
### Table definition
By default output uses table 'log' for main message entry and 'log_attribute' for attributes.
Sample table creation script (MySQL):
```sql
create table if not exists log (
id int not null auto_increment,
message_date datetime,
message_id varchar(64),
source varchar(32),
message varchar(4096) null,
PRIMARY KEY (id)
);
create table if not exists log_attribute (
id int not null auto_increment,
log_id numeric(10,0),
name varchar(255),
value varchar(4096) null,
primary key (id),
foreign key (log_id) references log(id)
);
```
Make sure that for table log, column ID are generated automatically. For example add 'identity' (MS SQL/Sybase ASE) or AUTO_INCREMENT (MySQL) into column definition.
## Links
- https://www.graylog.org/