Skip to main content

Database Sender

Description

The Database Sender Plugin persists messages from 1Gateway directly into a relational database using JDBC-compatible connections.

Incoming messages (such as metrics or alarms) are mapped via configured mappers (e.g., metric2database or alarm2database) and inserted into a target database table.

The Database Sender Plugin is commonly used for:

  • Long-term metric storage
  • Analytics and reporting
  • Exporting monitoring data to data lakes or analytical databases

Supported Databases

The Database Sender Plugin uses JDBC and therefore supports a wide range of databases.

DatabaseJDBC DriverNotes
PostgreSQLpostgresqlFully supported
MySQL / MariaDBmysql-connector-jFully supported
OracleojdbcRequires Oracle JDBC driver
Microsoft SQL Servermssql-jdbcFully supported
H2Built-inMainly for testing
Note

Any database with a valid JDBC driver can be used, provided the correct connection string and driver are available in 1Gateway. If the JDBC driver doesn’t come out-of-the-box, install it in 1Gateway and restart the service.


Example Database Insert

The plugin inserts mapped fields into the configured table. The actual structure depends on the mapper used.

Example target table:

CREATE TABLE metrics (
timestamp DateTime,
source String,
metric_name String,
value Float64
);

Example mapped insert (conceptual):

INSERT INTO metrics (timestamp, source, metric_name, value)
VALUES (?, ?, ?, ?);

Prerequisites

To ensure the Database Sender Plugin functions correctly, verify the following:

  • 1Gateway Version: 4.1.2 or later.
  • JDBC Driver: The relevant driver must be installed in the 1Gateway environment followed by a service restart.
  • Schema Ready: The target database and table must be created manually before the plugin starts sending data.
  • Mapping: A valid mapper configuration must be set up to translate 1Gateway fields to database columns.
  • Network: Ensure firewalls allow connectivity from the 1Gateway host to the database port.

Sender Configuration

The Database Sender Plugin utilizes a Database Connection Profile to manage credentials and target locations.

Database Connection Profile

Field nameSupported valuesDescriptionRequiredExample
Connection stringURLFull JDBC connection stringNo*jdbc:sqlserver://localhost:1433;databaseName=TestDB;
Database nameStringName of the target DBNo*TestDB
Database typeStringType of SQL engineNo*sqlserver, sqlite
Database userStringUsername for authenticationNo*sa
Database passwordStringPassword for authenticationNo*abc123
Database portNumberPort numberNo*1433
Database hostStringHostname or IP addressNo*localhost
Database table nameStringDestination tableYesTestTable
Script before insertFilenameSQL script to run before data entryNobeforeScript.sql
Script after insertFilenameSQL script to run after data entryNoafterScript.sql

*Not required if a full Connection string is provided.


db config

db config

Message Flow

The following sequence describes how data travels from 1Gateway to your database:

  1. Ingestion: Message is received from 1Gateway.
  2. Matching: The topic is matched against the Main Profile criteria.
  3. Mapping: The message payload is transformed via the configured mapper.
  4. Resolution: The Database Connection Profile is resolved to establish a session.
  5. Pre-processing: The "Before script" is executed (if configured).
  6. Execution: The SQL INSERT or UPDATE is performed.
  7. Post-processing: The "After script" is executed (if configured).