-
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
x-pack/metricbeat/module/sql: Add option to execute SQL queries for all databases #35688
Conversation
This pull request does not have a backport label.
To fixup this pull request, you need to add the backport labels for the needed
|
2593f3b
to
3275971
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Need description summary of fetch_from_all_db
- If "fetch from all databases feature is not supported for driver" it has to be added to beats user document.
- Need to add a beats testcase for fetch_from_all_db for beats
- Need to see a simple example at beats level what happens when fetch_from_all_db is enabled.
- Interested to see the diff between the docs created for each DB, when fetch_from_all_db is enabled.
d18efee
to
56df53a
Compare
bac4c6a
to
e59d7d0
Compare
74ee9db
to
5c1a214
Compare
Cherry-picked the commit to fix CI errors temporarily. See #36091 for more details. |
df03fab
to
c3f4148
Compare
60df722
to
7ae6948
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Pinging @elastic/elastic-agent (Team:Elastic-Agent) |
I need someone from the elastic-agent-data-plane team to review this PR. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving as the comments here are resolved.
ccaf445
to
7366a5f
Compare
7366a5f
to
7476250
Compare
What does this PR do?
Add support for executing a set of given queries for all databases present in a server. Currently, this feature is only supported for mssql driver.
It expects a field
fetch_from_all_databases
in the configuration to be set totrue
in order to enable the feature. This feature executes queries agnostic of database names (i.e., where database names are not already part of the query) for all databases in a server. On every call toFetch
, the database names are refreshed and to fire the given set of queries for a particular database,USE @command
statement is used by prefixing the same to each query when iterating over database names.merge_results
feature merges results per database basis and not merging all results from all databases.Please read the comments (
NOTE
) in between the code changes to know more about why mssql is only supported and more.In this PR some doc-related updates are also there. Also, handle the exit of metricbeat gracefully by handling return value of reporter.Event.
Why is it important?
Currently, we allow users to manually enter the databases when they are setting up the integration and that allows them to execute the SQL queries required for fetching the desired metrics. But, assuming a user could have 100s of databases on their server and then it becomes cumbersome to add them manually. There should be some easy way to fetch metrics from all databases that are there on the server.
To summarize, we already have a solution in place which enables users to manually feed the user databases along with the already set system databases (as default). But to close this issue we’d ideally want to have a solution that gets all accessible databases on a server.
Checklist
CHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.Author's Checklist
fetch_from_all_databases
set tofalse
andtrue
.How to test this PR locally
fetch_from_all_dbs
totrue
and make adjustments to the SQL query, if necessary.Related issues
Logs
For an mssql instance with only 4 databases — master, model, msdb, tempdb; here are some sample documents:
fetch_from_all_databases
isfalse
:Configuration file:
Response:
fetch_from_all_databases
istrue
:Configuration file:
Response: