diff --git a/src/main/java/com/loafle/overflow/crawler/sql/SQLCrawler.java b/src/main/java/com/loafle/overflow/crawler/sql/SQLCrawler.java index d9afba4..cce6db4 100644 --- a/src/main/java/com/loafle/overflow/crawler/sql/SQLCrawler.java +++ b/src/main/java/com/loafle/overflow/crawler/sql/SQLCrawler.java @@ -42,11 +42,10 @@ public class SQLCrawler extends Crawler { for (Item item : config.getItems()) { - Query query = item.getQuery(); OFResultSet resultSet = OFResultSetRow.newInstance(item); Map meta = resultSet.getMeta(); - rs = stmt.executeQuery((String)query.getQueryInfo().get("query")); + rs = stmt.executeQuery((String)item.getQueryInfo().getQuery()); while(rs.next()) { List row = new ArrayList<>(Arrays.asList(new String[meta.size()])); diff --git a/src/test/resources/config/mysql.json b/src/test/resources/config/mysql.json index f1ff962..7c5fa93 100644 --- a/src/test/resources/config/mysql.json +++ b/src/test/resources/config/mysql.json @@ -22,23 +22,23 @@ }, "items" : [ { - "metrics" : [ - "net.connection_count" - ], - "query": + "keys" : [ { - "queryInfo" : { - "query":"show status where `variable_name` = 'Connections'", - "parseDirection" : "row", - "valueColumn" : "Value", - "keyColumns" : [ - "Variable_name" - ] - }, - "keys" : [ - "Connections" - ] + "metric":"net.connection_count", + "key":"Connections" } + + ], + "queryInfo" : { + "query":"show status where `variable_name` = 'Connections'" + }, + "mappingInfo" : { + "parseDirection" : "row", + "valueColumn" : "Value", + "keyColumns" : [ + "Variable_name" + ] + } } ] } \ No newline at end of file diff --git a/src/test/resources/config/pgsql.json b/src/test/resources/config/pgsql.json index 8f98c9d..5ae8e3d 100644 --- a/src/test/resources/config/pgsql.json +++ b/src/test/resources/config/pgsql.json @@ -22,18 +22,15 @@ }, "items" : [ { - "metrics" : [ - "net.connection_count" - ], - "query": { - "queryInfo":{ - "query" : "select count(pid) as connection_count from pg_catalog.pg_stat_activity where state <> 'idle'" , - "parseDirection":"col" - }, - "keys" : [ - "connection_count" - ] + "keys" : [ + { + "metric":"net.connection_count", + "key" : "connection_count" } + ], + "queryInfo":{ + "query" : "select count(pid) as connection_count from pg_catalog.pg_stat_activity where state <> 'idle'" + } } ] } \ No newline at end of file diff --git a/src/test/resources/config/sqlserver_connection_count.json b/src/test/resources/config/sqlserver_connection_count.json index 4205924..d9f9218 100644 --- a/src/test/resources/config/sqlserver_connection_count.json +++ b/src/test/resources/config/sqlserver_connection_count.json @@ -22,18 +22,17 @@ }, "items" : [ { - "metrics" : [ - "net.connection_count" - ], - "query": { - "queryInfo" : { - "query": "select count(session_id) as connection_count from sys.dm_exec_connections where session_id = @@SPID", - "parseDirection" : "col" - }, - "keys" : [ - "connection_count" - ] + "keys" : [ + { + "metric" :"net.connection_count", + "key" : "connection_count" } + ], + "queryInfo" : { + "query": "select count(session_id) as connection_count from sys.dm_exec_connections where session_id = @@SPID" + }, + "mappingInfo" : {} } + ] } \ No newline at end of file diff --git a/src/test/resources/config/sqlserver_multiple_key_array.json b/src/test/resources/config/sqlserver_multiple_key_array.json index f84d4d5..d85ae41 100644 --- a/src/test/resources/config/sqlserver_multiple_key_array.json +++ b/src/test/resources/config/sqlserver_multiple_key_array.json @@ -23,23 +23,25 @@ }, "items" : [ { - "metrics" : [ - "object[$0].db[$1].datafile_size", - "object[$0].db[$1].logfile_size" - ], - "query": { - "queryInfo" : { - "query": "select object_name,instance_name, counter_name, cntr_value from sys.dm_os_performance_counters where ( counter_name = 'Data File(s) Size (KB)' or counter_name = 'Log File(s) Size (KB)' ) AND object_name = 'SQLServer:Databases'", - "parseDirection" : "row", - "arrayColumns" : [ "object_name","instance_name"], - "keyColumns" : ["counter_name"], - "valueColumn" : "cntr_value" - }, - "keys" : [ - "Data File(s) Size (KB)", - "Log File(s) Size (KB)" - ] + "keys" : [ + { + "metric" : "object[$0].db[$1].datafile_size", + "key" : "Data File(s) Size (KB)" + }, + { + "metric" : "object[$0].db[$1].logfile_size", + "key" : "Log File(s) Size (KB)" } + ], + "queryInfo" : { + "query": "select object_name,instance_name, counter_name, cntr_value from sys.dm_os_performance_counters where ( counter_name = 'Data File(s) Size (KB)' or counter_name = 'Log File(s) Size (KB)' ) AND object_name = 'SQLServer:Databases'" + }, + "mappingInfo" : { + "parseDirection" : "row", + "arrayColumns" : [ "object_name","instance_name"], + "keyColumns" : ["counter_name"], + "valueColumn" : "cntr_value" + } } ] } \ No newline at end of file