Skip to content

[9.0](backport #44577) [Metricbeat] [SQL] Remove connection string from error message#44636

Merged
mykola-elastic merged 3 commits into9.0from
mergify/bp/9.0/pr-44577
Jun 5, 2025
Merged

[9.0](backport #44577) [Metricbeat] [SQL] Remove connection string from error message#44636
mykola-elastic merged 3 commits into9.0from
mergify/bp/9.0/pr-44577

Conversation

@mergify
Copy link
Contributor

@mergify mergify bot commented Jun 4, 2025

Proposed commit message

See title.

Use cases

This PR handles specifically the case when the mssql driver is used and the port number supplied is wrong, for example, 4xf. In this case the underlying library exposes the password (the whole connection string) in the error message and we get something like this in the logs:

[elastic_agent][warn] Unit state changed sql/metrics-default-sql/metrics-sql-1ff7729a-ac72-45c3-a643-dbd3bc24f4aa (HEALTHY->DEGRADED): Error fetching data for metricset sql.query: cannot open connection: testing connection: parse "sqlserver://SA:1234_asdf@host.docker.internal:4xf": invalid port ":4xf" after host

After this fix the string gets replaced by (redacted), like this:

[elastic_agent][warn] Unit state changed sql/metrics-default-sql/metrics-sql-1ff7729a-ac72-45c3-a643-dbd3bc24f4aa (HEALTHY->DEGRADED): Error fetching data for metricset sql.query: cannot open connection: testing connection: parse "(redacted)": invalid port ":4xf" after host

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

Disruptive User Impact

Related issues


This is an automatic backport of pull request #44577 done by [Mergify](https://mergify.com).
@mergify mergify bot requested a review from a team as a code owner June 4, 2025 11:26
@mergify mergify bot added the backport label Jun 4, 2025
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Jun 4, 2025
@mykola-elastic mykola-elastic added the Team:Obs-InfraObs Label for the Observability Infrastructure Monitoring team label Jun 4, 2025
@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Jun 4, 2025
@mykola-elastic mykola-elastic merged commit c6cb270 into 9.0 Jun 5, 2025
27 checks passed
@mykola-elastic mykola-elastic deleted the mergify/bp/9.0/pr-44577 branch June 5, 2025 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport Team:Obs-InfraObs Label for the Observability Infrastructure Monitoring team

1 participant