-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Beatless initial PR Add a new beat inside the x-pack folder under the Elastic License, minimal requirement changes to have a build and a test running. Main makefile exclude ASL2 for x-pack but check for Elastic. Beats can override the license in their Makefile.
- Loading branch information
Showing
26 changed files
with
2,107 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.idea | ||
.vagrant | ||
.vscode | ||
/*/_meta/kibana.generated | ||
beatless | ||
build | ||
data | ||
fields.yml | ||
logs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
BEAT_NAME?=beatless | ||
LICENSE=Elastic | ||
BEAT_TITLE?=Beatless | ||
SYSTEM_TESTS?=true | ||
BEAT_PATH?=github.com/elastic/beats/x-pack/${BEAT_NAME} | ||
TEST_ENVIRONMENT?=false | ||
GOX_FLAGS=-arch="amd64 386 arm ppc64 ppc64le" | ||
ES_BEATS?=../../ | ||
FIELDS_FILE_PATH=module | ||
|
||
# Path to the libbeat Makefile | ||
include $(ES_BEATS)/libbeat/scripts/Makefile | ||
|
||
# Runs all collection steps and updates afterwards | ||
.PHONY: collect | ||
collect: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
################### Beatless Configuration Example ######################### | ||
|
||
############################# Beatless ###################################### | ||
|
||
beatless: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
- key: beatless | ||
title: beatless | ||
description: | ||
fields: | ||
- name: counter | ||
type: long | ||
required: true | ||
description: > | ||
PLEASE UPDATE DOCUMENTATION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
// or more contributor license agreements. Licensed under the Elastic License; | ||
// you may not use this file except in compliance with the Elastic License. | ||
|
||
package beater | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/elastic/beats/libbeat/beat" | ||
"github.com/elastic/beats/libbeat/common" | ||
"github.com/elastic/beats/libbeat/logp" | ||
|
||
"github.com/elastic/beats/x-pack/beatless/bus" | ||
"github.com/elastic/beats/x-pack/beatless/config" | ||
) | ||
|
||
// Beatless configuration. | ||
type Beatless struct { | ||
done chan struct{} | ||
config config.Config | ||
log *logp.Logger | ||
|
||
// TODO: Add registry reference here. | ||
} | ||
|
||
// New creates an instance of beatless. | ||
func New(b *beat.Beat, cfg *common.Config) (beat.Beater, error) { | ||
c := config.DefaultConfig | ||
if err := cfg.Unpack(&c); err != nil { | ||
return nil, fmt.Errorf("error reading config file: %v", err) | ||
} | ||
|
||
bt := &Beatless{ | ||
done: make(chan struct{}), | ||
config: c, | ||
log: logp.NewLogger("beatless"), | ||
} | ||
return bt, nil | ||
} | ||
|
||
// Run starts beatless. | ||
func (bt *Beatless) Run(b *beat.Beat) error { | ||
bt.log.Info("beatless is running") | ||
defer bt.log.Info("beatless stopped running") | ||
|
||
client, err := b.Publisher.Connect() | ||
if err != nil { | ||
return err | ||
} | ||
defer client.Close() | ||
|
||
// NOTE: Do not review below, this is the minimal to have a working PR. | ||
bus := bus.New(client) | ||
// TODO: noop | ||
bus.Listen() | ||
|
||
// Stop until we are tell to shutdown. | ||
// TODO this is where the events catcher starts. | ||
select { | ||
case <-bt.done: | ||
// Stop catching events. | ||
} | ||
return nil | ||
} | ||
|
||
// Stop stops beatless. | ||
func (bt *Beatless) Stop() { | ||
bt.log.Info("beatless is stopping") | ||
defer bt.log.Info("beatless is stopped") | ||
close(bt.done) | ||
} |
Oops, something went wrong.