JDBC Data Collection
Last updated - 13 May, 2026
You can use Java Database Connectivity data collection (JDBC) to query relational databases directly with SQL. This collection method enables you to retrieve metrics such as counts, statuses, or performance indicators by executing queries against supported databases, such as MySQL, Oracle, or SQL Server.
JDBC data collection is best suited for environments where the following conditions apply:
- Storing metrics in a database rather than exposing them through APIs or SNMP
- Custom, query-based monitoring
- Returning specific values derived from SQL queries
When you select JDBC as the collection method in a DataSource, the UI displays fields that enable you to configure database connectivity and query behavior.
To configure JDBC data collection, you define the following attributes:
- JDBC URL—Specifies the database connection string
- JDBC Credentials—Defines authentication for database access
- Query—Specifies the SQL statement that LogicMonitor runs against the database
- Result Handling—Determines how query results are interpreted and mapped to datapoints
These attributes control how LogicMonitor connects to your database and retrieves data.
Requirements for JDBC Data Collection
To configure JDBC data collection, you need the following:
- A LogicMonitor user with Manage permissions for Modules in role permissions
- A JDBC-supported database (for example, MySQL, Oracle, SQL Server)
- A reachable database endpoint (for example, hostname and port accessible from the Collector)
- A valid JDBC URL
For more information, see JDBC URL. - Valid database credentials
For more information, see JDBC Credentials. - A SQL query that returns a result set
JDBC URL
The JDBC URL defines how LogicMonitor connects to your database. You must enter a valid JDBC connection string, which varies by database type.
You can construct the URL using the following components:
- Hostname
- Port
- Database name
- Optional connection parameters
You can also use LogicMonitor property tokens to make the URL reusable across resources.
Common tokens include the following:
| Token | Description | Example usage |
|---|---|---|
##HOSTNAME## | Replaced with the monitored device hostname | jdbc:mysql://##HOSTNAME##:3306/##DBNAME## |
##WILDVALUE## | Used in Active Discovery; commonly represents a port | jdbc:postgresql://##HOSTNAME##:##WILDVALUE##/##DBNAME## |
##DBNAME## | Specifies the database name | jdbc:mysql://##HOSTNAME##:3306/##DBNAME## |
##DBPORT## | Specifies the database port | jdbc:sqlserver://##HOSTNAME##:##DBPORT##;databaseName=##DBNAME## |
Note: Some database types (such as Sybase) use slightly different URL formats.
JDBC Credentials
You must configure credentials to enable LogicMonitor to authenticate to the database.
You can provide credentials using one of the following methods: use LogicMonitor properties (recommended) or enter credentials directly in the DataSource. Using properties enables you to define credentials at the resource or group level and reuse them across multiple DataSources.
Common property formats include the following:
- ##jdbc.mysql.user##
- ##jdbc.mysql.pass##
- ##jdbc.oracle.user##
- ##jdbc.oracle.pass##
Entering credentials directly in the DataSource is appropriate when the following conditions apply:
- Credentials are unique to a single DataSource
- You do not need to reuse credentials across multiple resources
Recommendation: Do not embed credentials directly into the JDBC URL
Note: The following considerations apply when configuring JDBC credentials:
Microsoft SQL Server authentication—If you use Windows authentication, LogicMonitor uses the Collector’s run-as credentials. If you use SQL Server authentication, the credentials defined in the DataSource must have permission to execute the query.
MySQL limitation—Passwords should not contain the backslash (\) character.
JBDC Query Configuration
The Query field defines the SQL statement that LogicMonitor executes and returns for data collection.
Ensure your query returns a result set. JDBC data collection does not support statements that do not return data, including INSERT, UPDATE, DELETE, ALTER, CREATE, DROP, RENAME, and TRUNCATE.
Note: Some JDBC drivers do not support queries that end with a semicolon (;). If your query fails, verify whether your driver supports semicolons and remove the trailing semicolon if necessary.
To simplify configuration, design your query to return a single row and a single value (or a clearly named column). This approach enables you to extract the result directly without additional processing, see the following example:
SELECT COUNT(*) AS active_sessions FROM sessions WHERE status = 'active'
After your query returns the desired result, you can configure how LogicMonitor interprets that output. When you configure a datapoint, you can select from the following result interpretation options:
- Query execution time—Measures how long the query takes to run
- Query status—Indicates whether the query succeeded
- Query result—Extracts values from the result set
If you use query results, extract values using one of the following methods:
- Column value (recommended)—Specify a column name to return the value from the first row.
- Regular expression (advanced)—Use a regex if your query returns multiple rows. Results are formatted as key-value pairs, as shown in the following example:
application=websales,count=42application=phonesales,count=12application=storefront,count=33
You can extract a value using a regex pattern such as the following:phonesales,count=(\d+)
Note: Use this method only for scenarios where multiple rows must be processed.
- Text match—Returns 1 if a specified string is present and 0 if it is not.
Configuring a JDBC Datapoint
- In LogicMonitor, navigate to Modules, then either add a new DataSource or select a DataSource you want to configure JDBC data collection for.
For more information, see Custom Module Creation or Modules Management. - Configure or modify your DataSource as needed, and select “JDBC” from the Collection Method dropdown menu.
For more information, see DataSource Configuration.
- In the Collection section, enter the following fields:
- In the URL field, add the JDBC URL.
- In the Username field, enter the JDBC username.
- In the Password field, enter the JDBC password.
- In the Query field, enter the SQL statement that returns the data you want to collect.
Ensure the query returns a result set and is designed to return a single row and value where possible.
- In the Datapoint section, add a datapoint.
The Datapoint configuration form displays.
For more information, see Datapoint Overview. - From the Datapoint Source dropdown menu, select one of the following:
- To collect a value returned by the query, select ”Query Result.”
- To measure how long the query takes to run, select “Query execution time in milliseconds.”
- To return a status code indicating whether the query succeeded (for example, success or authentication failure), select “Query Status.”

- (Optional) If you select Query Result, configure the following fields:
- In the Interpret output with field, select “Use the value of a specific column of the first row in the result”
- In the Column name field, enter the name of the column returned by your query that contains the value you want to collect
- (Optional) If your query returns multiple rows or requires additional parsing, configure a post-processor such as a regular expression or text match.
- Select Save.
After saving the configuration, assign the DataSource to a resource, and verify the data is collected.