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

[libbeat] AWS ELB Monitoring #12401

Merged
merged 78 commits into from
Jul 30, 2019
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
72894c5
Unify heartbeat jobs and tasks for simplicity
andrewvc Nov 14, 2018
ab4a73d
AWS Autodisco
andrewvc Oct 17, 2018
d0bdd60
checkpoint
andrewvc Nov 15, 2018
2c69797
Everything is a job
andrewvc Nov 16, 2018
5e223ba
Improve job types
andrewvc Nov 16, 2018
c54f02d
Checkpoint
andrewvc Nov 16, 2018
53b53e0
Checkpoint
andrewvc Nov 16, 2018
f83d586
CHECKPOINT
andrewvc Nov 16, 2018
3735992
checkpoint
andrewvc Nov 19, 2018
3a27a98
Merge remote-tracking branch 'origin/master' into auto-elb
andrewvc Jun 3, 2019
885eda8
Fix govendor
andrewvc Jun 3, 2019
900b2fd
Fix govendor
andrewvc Jun 3, 2019
9694836
Updates
andrewvc Jun 3, 2019
e5db213
Autodisco sorta works
andrewvc Jun 4, 2019
338afdc
moar
andrewvc Jun 6, 2019
d7b7982
Actually handle additional listeners
andrewvc Jun 6, 2019
2173a3e
More cleanup
andrewvc Jun 6, 2019
48285fa
Support custom access key
andrewvc Jun 7, 2019
64b2d60
Moar
andrewvc Jun 7, 2019
7de2b77
Improve asciidocs
andrewvc Jun 7, 2019
eda8ef2
Revert heartbeat yml
andrewvc Jun 7, 2019
9e7fd30
Fix authentication_failure event.type for security module (#12393)
andrewkroh Jun 3, 2019
381e161
Hardcode namespace for prometheus metrics (#12400)
jsoriano Jun 3, 2019
e98297f
Add documentation for Winlogbeat modules (#12361)
andrewkroh Jun 3, 2019
5298de2
Fix references to `beat.timezone` in docs (#12399)
jsoriano Jun 3, 2019
4c7dab9
Parse the timezone in PostgreSQL logs as part of the date (#12338)
jsoriano Jun 3, 2019
9b62b34
Timeouts on calls to docker api (#12310)
marqc Jun 4, 2019
b43d8cf
Add operating system from vsphere to 'os' field (#12391)
jsoriano Jun 4, 2019
bc22929
Un-skip flaky tests (#12388)
ycombinator Jun 4, 2019
023a46c
Load configuration from modules.d when running setup subcommand (#12340)
kvch Jun 4, 2019
c401af9
[Metricbeat] Decrease timeout time of compose.EnsureUp functions (#10…
sayden Jun 4, 2019
31f72d0
Mark Cisco and PANW modules as beta (#12426)
adriansr Jun 4, 2019
07de1e3
Validate stack modules' metricsets when xpack.enabled = true (#12386)
ycombinator Jun 4, 2019
4e5f001
Fix a typo in kubernetes deploy readme files (#12413)
Jun 4, 2019
05b42a6
Ensure Pod UID is always present in `pod` metricset (#12345)
Jun 4, 2019
26c87ba
[dev guide] Add docs on optional schema arguments (#12371)
fearful-symmetry Jun 5, 2019
f9ad369
Update filebeat EnvoyProxy module README file to reflect the changes …
Jun 5, 2019
1e9ecca
Update CoreDNS module README file to reflect the changes to autodisco…
Jun 5, 2019
1f00ab3
Revert "Enforce presence of Certificate Authorities, Certificate file…
ph Jun 5, 2019
4fc44ee
Govendor ECS 1.0.1 (#12317)
Jun 5, 2019
06d3f08
Don't duplicate @timestamp to beat.Event's Fields (#12449)
andrewkroh Jun 5, 2019
a23a8b7
migrate the system module to reporterV2 with error return, part one (…
fearful-symmetry Jun 6, 2019
338fabb
Remove `convert_timezone` option from filebeat system module (#12410)
jsoriano Jun 6, 2019
03752cd
Export Kibana Client's Transport and Version (#12422)
jalvz Jun 7, 2019
89cab2f
Fix 11975 - change Kubernetes container cpu cores fields to float (#1…
easkay Jun 7, 2019
0f883d1
[Heartbeat] Fix Continuation Dispatch / mode: all pings (#12458)
andrewvc Jun 7, 2019
c449d3c
Remove ECS from aws dashboard names (#12471)
kaiyan-sheng Jun 7, 2019
e5b8a8c
A variety of improvements
andrewvc Jun 7, 2019
e0202ec
Add ELB Listener fields
andrewvc Jun 12, 2019
1b078e4
Merge remote-tracking branch 'origin/master' into auto-elb
andrewvc Jun 12, 2019
462d0de
Revert accidental notice change
andrewvc Jun 12, 2019
ceedb5b
Incorporate PR feedback
andrewvc Jun 13, 2019
dce76e4
Incorporate PR feedback
andrewvc Jun 13, 2019
f5d8a69
Improve fields
andrewvc Jun 13, 2019
11ab929
Update all vendored imports
andrewvc Jun 14, 2019
0a1ba5a
Merge remote-tracking branch 'origin/master' into auto-elb
andrewvc Jun 17, 2019
d8e7230
Reset vendor to master
andrewvc Jun 17, 2019
555fd32
Merge remote-tracking branch 'origin/master' into auto-elb
andrewvc Jul 23, 2019
adf4d23
Update
andrewvc Jul 23, 2019
3817d9b
Update
andrewvc Jul 23, 2019
c279606
Incorporate PR feedback
andrewvc Jul 24, 2019
7242238
Merge remote-tracking branch 'origin/master' into auto-elb
andrewvc Jul 24, 2019
0d075ec
Incorporate PR feedback
andrewvc Jul 24, 2019
282cec2
Add timeout equal to interval
andrewvc Jul 24, 2019
7056db5
Incorporate PR feedback
andrewvc Jul 24, 2019
563e85d
Various improvements
andrewvc Jul 25, 2019
d35e091
Improve docs
andrewvc Jul 25, 2019
a5340f1
Fix whitespace
andrewvc Jul 25, 2019
ee5fdde
Merge remote-tracking branch 'origin/master' into auto-elb
andrewvc Jul 25, 2019
aa019c3
Fix test race
andrewvc Jul 29, 2019
bf2904e
Fix detected races
andrewvc Jul 29, 2019
7a6f151
Merge remote-tracking branch 'origin/master' into auto-elb
andrewvc Jul 29, 2019
431c5f6
Fix detected races
andrewvc Jul 29, 2019
9a53417
Make timeouts more lax
andrewvc Jul 29, 2019
0af6bd4
Fix docs
andrewvc Jul 29, 2019
f8683a0
Fix docs
andrewvc Jul 29, 2019
e120361
Just make the docs work for now
andrewvc Jul 30, 2019
abfb978
Don't leave in broken docs
andrewvc Jul 30, 2019
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: 2 additions & 0 deletions heartbeat/docs/autodiscover-aws-elb-config.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ heartbeat.autodiscover:
-------------------------------------------------------------------------------------

This configuration launches a `tcp` monitor for all ELBs that have a declared port (TODO: come up with a better condition).

This autodiscover provider takes our standard AWS credentials options. Please see <<aws-credentials-config>> for more details.
2 changes: 2 additions & 0 deletions libbeat/docs/shared-autodiscover.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@ ifdef::autodiscoverAWSELB[]
[float]
===== Amazon ELBs
andrewvc marked this conversation as resolved.
Show resolved Hide resolved

*Note: This provider is experimental*

The Amazon ELB autodiscover provider discovers https://aws.amazon.com/elasticloadbalancing/[ELBs] and their listeners. This is useful when you don't want to connect
directly to a service, but rather to the ELB fronting a pool of services.

Expand Down
4 changes: 2 additions & 2 deletions x-pack/libbeat/autodiscover/providers/aws/elb/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ type Config struct {

// AWS Specific autodiscover fields

Regions []string `config:"regions" validate:"required"`
aws.ConfigAWS
Regions []string `config:"regions" validate:"required"`
AWSConfig aws.ConfigAWS `config:",inline"`
jsoriano marked this conversation as resolved.
Show resolved Hide resolved
}
andrewvc marked this conversation as resolved.
Show resolved Hide resolved

func defaultConfig() *Config {
Expand Down
24 changes: 14 additions & 10 deletions x-pack/libbeat/autodiscover/providers/aws/elb/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ import (
"context"
"sync"

"github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2"
"github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2/elasticloadbalancingv2iface"
"go.uber.org/multierr"

"github.com/elastic/beats/libbeat/logp"
andrewvc marked this conversation as resolved.
Show resolved Hide resolved

"github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2"
"go.uber.org/multierr"
)

const logSelector = "autodiscover-elb-fetch"
Expand Down Expand Up @@ -137,15 +136,17 @@ func (p *fetchRequest) fetch() ([]*lbListener, error) {

func (p *fetchRequest) fetchAllPages() {
// Keep fetching pages unless we're stopped OR there are no pages left
Outer:
for {
select {
case <-p.context.Done():
logp.Debug(logSelector, "done fetching ELB pages, context cancelled")
break Outer
return
default:
p.fetchNextPage()
logp.Debug(logSelector, "API page fetched")
if !p.fetchNextPage() {
logp.Debug(logSelector, "fetched all ELB pages")
return
}
logp.Debug(logSelector, "fetched ELB page")
}
}
}
Expand Down Expand Up @@ -189,12 +190,15 @@ func (p *fetchRequest) fetchListeners(lb elasticloadbalancingv2.LoadBalancer) {
p.recordErrResult(listen.Err())
}

Outer:
for listen.Next(p.context) {
for {
select {
case <-p.context.Done():
break Outer
return
default:
if !listen.Next(p.context) {
return
}

for _, listener := range listen.CurrentPage().Listeners {
p.recordGoodResult(&lb, &listener)
}
Expand Down
8 changes: 4 additions & 4 deletions x-pack/libbeat/autodiscover/providers/aws/elb/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ func AutodiscoverBuilder(bus bus.Bus, uuid uuid.UUID, c *common.Config) (autodis
var clients []elasticloadbalancingv2iface.ClientAPI
for _, region := range config.Regions {
awsCfg, err := awscommon.GetAWSCredentials(awscommon.ConfigAWS{
AccessKeyID: config.AccessKeyID,
SecretAccessKey: config.SecretAccessKey,
SessionToken: config.SessionToken,
ProfileName: config.ProfileName,
AccessKeyID: config.AWSConfig.AccessKeyID,
SecretAccessKey: config.AWSConfig.SecretAccessKey,
SessionToken: config.AWSConfig.SessionToken,
ProfileName: config.AWSConfig.ProfileName,
})
if err != nil {
logp.Err("error loading AWS config for aws_elb autodiscover provider: %s", err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ import (
"testing"
"time"

"github.com/elastic/beats/libbeat/common"

"github.com/gofrs/uuid"
"github.com/pkg/errors"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
andrewvc marked this conversation as resolved.
Show resolved Hide resolved

"github.com/elastic/beats/libbeat/common"
"github.com/elastic/beats/libbeat/common/bus"
)

Expand Down
12 changes: 6 additions & 6 deletions x-pack/libbeat/autodiscover/providers/aws/elb/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@ type watcher struct {
onStop func(uuid string)
done chan struct{}
ticker *time.Ticker
interval time.Duration
period time.Duration
lbListeners map[string]uint64
}

func newWatcher(
fetcher fetcher,
interval time.Duration,
period time.Duration,
onStart func(uuid string, lblMap *lbListener),
onStop func(uuid string)) *watcher {
return &watcher{
fetcher: fetcher,
onStart: onStart,
onStop: onStop,
done: make(chan struct{}),
ticker: time.NewTicker(interval),
interval: interval,
ticker: time.NewTicker(period),
period: period,
lbListeners: map[string]uint64{},
}
}
Expand All @@ -57,7 +57,6 @@ func (w *watcher) forever() {
err := w.once()
if err != nil {
logp.Err("error while fetching AWS ELBs: %s", err)
return
}
}
}
Expand All @@ -66,11 +65,12 @@ func (w *watcher) forever() {
// once executes the watch loop a single time.
// This is mostly useful for testing.
func (w *watcher) once() error {
ctx, _ := context.WithTimeout(context.Background(), w.interval)
ctx, _ := context.WithTimeout(context.Background(), w.period)
fetchedLbls, err := w.fetcher.fetch(ctx)
if err != nil {
return err
}
logp.Info("fetched %d load balancer listeners from AWS for autodiscovery", len(fetchedLbls))
andrewvc marked this conversation as resolved.
Show resolved Hide resolved

oldGen := w.gen
w.gen++
Expand Down