JDBC Active Discovery
Last updated on 25 November, 2020The JDBC Active Discovery method is used to detect whether databases are running on certain ports, and to filter them based on responses to SQL queries. It can also be used to create instances based on arbitrary SQL queries, that can be used to collect more detail about objects.
Parameters
Once you set the Active Discovery method to JDBC, you’ll need to configure the following parameters:
- JDBC URL: This field can be filled with either the type of database engine or a fully defined URL. If you only specify the type of database engine to connect to (i.e. mysql, oracle, postgresql or mssql), LogicMonitor will attempt to build the JDBC URL using defined device properties. You can specify a fully defined URL in one of the following formats:
- SQL Statement: A SQL query supported by the database engine that will be used to discover instances. For example, you might execute the following query: select * from information_schema.tables; or show slave status for mysql.
- Discovery Type: There are four discovery types: Attributes in columns | Attributes in rows | database list | instance list
- Oracle SID: The SID to use for connecting to Oracle databases.
- Port # List: A comma separated list of ports that Active Discovery should check. Any database services discovered on these ports will be returned as instances according to the discovery type specified.
- Separator: This field is only valid if the Discovery Type is set to database list. The separator specified here is used to create instance names by concatenating the port number and the database names in the following manner: portNumber separator databaseName.
Attributes in Rows
Using the Attributes in Rows discovery type, database services discovered on ports in the port list will be returned as instances if the SQL statement can be executed against them. If filters are defined, only those instances that pass the filters are discovered as instances.
When using this discovery method, the Active Discovery wildvalue returned is the port number.
Assume for the following examples that this database is being discovered on port 3306:
The SQL statement will result in a two column table:
One instance will be discovered with a wildvalue of 3306.
Example 2
Assume that there is one filter defined, and that the Active Discovery parameters are specified as follows:
The SQL statement will result in a two column table:
Since the first attribute meets the filter criteria, one instance is returned with wildvalue 3306.
Example 3
Assume that there is one filter defined, and that the Active Discovery parameters are specified as follows:
The SQL statement will result in a two column table:
Since the attributes returned do not meet the filter criteria, no instances will be returned.
Attributes in Columns
Using the Attributes in Columns discovery type, a database service running on a port in the port list will be discovered as an instance if the SQL statement can be executed against it. If filters are defined, only those instances that meet the filter criteria are discovered as instances.
When using the Attributes in Columns discovery type, the Active Discovery wildvalue returned is the port number.
Example 1
Continuing with the previous example database, assume that there are no filters, and that the Active Discovery parameters are specified as follows:
The SQL statement will result in a one column table:
One instance will be discovered with a wildvalue of 3306.
Example 2
Assume that there is one filter, and that the Active Discovery parameters are specified as follows:
The SQL statement will result in a one column table:
Since the attribute meets the filter criteria, one instance is discovered with a wildvalue of 3306.
Example 3
Assume that there is one filter defined, and that the Active Discovery parameters are specified as follows:
The SQL statement will result in a one column table:
Since the attribute doesn’t meet the filter, no instances are discovered.
Database List
When using the database list discovery type, the Active Discovery wildvalue is:
port separator SQLstatementRowResult
Example 4
Assume that there are two tables in our database:
The following tables are discovered as instances, and they are named as follows:
- 3306:robin_test
- 3306:robin_test_1
Instance List
When using the instance list discovery type, the Active Discovery wildvalue is the result of the SQL statement.
This method, like the database list method, creates instances using information returned from the SQL query and the query must return a single column table with each row value equaling an instance.
Example 5
Consider the following SQL query:
The instances discovered would be 1 and 2.
Example 2
The instance list discovery type can be used to find objects within a database that can then be further queried by the datasource.
This returns an instance for each entry in the customers table, on each host the datasource is applied to, that responds to the query on the default mysql port of 3306.
The datasource can then use this instance in the main JDBC collector, either in the connection string (if each customer has their own database), or in the query: