Skip to content

fix: Database_observability: allow setting limit for mysql query_details#5314

Merged
cristiangreco merged 1 commit intomainfrom
cristian/dbo11y-mysql-query-details-limit
Jan 22, 2026
Merged

fix: Database_observability: allow setting limit for mysql query_details#5314
cristiangreco merged 1 commit intomainfrom
cristian/dbo11y-mysql-query-details-limit

Conversation

@cristiangreco
Copy link
Contributor

Brief description of Pull Request

Allow limiting the number of recent queries collected in the mysql query_details collector. Default to 250 to match mysqld_exporter's behavior.

Pull Request Details

Issue(s) fixed by this Pull Request

Notes to the Reviewer

PR Checklist

  • Documentation added
  • Tests updated
  • Config converters updated

@cristiangreco cristiangreco marked this pull request as ready for review January 21, 2026 15:39
@cristiangreco cristiangreco requested review from a team and clayton-cornell as code owners January 21, 2026 15:39

func (c *QueryDetails) tablesFromEventsStatements(ctx context.Context) error {
rs, err := c.dbConnection.QueryContext(ctx, selectQueryTablesSamples)
query := fmt.Sprintf(selectQueryTablesSamples, EXCLUDED_SCHEMAS, c.statementsLimit)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Semgrep identified an issue in your code:
String-formatted SQL query detected. This could lead to SQL injection if the string is not sanitized properly. Audit this call to ensure the SQL is not manipulable by external data.

To resolve this comment:

🔧 No guidance has been designated for this issue. Fix according to your organization's approved methods.

💬 Ignore this finding

Reply with Semgrep commands to ignore this finding.

  • /fp <comment> for false positive
  • /ar <comment> for acceptable risk
  • /other <comment> for all other reasons

Alternatively, triage in Semgrep AppSec Platform to ignore the finding created by string-formatted-query.

We're currently testing semgrep's diff-aware PR comment feature on a subset of our repos-- if you run into issues or find this spammy, please reach out to @danny.cooper in slack and give feedback.

For backwards compatability with gosec, its best to use polyglot suppression comments of the following format for false positives:
// #nosec <gosec rule ID> nosemgrep: <semgrep rule ID>

You can view more details about this finding in the Semgrep AppSec Platform.

Allow limiting the number of recent queries collected in the mysql
`query_details` collector. Default to 250 to match mysqld_exporter's
behavior.
@cristiangreco cristiangreco force-pushed the cristian/dbo11y-mysql-query-details-limit branch from 974a681 to 52cdbca Compare January 21, 2026 15:39
@github-actions
Copy link
Contributor

github-actions bot commented Jan 21, 2026

💻 Deploy preview deleted (fix: Database_observability: allow setting limit for mysql query_details).

@cristiangreco cristiangreco merged commit 085f300 into main Jan 22, 2026
49 of 50 checks passed
@cristiangreco cristiangreco deleted the cristian/dbo11y-mysql-query-details-limit branch January 22, 2026 12:12
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants