Skip to content

Commit

Permalink
Cherry-pick #17378 to 7.x: [Metricbeat] Add a switch to the driver de…
Browse files Browse the repository at this point in the history
…finition on SQL module to use pretty names (#17708)
  • Loading branch information
sayden authored May 5, 2020
1 parent 76db4c0 commit 2deccde
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Fix Disk Used and Disk Usage visualizations in the Metricbeat System dashboards. {issue}12435[12435] {pull}17272[17272]
- Fix missing Accept header for Prometheus and OpenMetrics module. {issue}16870[16870] {pull}17291[17291]
- Fix issue in Jolokia module when mbean contains multiple quoted properties. {issue}17375[17375] {pull}17374[17374]
- Further revise check for bad data in docker/memory. {pull}17400[17400]
- Further revise check for bad data in docker/memory. {pull}17400[17400]
- Combine cloudwatch aggregated metrics into single event. {pull}17345[17345]
- Fix how we filter services by name in system/service {pull}17400[17400]
- Fix cloudwatch metricset missing tags collection. {issue}17419[17419] {pull}17424[17424]
Expand All @@ -214,6 +214,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- 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]
- Fix overflow on Prometheus rates when new buckets are added on the go. {pull}17753[17753]
- 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
}

0 comments on commit 2deccde

Please sign in to comment.