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

Don't stop Metricbeat if aerospike server is down #6874

Merged
merged 1 commit into from
Apr 17, 2018
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.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ https://github.com/elastic/beats/compare/v6.0.0-beta2...master[Check the HEAD di
- Fix Windows perfmon metricset so that it sends metrics when an error occurs. {pull}6542[6542]
- Fix Kubernetes calculated fields store. {pull}6564{6564}
- Exclude bind mounts in fsstat and filesystem metricsets. {pull}6819[6819]
- Don't stop Metricbeat if aerospike server is down. {pull}6874[6874]

*Packetbeat*

Expand Down
24 changes: 18 additions & 6 deletions metricbeat/module/aerospike/namespace/namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func init() {
// multiple fetch calls.
type MetricSet struct {
mb.BaseMetricSet
host *as.Host
client *as.Client
}

Expand All @@ -47,14 +48,9 @@ func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
return nil, errors.Wrap(err, "Invalid host format, expected hostname:port")
}

client, err := as.NewClientWithPolicyAndHost(as.NewClientPolicy(), host)
if err != nil {
return nil, err
}

return &MetricSet{
BaseMetricSet: base,
client: client,
host: host,
}, nil
}

Expand All @@ -64,6 +60,10 @@ func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
func (m *MetricSet) Fetch() ([]common.MapStr, error) {
var events []common.MapStr

if err := m.connect(); err != nil {
return nil, err
}

for _, node := range m.client.GetNodes() {
info, err := as.RequestNodeInfo(node, "namespaces")
if err != nil {
Expand Down Expand Up @@ -91,3 +91,15 @@ func (m *MetricSet) Fetch() ([]common.MapStr, error) {

return events, nil
}

// create an aerospike client if it doesn't exist yet
func (m *MetricSet) connect() error {
if m.client == nil {
client, err := as.NewClientWithPolicyAndHost(as.NewClientPolicy(), m.host)
if err != nil {
return err
}
m.client = client
}
return nil
}