Skip to content

Commit 1a069b1

Browse files
committed
Merge remote-tracking branch 'upstream/master' into feature/fix-warnings-archive
* upstream/master: Fix minor spelling error in Jenkinsfile (elastic#19153) [CI] fail if not possible to install python3 (elastic#19164) [Elastic Agent] Improved mage demo experience (elastic#18445) [yum] Clear cached data and add retry loop (elastic#19182) fix lint job by updating NOTICE (elastic#19161) Fix tags for coredns/envoyproxy (elastic#19134) Disable host.* fields by default for CrowdStrike module (elastic#19132) Allow host.* fields to be disabled in Zeek module (elastic#19113) Rename to management.Manager, add UpdateStatus to Manager interface. (elastic#19114) Edit Elastic Agent docs (elastic#19146) [JJBB] create job definition for the golang-crossbuild project (elastic#19162) Fix incorrect usage of hints builder when exposed port is a substring of the hint (elastic#19052) Add basic cloudfoundry integration tests (elastic#19018)
2 parents 6af8dfb + dcac363 commit 1a069b1

File tree

76 files changed

+1403
-713
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+1403
-713
lines changed

.ci/jobs/golang-crossbuild-mbp.yml

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
- job:
3+
name: Beats/golang-crossbuild-mbp
4+
display-name: Pipeline for golang-crossbuild
5+
description: Jenkins pipeline for the golang-crossbuild project.
6+
view: Beats
7+
project-type: multibranch
8+
script-path: Jenkinsfile
9+
scm:
10+
- github:
11+
branch-discovery: no-pr
12+
discover-pr-forks-strategy: merge-current
13+
discover-pr-forks-trust: permission
14+
discover-pr-origin: merge-current
15+
discover-tags: true
16+
notification-context: 'beats-ci'
17+
repo: golang-crossbuild
18+
repo-owner: elastic
19+
credentials-id: 2a9602aa-ab9f-4e52-baf3-b71ca88469c7-UserAndToken
20+
ssh-checkout:
21+
credentials: f6c7695a-671e-4f4f-a331-acdce44ff9ba
22+
build-strategies:
23+
- tags:
24+
ignore-tags-older-than: -1
25+
ignore-tags-newer-than: -1
26+
- regular-branches: true
27+
- change-request:
28+
ignore-target-only-changes: false
29+
clean:
30+
after: true
31+
before: true
32+
prune: true
33+
shallow-clone: true
34+
depth: 4
35+
do-not-fetch-tags: true
36+
submodule:
37+
disable: false
38+
recursive: true
39+
parent-credentials: true
40+
timeout: 100
41+
timeout: '15'
42+
use-author: true
43+
wipe-workspace: 'True'

.ci/scripts/install-tools.bat

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ where mage
2020

2121
if not exist C:\Python38\python.exe (
2222
REM Install python 3.8.
23-
choco install python -y -r --no-progress --version 3.8.2
23+
choco install python -y -r --no-progress --version 3.8.2 || echo ERROR && exit /b
2424
)
2525
python --version
2626
where python

CHANGELOG-developer.next.asciidoc

+2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ The list below covers the major changes between 7.0.0-rc2 and master only.
4646
Your magefile.go will require a change to adapt the devtool API. See the pull request for
4747
more details. {pull}18148[18148]
4848
- The Elasticsearch client settings expect the API key to be raw (not base64-encoded). {issue}18939[18939] {pull}18945[18945]
49+
- `management.ConfigManager` has been renamed to `management.Manager`. {pull}19114[19114]
50+
- `UpdateStatus` has been added to the `management.Manager` interface. {pull}19114[19114]
4951

5052
==== Bugfixes
5153

CHANGELOG.next.asciidoc

+5
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,14 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
3939
* CEF {pull}18223[18223]
4040
* PANW {pull}18223[18223]
4141
* Cisco {pull}18753[18753]
42+
* CrowdStrike {pull}19132[19132]
4243
* iptables {pull}18756[18756]
4344
* Checkpoint {pull}18754[18754]
4445
* Netflow {pull}19087[19087]
46+
* Zeek {pull}19113[19113] (`forwarded` tag is not included by default)
4547
* Suricata {pull}19107[19107] (`forwarded` tag is not included by default)
48+
* CoreDNS {pull}19134[19134] (`forwarded` tag is not included by default)
49+
* Envoy Proxy {pull}19134[19134] (`forwarded` tag is not included by default)
4650
- Preserve case of http.request.method. ECS prior to 1.6 specified normalizing to lowercase, which lost information. Affects filesets: apache/access, elasticsearch/audit, iis/access, iis/error, nginx/access, nginx/ingress_controller, aws/elb, suricata/eve, zeek/http. {issue}18154[18154] {pull}18359[18359]
4751
- Adds check on `<no value>` config option value for the azure input `resource_manager_endpoint`. {pull}18890[18890]
4852
- Okta module now requires objects instead of JSON strings for the `http_headers`, `http_request_body`, `pagination`, `rate_limit`, and `ssl` variables. {pull}18953[18953]
@@ -241,6 +245,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
241245
- Add missing network.sent_packets_count metric into compute metricset in googlecloud module. {pull}18802[18802]
242246
- Fix compute and pubsub dashboard for googlecloud module. {issue}18962[18962] {pull}18980[18980]
243247
- Fix crash on vsphere module when Host information is not available. {issue}18996[18996] {pull}19078[19078]
248+
- Fix incorrect usage of hints builder when exposed port is a substring of the hint {pull}19052[19052]
244249

245250
*Packetbeat*
246251

Jenkinsfile

+4-4
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ pipeline {
704704
stage('Generators Metricbeat Linux'){
705705
steps {
706706
// FIXME see https://github.com/elastic/beats/issues/18132
707-
catchError(buildResult: 'SUCCESS', message: 'Ignore error temporally', stageResult: 'UNSTABLE') {
707+
catchError(buildResult: 'SUCCESS', message: 'Ignore error temporarily', stageResult: 'UNSTABLE') {
708708
makeTarget(context: "Generators Metricbeat Linux", target: "-C generator/_templates/metricbeat test")
709709
makeTarget(context: "Generators Metricbeat Linux", target: "-C generator/_templates/metricbeat test-package")
710710
}
@@ -713,7 +713,7 @@ pipeline {
713713
stage('Generators Beat Linux'){
714714
steps {
715715
// FIXME see https://github.com/elastic/beats/issues/18132
716-
catchError(buildResult: 'SUCCESS', message: 'Ignore error temporally', stageResult: 'UNSTABLE') {
716+
catchError(buildResult: 'SUCCESS', message: 'Ignore error temporarily', stageResult: 'UNSTABLE') {
717717
makeTarget(context: "Generators Beat Linux", target: "-C generator/_templates/beat test")
718718
makeTarget(context: "Generators Beat Linux", target: "-C generator/_templates/beat test-package")
719719
}
@@ -730,7 +730,7 @@ pipeline {
730730
}
731731
steps {
732732
// FIXME see https://github.com/elastic/beats/issues/18132
733-
catchError(buildResult: 'SUCCESS', message: 'Ignore error temporally', stageResult: 'UNSTABLE') {
733+
catchError(buildResult: 'SUCCESS', message: 'Ignore error temporarily', stageResult: 'UNSTABLE') {
734734
makeTarget(context: "Generators Metricbeat Mac OS X", target: "-C generator/_templates/metricbeat test")
735735
}
736736
}
@@ -751,7 +751,7 @@ pipeline {
751751
}
752752
steps {
753753
// FIXME see https://github.com/elastic/beats/issues/18132
754-
catchError(buildResult: 'SUCCESS', message: 'Ignore error temporally', stageResult: 'UNSTABLE') {
754+
catchError(buildResult: 'SUCCESS', message: 'Ignore error temporarily', stageResult: 'UNSTABLE') {
755755
makeTarget(context: "Generators Beat Mac OS X", target: "-C generator/_templates/beat test")
756756
}
757757
}

NOTICE.txt

+1-2
Original file line numberDiff line numberDiff line change
@@ -7843,8 +7843,7 @@ Apache License 2.0
78437843

78447844
--------------------------------------------------------------------
78457845
Dependency: go.elastic.co/ecszap
7846-
Version: v0.1.1
7847-
Revision: cdd95a104193
7846+
Version: v0.2.0
78487847
License type (autodetected): Apache-2.0
78497848
./vendor/go.elastic.co/ecszap/LICENSE:
78507849
--------------------------------------------------------------------

dev-tools/packaging/templates/docker/Dockerfile.elastic-agent.tmpl

+2-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@
55
FROM {{ .from }}
66

77
# Installing jq needs to be installed after epel-release and cannot be in the same yum install command.
8-
RUN yum -y --setopt=tsflags=nodocs update && \
9-
yum install epel-release -y && \
10-
yum install jq -y && \
11-
yum clean all
8+
RUN for iter in {1..10}; do yum update --setopt=tsflags=nodocs -y && yum install --setopt=tsflags=nodocs -y epel-release && yum clean all && exit_code=0 && break || exit_code=$? && echo "yum error: retry $iter in 10s" && sleep 10; done; (exit $exit_code)
9+
RUN for iter in {1..10}; do yum update -y && yum install -y jq && yum clean all && exit_code=0 && break || exit_code=$? && echo "yum error: retry $iter in 10s" && sleep 10; done; (exit $exit_code)
1210

1311
LABEL \
1412
org.label-schema.build-date="{{ date }}" \

dev-tools/packaging/templates/docker/docker-entrypoint.elastic-agent.tmpl

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
set -eo pipefail
44

55
# Environment variables used
6-
# FLEET_CONFIG_ID - config related to new token [defaul]
76
# FLEET_ENROLLMENT_TOKEN - existing enrollment token to be used for enroll
87
# FLEET_ENROLL - if set to 1 enroll will be performed
98
# FLEET_SETUP - if set to 1 fleet setup will be performed
@@ -49,8 +48,9 @@ function enroll(){
4948
if [ $exitCode -ne 0 ]; then
5049
exit $exitCode
5150
fi
51+
52+
apikey=$(echo $enrollResp | jq -r '.item.api_key')
5253
fi
53-
apikey=$(echo $enrollResp | jq -r '.item.api_key')
5454
echo $apikey
5555

5656
./{{ .BeatName }} enroll ${KIBANA_HOST:-http://localhost:5601} $apikey -f

filebeat/beater/filebeat.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ func New(b *beat.Beat, rawConfig *common.Config) (beat.Beater, error) {
114114
haveEnabledInputs = true
115115
}
116116

117-
if !config.ConfigInput.Enabled() && !config.ConfigModules.Enabled() && !haveEnabledInputs && config.Autodiscover == nil && !b.ConfigManager.Enabled() {
117+
if !config.ConfigInput.Enabled() && !config.ConfigModules.Enabled() && !haveEnabledInputs && config.Autodiscover == nil && !b.Manager.Enabled() {
118118
if !b.InSetupCmd {
119119
return nil, errors.New("no modules or inputs enabled and configuration reloading disabled. What files do you want me to watch?")
120120
}

heartbeat/beater/heartbeat.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func (bt *Heartbeat) Run(b *beat.Beat) error {
8686
return err
8787
}
8888

89-
if b.ConfigManager.Enabled() {
89+
if b.Manager.Enabled() {
9090
bt.RunCentralMgmtMonitors(b)
9191
}
9292

libbeat/beat/beat.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ type Beat struct {
6666

6767
Fields []byte // Data from fields.yml
6868

69-
ConfigManager management.ConfigManager // config manager
69+
Manager management.Manager // manager
7070

7171
Keystore keystore.Keystore
7272
}

libbeat/cmd/instance/beat.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -330,12 +330,12 @@ func (b *Beat) createBeater(bt beat.Creator) (beat.Beater, error) {
330330

331331
// Report central management state
332332
mgmt := monitoring.GetNamespace("state").GetRegistry().NewRegistry("management")
333-
monitoring.NewBool(mgmt, "enabled").Set(b.ConfigManager.Enabled())
333+
monitoring.NewBool(mgmt, "enabled").Set(b.Manager.Enabled())
334334

335335
debugf("Initializing output plugins")
336336
outputEnabled := b.Config.Output.IsSet() && b.Config.Output.Config().Enabled()
337337
if !outputEnabled {
338-
if b.ConfigManager.Enabled() {
338+
if b.Manager.Enabled() {
339339
logp.Info("Output is configured through Central Management")
340340
} else {
341341
msg := "No outputs are defined. Please define one under the output section."
@@ -462,8 +462,8 @@ func (b *Beat) launch(settings Settings, bt beat.Creator) error {
462462
logp.Info("%s start running.", b.Info.Beat)
463463

464464
// Launch config manager
465-
b.ConfigManager.Start(beater.Stop)
466-
defer b.ConfigManager.Stop()
465+
b.Manager.Start(beater.Stop)
466+
defer b.Manager.Stop()
467467

468468
return beater.Run(&b.Beat)
469469
}
@@ -643,12 +643,12 @@ func (b *Beat) configure(settings Settings) error {
643643
logp.Info("Beat ID: %v", b.Info.ID)
644644

645645
// initialize config manager
646-
b.ConfigManager, err = management.Factory(b.Config.Management)(b.Config.Management, reload.Register, b.Beat.Info.ID)
646+
b.Manager, err = management.Factory(b.Config.Management)(b.Config.Management, reload.Register, b.Beat.Info.ID)
647647
if err != nil {
648648
return err
649649
}
650650

651-
if err := b.ConfigManager.CheckRawConfig(b.RawConfig); err != nil {
651+
if err := b.Manager.CheckRawConfig(b.RawConfig); err != nil {
652652
return err
653653
}
654654

libbeat/management/management.go

+69-16
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,36 @@
1818
package management
1919

2020
import (
21+
"sync"
22+
2123
"github.com/gofrs/uuid"
2224

2325
"github.com/elastic/beats/v7/libbeat/common"
2426
"github.com/elastic/beats/v7/libbeat/common/reload"
2527
"github.com/elastic/beats/v7/libbeat/feature"
28+
"github.com/elastic/beats/v7/libbeat/logp"
29+
)
30+
31+
// Status describes the current status of the beat.
32+
type Status int
33+
34+
const (
35+
// Unknown is initial status when none has been reported.
36+
Unknown Status = iota
37+
// Starting is status describing application is starting.
38+
Starting
39+
// Configuring is status describing application is configuring.
40+
Configuring
41+
// Running is status describing application is running.
42+
Running
43+
// Degraded is status describing application is degraded.
44+
Degraded
45+
// Failed is status describing application is failed. This status should
46+
// only be used in the case the beat should stop running as the failure
47+
// cannot be recovered.
48+
Failed
49+
// Stopping is status describing application is stopping.
50+
Stopping
2651
)
2752

2853
// Namespace is the feature namespace for queue definition.
@@ -33,27 +58,36 @@ var DebugK = "centralmgmt"
3358

3459
var centralMgmtKey = "x-pack-cm"
3560

36-
// ConfigManager interacts with the beat to update configurations
37-
// from an external source
38-
type ConfigManager interface {
39-
// Enabled returns true if config manager is enabled
61+
// StatusReporter provides a method to update current status of the beat.
62+
type StatusReporter interface {
63+
// UpdateStatus called when the status of the beat has changed.
64+
UpdateStatus(status Status, msg string)
65+
}
66+
67+
// Manager interacts with the beat to provide status updates and to receive
68+
// configurations.
69+
type Manager interface {
70+
StatusReporter
71+
72+
// Enabled returns true if manager is enabled.
4073
Enabled() bool
4174

42-
// Start the config manager
43-
Start(func())
75+
// Start the config manager giving it a stopFunc callback
76+
// so the beat can be told when to stop.
77+
Start(stopFunc func())
4478

45-
// Stop the config manager
79+
// Stop the config manager.
4680
Stop()
4781

48-
// CheckRawConfig check settings are correct before launching the beat
82+
// CheckRawConfig check settings are correct before launching the beat.
4983
CheckRawConfig(cfg *common.Config) error
5084
}
5185

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

5589
// FactoryFunc for creating a config manager
56-
type FactoryFunc func(*common.Config, *reload.Registry, uuid.UUID) (ConfigManager, error)
90+
type FactoryFunc func(*common.Config, *reload.Registry, uuid.UUID) (Manager, error)
5791

5892
// Register a config manager
5993
func Register(name string, fn PluginFunc, stability feature.Stability) {
@@ -91,13 +125,32 @@ func defaultModeConfig() *modeConfig {
91125
}
92126

93127
// nilManager, fallback when no manager is present
94-
type nilManager struct{}
128+
type nilManager struct {
129+
logger *logp.Logger
130+
lock sync.Mutex
131+
status Status
132+
msg string
133+
}
95134

96-
func nilFactory(*common.Config, *reload.Registry, uuid.UUID) (ConfigManager, error) {
97-
return nilManager{}, nil
135+
func nilFactory(*common.Config, *reload.Registry, uuid.UUID) (Manager, error) {
136+
log := logp.NewLogger("mgmt")
137+
return &nilManager{
138+
logger: log,
139+
status: Unknown,
140+
msg: "",
141+
}, nil
98142
}
99143

100-
func (nilManager) Enabled() bool { return false }
101-
func (nilManager) Start(_ func()) {}
102-
func (nilManager) Stop() {}
103-
func (nilManager) CheckRawConfig(cfg *common.Config) error { return nil }
144+
func (*nilManager) Enabled() bool { return false }
145+
func (*nilManager) Start(_ func()) {}
146+
func (*nilManager) Stop() {}
147+
func (*nilManager) CheckRawConfig(cfg *common.Config) error { return nil }
148+
func (n *nilManager) UpdateStatus(status Status, msg string) {
149+
n.lock.Lock()
150+
defer n.lock.Unlock()
151+
if n.status != status || n.msg != msg {
152+
n.status = status
153+
n.msg = msg
154+
n.logger.Infof("Status change to %s: %s", status, msg)
155+
}
156+
}

metricbeat/autodiscover/builder/hints/metrics.go

+23-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package hints
1919

2020
import (
2121
"fmt"
22+
"strconv"
2223
"strings"
2324

2425
"github.com/elastic/go-ucfg"
@@ -187,7 +188,7 @@ func (m *metricHints) getHostsWithPort(hints common.MapStr, port int) ([]string,
187188
// Only pick hosts that have ${data.port} or the port on current event. This will make
188189
// sure that incorrect meta mapping doesn't happen
189190
for _, h := range thosts {
190-
if strings.Contains(h, "data.port") || strings.Contains(h, fmt.Sprintf(":%d", port)) ||
191+
if strings.Contains(h, "data.port") || m.checkHostPort(h, port) ||
191192
// Use the event that has no port config if there is a ${data.host}:9090 like input
192193
(port == 0 && strings.Contains(h, "data.host")) {
193194
result = append(result, h)
@@ -202,6 +203,27 @@ func (m *metricHints) getHostsWithPort(hints common.MapStr, port int) ([]string,
202203
return result, true
203204
}
204205

206+
func (m *metricHints) checkHostPort(h string, p int) bool {
207+
port := strconv.Itoa(p)
208+
209+
index := strings.LastIndex(h, ":"+port)
210+
// Check if host contains :port. If not then return false
211+
if index == -1 {
212+
return false
213+
}
214+
215+
// Check if the host ends with :port. Return true if yes
216+
end := index + len(port) + 1
217+
if end == len(h) {
218+
return true
219+
}
220+
221+
// Check if the character immediately after :port. If its not a number then return true.
222+
// This is to avoid adding :80 as a valid host for an event that has port=8080
223+
// Also ensure that port=3306 and hint="tcp(${data.host}:3306)/" is valid
224+
return h[end] < '0' || h[end] > '9'
225+
}
226+
205227
func (m *metricHints) getNamespace(hints common.MapStr) string {
206228
return builder.GetHintString(hints, m.Key, namespace)
207229
}

0 commit comments

Comments
 (0)