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

Cherry-pick #12950 to 7.1: Reuse connections in redis info metricset #12980

Merged
merged 2 commits into from
Jul 23, 2019
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
2 changes: 1 addition & 1 deletion CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ https://github.com/elastic/beats/compare/v7.1.1...7.1[Check the HEAD diff]
- Require certificate authorities, certificate file, and key when SSL is enabled for module http metricset server. {pull}12355[12355]
- In the kibana/stats metricset, only log error (don't also index it) if xpack is enabled. {pull}12353[12353]
- When TLS is configured for the http metricset and a `certificate_authorities` is configured we now default to `required` for the `client_authentication`. {pull}12584[12584]
- Fix connections leak in redis module {pull}12914[12914]
- Fix connections leak in redis module {pull}12914[12914] {pull}12950[12950]

*Packetbeat*

Expand Down
8 changes: 6 additions & 2 deletions metricbeat/module/redis/info/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
// Fetch fetches metrics from Redis by issuing the INFO command.
func (m *MetricSet) Fetch(r mb.ReporterV2) {
conn := m.Connection()
defer conn.Close()
defer func() {
if err := conn.Close(); err != nil {
debugf("failed to release connection: %v", err)
}
}()

// Fetch default INFO.
info, err := redis.FetchRedisInfo("default", conn)
Expand All @@ -80,7 +84,7 @@ func (m *MetricSet) Fetch(r mb.ReporterV2) {
}
}

slowLogLength, err := redis.FetchSlowLogLength(m.Connection())
slowLogLength, err := redis.FetchSlowLogLength(conn)
if err != nil {
logp.Err("Failed to fetch slow log length: %s", err)
return
Expand Down
6 changes: 5 additions & 1 deletion metricbeat/module/redis/key/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
// Fetch fetches information from Redis keys
func (m *MetricSet) Fetch(r mb.ReporterV2) {
conn := m.Connection()
defer conn.Close()
defer func() {
if err := conn.Close(); err != nil {
debugf("failed to release connection: %v", err)
}
}()

for _, p := range m.patterns {
if err := redis.Select(conn, p.Keyspace); err != nil {
Expand Down
6 changes: 5 additions & 1 deletion metricbeat/module/redis/keyspace/keyspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
// Fetch fetches metrics from Redis by issuing the INFO command.
func (m *MetricSet) Fetch(r mb.ReporterV2) {
conn := m.Connection()
defer conn.Close()
defer func() {
if err := conn.Close(); err != nil {
debugf("failed to release connection: %v", err)
}
}()

// Fetch default INFO.
info, err := redis.FetchRedisInfo("keyspace", conn)
Expand Down