-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generic SQL join results of multiple queries - discussion draft #31806
Comments
If we have the variable format, my understanding is we have always key / value pairs. In this scenario, is merging still an issue? In which scenarios do we require table? The queries you showed above seem to always return just key / value pair? |
Merging only variable formats in a sql_queries is fine (only need to consider non-overlapping of names) |
Solution details:Merging metrics from multiple sql_queries, will be enabled only if specific criteria below is met. Additional config will be added (request_merge default: false) will be added, using which users can request for a merge of generated metrics. However, this is only a request to merge and will be done, if the table queries produce single row. Multiple row merge is currently not supported. This criteria however, is sufficient for our usage currently. If the condition is not meet, metrics will be generated as-is and merge request will be ignored. The merge process combines all the metrics generated into a single event. Example Merging of 3 queries, "table1", "table2" & "variable1"
and
will produce the event:
Conditions of merge: All of the table queries produce only a single row. Related metrics change:
|
Could we instead throw / log an error instead? We should let any dev now as soon as possible that something is not as expected? |
Yes, we can flag an error/warning if merging was skipped and any other conditions like overlapping key names. |
+1 to throwing an error if something configured cannot work. The I would also like to see an example with this setting, I wonder if you are planning to add this setting at the module level or at the query level. Settings at the query-level would give more control, but it is probably better to have this at the module level, so all the events generated for a data stream have similar sets of fields. Different data streams/modules can be used if different sets of events are wanted. Having the setting at the module level it would be like this.
At the query level:
Another option I see would be to add a new response format for tables with one row, and when everything in
For context, the JMX module also has some automatic logic to merge fields or not. This behaviour can be controlled by adding an
|
Hi @jsoriano, request_merge is at module level. Now the PR is out with an example usage, which gives the exact details.
|
Two changes being done as per the PR reviews:
|
Summary
In generic SQL, there is a need to join results generated by multiple queries in sql_queries to create a single event. This will enable creating a single event for cases, where multiple individual queries are executed to extract the specific metrics.
For example:
The above two queries will create two separate events one for each query, currently each with a single metric. It is desired to create single event with 2 of the metrics together.
Before diving into the solution space, let’s first summarise the current behaviour of SQL module.
Current behaviour
sql_queries have two response formats table and variables.
Here, X events are generated one for each row. The event is of the format: (
“C1: V11”, “C2:V12”, …. “CY:V1Y”
)Here single event is generated of the format: (“N1:V1”, “N2:V2”…..”NX:VX”)
Solution feasibility
Solution details
TBD
The text was updated successfully, but these errors were encountered: