Adding queries for collecting QDS data for SQL DB#9150
Adding queries for collecting QDS data for SQL DB#9150masree wants to merge 47 commits intoinfluxdata:masterfrom
Conversation
…tore wait statistics, for Azure SQL DB and MI Add ability to store in a hashtable a custom value associated with the query result, and use it when the query is run next time. For query store queries, we store the time when the query was run last, and in the next run we only return the data between the last run time and the current time, rounded down to a multiple of the reporting interval.
…ime_stats_interval_id. Need this aggregation so that we do not get multiple rows for the same query in the same time interval. See here https://docs.microsoft.com/en-us/sql/relational-databases/system-catalog-views/sys-query-store-runtime-stats-transact-sql?view=sql-server-ver15
570ada4 to
b9af066
Compare
# Conflicts: # plugins/inputs/sqlserver/sqlserver.go
|
@denzilribeiro @dimitri-furman could you please review? |
srebhan
left a comment
There was a problem hiding this comment.
Hey @masree, thanks for the PR. I have only a minor comment but I'm, to be honest, not the right person to review the SQL statements.
However, can you please comment on Stevens question regarding a "feature-enable list" instead of using booleans to switch on/off features? I think it is much more extensible...
Co-authored-by: Sven Rebhan <36194019+srebhan@users.noreply.github.com>
@ssoroka , @srebhan -- This is no different than turning queries on/off right aka feature-enable list or include_queries list is the same ? Unless the feature-enable groups a set of queries into a "feature" that you turn on/off. The difference with query store is that it is generally different in terms of granularity of collection and the query is a bit more heavy duty than say the other light weight queries and isn't really a live monitoring metric but lets you analyze queries and perf that contributed to resource usage in time. The crux of the problem is we wanted to disable by default and have someone explicitly enable, so we wanted a disable by default, explicitly opt in behavior. Take for example someone who had telegraf prior to this PR, doesn't change their config files to exclude this explicitly, they get this collector turned on by default and will have to explicitly add to exclude_query list -- if that is fine then we can just use the exclude_list . That isn't just for query store related collector only but should agree upon an approach for any of the more "advanced" collectors or bit more heavy weight collectors. If exclude_query is the way to go that is fine just we would introduce new things for existing customers that don't change their config file but update telegraf. Query store being a bit of a different type of collector thought of using explicit flag but I get the point that a flag for a feature in time can explode the conf section. We do understand that the same could be achieved with this ( and just use exclude list) but it won't be disable by default, rather onus is on customers. |
|
@denzilribeiro the difference is in the extensibility of both schemes. Imagine adding another "thing to collect". With the boolean approach you will need to extend the config (sampleConfig, README, struct) with another option that is say disabled by default. With the feature list approach, you just implement the feature and add the "feature enable string" to the sampleconfig and README documentation. No need to change the actual configuration. Furthermore, if you have more than a handful of those feature enable/disable toggles, a include list is much more readable than a bulky list of true/false options. So yes, both approaches are equivalent feature-wise, but the latter is much more extensible/readable in the long-run. |
Right now feature_include/feature_exclude is the same as exclude_query /include_query which is already implemented. So if the decision is still to revert to that, then it is fine At some point look at this a bit more holistically. The issue I have with include/exclude you don't have a notion of "default collectors" for those that don't specify the include/exclude lists and so that moves the onus to customers. Say we have queries a,b,c,d in existing version and now we introduce a query e that we want enabled by default, and a query f that we want disabled by default Sure we can change the default conf to reflect it, but a customer that already has a conf and doesn't update it won't get it, maybe I am missing something :) |
I'm fine with using the existing lists.
I'm not sure I understand your comment correctly. You can still define a default
Then I would specify: # query_include = ["a", "b", "c", "d", "e"]
# query_exclude = []in your sample config and set these options when setting up the plugin in func init() {
inputs.Add("sqlserver", func() telegraf.Input {
return &SQLServer{
Servers: []string{defaultServer},
IncludeQuery: []string{"a", "b", "c", "d", "e"},
}
})
}
Right, but that is the semantics behind an
No because you did not include it in the first place, so you don't need to exclude it. Note you are free to craft the
See above. Just do not specify
Right, but again, if somebody sets an |
|
Will change to include/exclude lists for now and revisit any other changes later. Just to clarify concern wasn't ever of someone using include lists as they get exactly what they want, no more, no less. Concern was folks that weren't using include lists.. or using exclude lists in getting a potentially heavier collector since the default for all collectors as premise is by default all collectors enabled. My experience has been in my limited experience with telegraf that folks don't necesarily update their conf files often yet update telegraf major versions but then I maybe wrong |
Well almost. Premise is be backward-compatible. That is, if you add a new feature, you now have to explicitly define the include list (instead of "use all") to exclude the new feature. If you had feature
No you are right and that's exactly the point. Please craft the |
# Conflicts: # plugins/inputs/sqlserver/sqlserver.go
|
@srebhan, the flag was removed. Are we good to merge this pull request? |
srebhan
left a comment
There was a problem hiding this comment.
@andrewzayats, @masree I have some more minor comments.
The most important one is to change the documentation (README.md and sampleConfig) such that the include_query list is specified explicitly to make sure the user can uncomment the option without a change in behavior.
| HasCachedData bool | ||
| DataCache *QueryDataCache |
There was a problem hiding this comment.
Btw. do we really need those exported?
There was a problem hiding this comment.
What do you mean under exported? If you need more details about the purpose of DataCache you can get them from the following comment #9150 (comment)
There was a problem hiding this comment.
I mean that those struct members are visible and accessible outside of the plugin if starting with an uppercase letter (see https://golang.org/doc/effective_go#names). To prevent (accidental) messing with those members, you should make them start with a lowercase-letter.
| rows, err := pool.Query(query.Script) | ||
| if query.HasCachedData { | ||
| cachedData, _ := query.DataCache.Get(server) | ||
| rows, err = pool.Query(query.Script, sql.Named("p1", cachedData)) |
Looks like new artifacts were built from this PR. Get them here!Artifact URLs |
|
|
||
| ## A list of queries to include. If not specified, all the above listed queries are used. | ||
| # include_query = [] | ||
| # include_query = ["AzureSQLDBResourceStats", "AzureSQLDBResourceGovernance", "AzureSQLDBWaitStats", "AzureSQLDBDatabaseIO", "AzureSQLDBServerProperties", "AzureSQLDBOsWaitstats", "AzureSQLDBMemoryClerks", "AzureSQLDBPerformanceCounters", "AzureSQLDBRequests", "AzureSQLDBSchedulers"] |
There was a problem hiding this comment.
Hey @andrewzayats, you changed this in the documentation, but not in the code. With the current code, your new query will automagically appear with old configs. Please initialize IncludeQuery as described here.
|
@masree any update here? |
|
@srebhan unfortunately we will not be able to continue work on this PR in foreseeable future. My impression is that it is close to meeting the quality bar for merging once your comment is addressed. Perhaps this can be finished by other contributors at some point in the future. Apologies, and thanks for understanding. CC: @masree |
|
Closing this issue. If anyone is interested in picking this up please feel free to re-open. |
Required for all PRs:
resolves #
Summary of PR:
Igor started the PR to collect data from query store runtime and wait statistics for SQL DB and SQL MI. Continuing his PR to completion as he does not own this feature anymore. There are a few review comments that needed to be addressed from old PR. Steps to address them: