dbo11y: stop tracking alloy's own queries in mysql#4978
Conversation
internal/component/database_observability/postgres/collector/query_samples.go
Outdated
Show resolved
Hide resolved
|
💻 Deploy preview available (dbo11y: stop tracking alloy's own queries in mysql and postgres): |
cbaeaeb to
0221c8d
Compare
|
Neat! |
Yes, more details in the ticket
Yeah I see the issue, I'm not sure what a good name could be though. I guess we might have more of these kind of "check-adjust-report" functionality in the future, and maybe they shouldn't be collectors (or maybe it's ok, if they also report data?). |
|
Agreed, calling this a "collector" is also a little disorienting. Also I linked #4991 to question if the two collectors should have the same name if they share the same end goal? (Maybe something like |
Don't think should have the same name, they do different things, and trying to make things too homogeneous across different engines is counter-productive imo. TBH there's a risk we might be overthinking this: as long as our docs explain what the collector is used for, it's not that much important trying to find an alternative to the name "collector" (at this stage, at least). |
|
|
||
| var enabled, history string | ||
| err = c.dbConnection.QueryRowContext(ctx, selectQuery, user).Scan(&enabled, &history) | ||
| if err == sql.ErrNoRows { |
There was a problem hiding this comment.
this could be an errors.Is()
| | `schema_details` | Collect schemas and tables from `information_schema`. | yes | | ||
| | `query_samples` | Collect query samples. | yes | | ||
| | `setup_consumers` | Collect enabled `performance_schema.setup_consumers`. | yes | | ||
| | `setup_actors` | Check and update `performance_schema.setup_actors` settings. | yes | |
There was a problem hiding this comment.
It doesn't look like it is enabled by default?
There was a problem hiding this comment.
It's in component.go:
collector.SetupActorsCollector: true|
|
||
| func (c *SetupActors) checkSetupActors(ctx context.Context) error { | ||
| var user string | ||
| err := c.dbConnection.QueryRowContext(ctx, selectUserQuery).Scan(&user) |
There was a problem hiding this comment.
Can this be done on startup? Is there a need to get the current user every run?
There was a problem hiding this comment.
Good call, I can move this operation to before entering the loop.
As an edge case, you could change the user in the DSN string and reload the Alloy config - but that should restart the component and all collectors, so should be ok.
|
💻 Deploy preview deleted (dbo11y: stop tracking alloy's own queries in mysql). |
docs/sources/reference/components/database_observability/database_observability.mysql.md
Outdated
Show resolved
Hide resolved
This PR introduces strategies for excluding "own queries" in mysql and postgres: - postgres: here we just need to drop samples (and wait events) for the currently connected user when scraping `pg_stat_activity`. This new behaviour is enabled by default, as it's deemed safe/recommended. No changes to be done on `pg_stat_statements` as that is achieved through user permissions update (docs on the website). - mysql: here we add a new `setup_actors` collector that checks (and optionally updates) settings for the currently connected user. By default it just checks that `enabled=NO` and logs out if that's not the case. Optionally, the component can auto-update this setting itself. This behaviour is disabled by default, though: it follows the same pattern of `setup_consumers` where two boolean settings are required to enable the auto-update. Additionally, auto-update requires `INSERT` and `UPDATE` permissions (docs on the website).
f18eac9 to
b6c0cc1
Compare
…ase_observability.mysql.md Co-authored-by: Clayton Cornell <131809008+clayton-cornell@users.noreply.github.com>
dbo11y: stop tracking alloy's own queries in mysql and postgres This PR introduces a change for excluding "own queries" in mysql: we add a new `setup_actors` collector that checks (and optionally updates) settings for the currently connected user. By default it just checks that `enabled=NO` and logs out if that's not the case. Optionally, the component can auto-update this setting itself. This behaviour is disabled by default, though: it follows the same pattern of `setup_consumers` where two boolean settings are required to enable the auto-update. Additionally, auto-update requires `INSERT` and `UPDATE` permissions (docs on the website).
PR Description
This PR introduces a change for excluding "own queries" in mysql: we add a new
setup_actorscollector that checks (and optionally updates) settings for the currently connected user. By default it just checks thatenabled=NOand logs out if that's not the case. Optionally, the component can auto-update this setting itself. This behaviour is disabled by default, though: it follows the same pattern ofsetup_consumerswhere two boolean settings are required to enable the auto-update. Additionally, auto-update requiresINSERTandUPDATEpermissions (docs on the website).Which issue(s) this PR fixes
Relates to https://github.com/grafana/grafana-dbo11y-app/issues/1307
Notes to the Reviewer
PR Checklist