Skip to content

[Metricbeat] [SQL] Remove connection string from error message#44577

Merged
mykola-elastic merged 17 commits intoelastic:mainfrom
mykola-elastic:metricbeat-sql-password-masking
Jun 4, 2025
Merged

[Metricbeat] [SQL] Remove connection string from error message#44577
mykola-elastic merged 17 commits intoelastic:mainfrom
mykola-elastic:metricbeat-sql-password-masking

Conversation

@mykola-elastic
Copy link
Contributor

@mykola-elastic mykola-elastic commented May 30, 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

@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label May 30, 2025
@github-actions
Copy link
Contributor

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)

@mergify
Copy link
Contributor

mergify bot commented May 30, 2025

This pull request does not have a backport label.
If this is a bug or security fix, could you label this PR @mykola-elastic? 🙏.
For such, you'll need to label your PR with:

  • The upcoming major version of the Elastic Stack
  • The upcoming minor version of the Elastic Stack (if you're not pushing a breaking change)

To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-8./d is the label to automatically backport to the 8./d branch. /d is the digit
  • backport-active-all is the label that automatically backports to all active branches.
  • backport-active-8 is the label that automatically backports to all active minor branches for the 8 major.
  • backport-active-9 is the label that automatically backports to all active minor branches for the 9 major.
@mykola-elastic mykola-elastic added the Team:Obs-InfraObs Label for the Observability Infrastructure Monitoring team label May 30, 2025
@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label May 30, 2025
@mykola-elastic mykola-elastic added Metricbeat Metricbeat needs_team Indicates that the issue/PR needs a Team:* label labels May 30, 2025
@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label May 30, 2025
@mykola-elastic mykola-elastic force-pushed the metricbeat-sql-password-masking branch from 1ef2aed to 3eb95c1 Compare May 30, 2025 13:51
@mykola-elastic mykola-elastic marked this pull request as ready for review June 2, 2025 06:59
@mykola-elastic mykola-elastic requested a review from a team as a code owner June 2, 2025 06:59
@mykola-elastic mykola-elastic added backport-active-9 Automated backport with mergify to all the active 9.[0-9]+ branches backport-active-8 Automated backport with mergify to all the active 8.[0-9]+ branches labels Jun 2, 2025
@mykola-elastic mykola-elastic requested a review from a team as a code owner June 2, 2025 08:11
@mykola-elastic mykola-elastic force-pushed the metricbeat-sql-password-masking branch from 7a0358c to d8516d3 Compare June 2, 2025 08:18
@lalit-satapathy lalit-satapathy requested a review from shmsr June 2, 2025 09:54
@devamanv devamanv self-requested a review June 3, 2025 16:45
@mykola-elastic mykola-elastic requested a review from shmsr June 4, 2025 06:44
Copy link
Member

@ishleenk17 ishleenk17 left a comment

Choose a reason for hiding this comment

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

Looks good!

@mykola-elastic mykola-elastic merged commit fafabad into elastic:main Jun 4, 2025
34 checks passed
@github-actions
Copy link
Contributor

github-actions bot commented Jun 4, 2025

@Mergifyio backport 8.17 8.18 8.19 9.0

@mergify
Copy link
Contributor

mergify bot commented Jun 4, 2025

mergify bot pushed a commit that referenced this pull request Jun 4, 2025
mergify bot pushed a commit that referenced this pull request Jun 4, 2025
mergify bot pushed a commit that referenced this pull request Jun 4, 2025
mergify bot pushed a commit that referenced this pull request Jun 4, 2025
mykola-elastic added a commit that referenced this pull request Jun 5, 2025
…rom error message (#44633)

* [Metricbeat] [SQL] Remove connection string from error message (#44577)

(cherry picked from commit fafabad)

* Remove !requirefips from query_test.go

---------

Co-authored-by: mykola-elastic <mykola.kmet@elastic.co>
mykola-elastic added a commit that referenced this pull request Jun 5, 2025
…rom error message (#44634)

* [Metricbeat] [SQL] Remove connection string from error message (#44577)

(cherry picked from commit fafabad)

* Remove !requirefips from query_test.go

---------

Co-authored-by: mykola-elastic <mykola.kmet@elastic.co>
mykola-elastic added a commit that referenced this pull request Jun 5, 2025
… (#44635)

(cherry picked from commit fafabad)

Co-authored-by: mykola-elastic <mykola.kmet@elastic.co>
mykola-elastic added a commit that referenced this pull request Jun 5, 2025
…om error message (#44636)

* [Metricbeat] [SQL] Remove connection string from error message (#44577)

(cherry picked from commit fafabad)

* Remove !requirefips from query_test.go

---------

Co-authored-by: mykola-elastic <mykola.kmet@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-active-8 Automated backport with mergify to all the active 8.[0-9]+ branches backport-active-9 Automated backport with mergify to all the active 9.[0-9]+ branches Metricbeat Metricbeat Team:Obs-InfraObs Label for the Observability Infrastructure Monitoring team

8 participants