Skip to content

Commit

Permalink
Merge agent to master (elastic#16494)
Browse files Browse the repository at this point in the history
This PR move the development of the Elastic Agent inside the master branch, the Agent can be configured locally or using the ingest manager in Kibana. The Agent will take care of starting or stopping the processes depending on the configuration needs.

Co-authored-by: Pier-Hugues Pellerin <[email protected]>
Co-authored-by: Michal Pristas <[email protected]>
  • Loading branch information
ph and michalpristas authored Mar 6, 2020
1 parent ee2d287 commit a9a2779
Show file tree
Hide file tree
Showing 415 changed files with 57,474 additions and 278 deletions.
10 changes: 10 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,16 @@ jobs:
go: $TRAVIS_GO_VERSION
stage: test

# Agent
- os: linux
env: TARGETS="-C x-pack/agent testsuite"
go: $TRAVIS_GO_VERSION
stage: test
- os: osx
env: TARGETS="TEST_ENVIRONMENT=0 -C x-pack/agent testsuite"
go: $TRAVIS_GO_VERSION
stage: test

# Generators
- os: linux
env: TARGETS="-C generator/_templates/metricbeat test test-package"
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BUILD_DIR=$(CURDIR)/build
COVERAGE_DIR=$(BUILD_DIR)/coverage
BEATS?=auditbeat filebeat heartbeat journalbeat metricbeat packetbeat winlogbeat x-pack/functionbeat
BEATS?=auditbeat filebeat heartbeat journalbeat metricbeat packetbeat winlogbeat x-pack/functionbeat x-pack/agent
PROJECTS=libbeat $(BEATS)
PROJECTS_ENV=libbeat filebeat metricbeat
PYTHON_ENV?=$(BUILD_DIR)/python-env
Expand Down
1,114 changes: 969 additions & 145 deletions NOTICE.txt

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions filebeat/filebeat.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"BinaryPath":"filebeat","Args":["-e"],"Configurable":"grpc"}
10 changes: 7 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ require (
github.com/aerospike/aerospike-client-go v1.27.1-0.20170612174108-0f3b54da6bdc
github.com/akavel/rsrc v0.8.0 // indirect
github.com/andrewkroh/sys v0.0.0-20151128191922-287798fe3e43
github.com/antlr/antlr4 v0.0.0-20200225173536-225249fdaef5
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5
github.com/aws/aws-lambda-go v1.6.0
github.com/aws/aws-sdk-go-v2 v0.9.0
Expand Down Expand Up @@ -82,12 +83,14 @@ require (
github.com/golang/protobuf v1.3.2
github.com/golang/snappy v0.0.1
github.com/google/flatbuffers v1.7.2-0.20170925184458-7a6b2bf521e9
github.com/google/go-cmp v0.4.0
github.com/google/gopacket v1.1.18-0.20191009163724-0ad7f2610e34
github.com/google/uuid v1.1.2-0.20190416172445-c2e93f3ae59f // indirect
github.com/googleapis/gnostic v0.3.1-0.20190624222214-25d8b0b66985 // indirect
github.com/gorhill/cronexpr v0.0.0-20161205141322-d520615e531a
github.com/gorilla/mux v1.7.2 // indirect
github.com/gorilla/websocket v1.4.1 // indirect
github.com/hashicorp/go-multierror v0.0.0-20161216184304-ed905158d874
github.com/hashicorp/golang-lru v0.5.2-0.20190520140433-59383c442f7d // indirect
github.com/insomniacslk/dhcp v0.0.0-20180716145214-633285ba52b2
github.com/jcmturner/gofork v1.0.0 // indirect
Expand All @@ -110,6 +113,7 @@ require (
github.com/mitchellh/hashstructure v0.0.0-20170116052023-ab25296c0f51
github.com/mitchellh/mapstructure v1.1.2
github.com/morikuni/aec v1.0.0 // indirect
github.com/oklog/ulid v1.3.1
github.com/opencontainers/go-digest v1.0.0-rc1.0.20190228220655-ac19fd6e7483 // indirect
github.com/opencontainers/image-spec v1.0.2-0.20190823105129-775207bd45b6 // indirect
github.com/pierrre/gotestcover v0.0.0-20160113212533-7b94f124d338
Expand All @@ -127,11 +131,10 @@ require (
github.com/shirou/gopsutil v2.19.11+incompatible
github.com/spf13/cobra v0.0.3
github.com/spf13/pflag v1.0.3
github.com/stretchr/objx v0.1.2-0.20180702103455-b8b73a35e983 // indirect
github.com/stretchr/testify v1.4.0
github.com/tsg/go-daemon v0.0.0-20200207173439-e704b93fd89b
github.com/tsg/gopacket v0.0.0-20190320122513-dd3d0e41124a
github.com/urso/magetools v0.0.0-20200106130147-61080ed7b22b // indirect
github.com/urso/ecslog v0.0.1
github.com/vmware/govmomi v0.0.0-20170802214208-2cad15190b41
github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c
github.com/yuin/gopher-lua v0.0.0-20170403160031-b402f3114ec7 // indirect
Expand All @@ -149,10 +152,11 @@ require (
golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4
google.golang.org/api v0.15.0
google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb
google.golang.org/grpc v1.27.1
gopkg.in/inf.v0 v0.9.0
gopkg.in/jcmturner/gokrb5.v7 v7.3.0 // indirect
gopkg.in/mgo.v2 v2.0.0-20160818020120-3f83fa500528
gopkg.in/yaml.v2 v2.2.7
gopkg.in/yaml.v2 v2.2.8
howett.net/plist v0.0.0-20181124034731-591f970eefbb
k8s.io/api v0.0.0-20190722141453-b90922c02518
k8s.io/apimachinery v0.0.0-20190719140911-bfcf53abc9f8
Expand Down
51 changes: 47 additions & 4 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion libbeat/cmd/instance/beat.go
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ func (b *Beat) configure(settings Settings) error {
logp.Info("Beat ID: %v", b.Info.ID)

// initialize config manager
b.ConfigManager, err = management.Factory()(b.Config.Management, reload.Register, b.Beat.Info.ID)
b.ConfigManager, err = management.Factory(b.Config.Management)(b.Config.Management, reload.Register, b.Beat.Info.ID)
if err != nil {
return err
}
Expand Down
25 changes: 21 additions & 4 deletions libbeat/management/management.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ var Namespace = "libbeat.management"
// DebugK used as key for all things central management
var DebugK = "centralmgmt"

var centralMgmtKey = "x-pack-cm"

// ConfigManager interacts with the beat to update configurations
// from an external source
type ConfigManager interface {
Expand All @@ -47,32 +49,47 @@ type ConfigManager interface {
CheckRawConfig(cfg *common.Config) error
}

// PluginFunc for creating FactoryFunc if it matches a config
type PluginFunc func(*common.Config) FactoryFunc

// FactoryFunc for creating a config manager
type FactoryFunc func(*common.Config, *reload.Registry, uuid.UUID) (ConfigManager, error)

// Register a config manager
func Register(name string, fn FactoryFunc, stability feature.Stability) {
func Register(name string, fn PluginFunc, stability feature.Stability) {
f := feature.New(Namespace, name, fn, feature.MakeDetails(name, "", stability))
feature.MustRegister(f)
}

// Factory retrieves config manager constructor. If no one is registered
// it will create a nil manager
func Factory() FactoryFunc {
func Factory(cfg *common.Config) FactoryFunc {
factories, err := feature.GlobalRegistry().LookupAll(Namespace)
if err != nil {
return nilFactory
}

for _, f := range factories {
if factory, ok := f.Factory().(FactoryFunc); ok {
return factory
if plugin, ok := f.Factory().(PluginFunc); ok {
if factory := plugin(cfg); factory != nil {
return factory
}
}
}

return nilFactory
}

type modeConfig struct {
Mode string `config:"mode" yaml:"mode"`
}

func defaultModeConfig() *modeConfig {
return &modeConfig{
Mode: centralMgmtKey,
}
}

// nilManager, fallback when no manager is present
type nilManager struct{}

Expand Down
52 changes: 52 additions & 0 deletions vendor/github.com/antlr/antlr4/LICENSE.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

152 changes: 152 additions & 0 deletions vendor/github.com/antlr/antlr4/runtime/Go/antlr/atn.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a9a2779

Please sign in to comment.