SQL generic module currently collects one event per row, being each field the title of the column, and the value the value in the row for this column.
So for a result like this one:
An event containing these fields is generated:
This is a problem for queries that return the values like this:
Because they would generate in this case two events containing fields like these ones:
...
"variable": a
"value": 0
...
Enhancement
Add a mode that can be selected with a configuration option and can be used so for the previous example an only event is generated containing fields like this one:
Use case
Some queries, specially some used for monitoring or configuration, use this "key/value" format in responses, for example MySQLs SHOW STATUS or SHOW VARIABLES.
This feature would allow to have a configuration like the following one, that would generate a single event mapping each variable to a field:
- module: sql
metricsets: [query]
hosts: ...
driver: mysql
sql_response_format: variables
sql_query: "SHOW STATUS LIKE 'Key%'"
Would generate a single event per fetch with these fields:
"Key_blocks_used": 14955,
"Key_read_requests": 96854827,
"Key_reads": 162040,
"Key_write_requests": 7589728,
"Key_writes": 3813196,
The possible values for sql_response_format would be:
sql_response_format: table for current behaviour (default).
sql_response_format: variables for the "key/value" case.
SQL generic module currently collects one event per row, being each field the title of the column, and the value the value in the row for this column.
So for a result like this one:
An event containing these fields is generated:
This is a problem for queries that return the values like this:
Because they would generate in this case two events containing fields like these ones:
Enhancement
Add a mode that can be selected with a configuration option and can be used so for the previous example an only event is generated containing fields like this one:
Use case
Some queries, specially some used for monitoring or configuration, use this "key/value" format in responses, for example MySQLs
SHOW STATUSorSHOW VARIABLES.This feature would allow to have a configuration like the following one, that would generate a single event mapping each variable to a field:
Would generate a single event per fetch with these fields:
The possible values for
sql_response_formatwould be:sql_response_format: tablefor current behaviour (default).sql_response_format: variablesfor the "key/value" case.