Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Metricbeat] Add a switch to the driver definition on SQL module to use pretty names #17378

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Fix "ID" event generator of Google Cloud module {issue}17160[17160] {pull}17608[17608]
- Add privileged option for Auditbeat in Openshift {pull}17637[17637]
- Fix storage metricset to allow config without region/zone. {issue}17623[17623] {pull}17624[17624]
- Add a switch to the driver definition on SQL module to use pretty names {pull}17378[17378]

*Packetbeat*

Expand Down
12 changes: 11 additions & 1 deletion x-pack/metricbeat/module/sql/query/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (m *MetricSet) Fetch(ctx context.Context, report mb.ReporterV2) error {
// DB gets a client ready to query the database
func (m *MetricSet) DB() (*sqlx.DB, error) {
if m.db == nil {
db, err := sqlx.Open(m.Driver, m.HostData().URI)
db, err := sqlx.Open(switchDriverName(m.Driver), m.HostData().URI)
if err != nil {
return nil, errors.Wrap(err, "opening connection")
}
Expand Down Expand Up @@ -251,3 +251,13 @@ func (m *MetricSet) Close() error {
}
return errors.Wrap(m.db.Close(), "closing connection")
}

// switchDriverName switches between driver name and a pretty name for a driver. For example, 'oracle' driver is called
// 'godror' so this detail implementation must be hidden to the user, that should only choose and see 'oracle' as driver
func switchDriverName(d string) string {
if d == "oracle" {
return "godror"
}

return d
}