Skip to content

Commit 358b2de

Browse files
authored
Merge branch '9.1' into mergify/bp/9.1/pr-45093
2 parents 5c62121 + f4c5435 commit 358b2de

File tree

29 files changed

+636
-122
lines changed

29 files changed

+636
-122
lines changed

.buildkite/libbeat/pipeline.libbeat.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ env:
99
GCP_HI_PERF_MACHINE_TYPE: "c2d-highcpu-16"
1010
IMAGE_UBUNTU_X86_64: "family/platform-ingest-beats-ubuntu-2204"
1111
IMAGE_WIN_2022: "family/platform-ingest-beats-windows-2022"
12+
IMAGE_UBUNTU_X86_64_FIPS: "platform-ingest-beats-ubuntu-2204-fips"
1213

1314
IMAGE_BEATS_WITH_HOOKS_LATEST: "docker.elastic.co/ci-agent-images/platform-ingest/buildkite-agent-beats-ci-with-hooks:latest"
1415

@@ -88,21 +89,22 @@ steps:
8889
- github_commit_status:
8990
context: "libbeat: Ubuntu x86_64 Unit Tests"
9091

91-
- label: ":ubuntu: Libbeat: Ubuntu x86_64 Unit Tests with requirefips build tag"
92+
- label: ":ubuntu: Libbeat: Ubuntu x86_64 Go Unit Tests with fips provider and requirefips build tag"
9293
key: "mandatory-linux-unit-test-fips-tag"
9394
command: |
94-
set -euo pipefail
9595
cd libbeat
96-
mage unitTest
96+
mage goUnitTest
9797
retry:
9898
automatic:
9999
- limit: 1
100100
agents:
101-
provider: "gcp"
102-
image: "${IMAGE_UBUNTU_X86_64}"
103-
machineType: "${GCP_DEFAULT_MACHINE_TYPE}"
101+
provider: "aws"
102+
imagePrefix: "${IMAGE_UBUNTU_X86_64_FIPS}"
103+
instanceType: "m5.xlarge"
104104
env:
105105
FIPS: "true"
106+
GOEXPERIMENT: "systemcrypto"
107+
ASDF_PYTHON_VERSION: "3.9.13"
106108
artifact_paths:
107109
- "libbeat/build/*.xml"
108110
- "libbeat/build/*.json"
@@ -114,7 +116,7 @@ steps:
114116
debug: true
115117
notify:
116118
- github_commit_status:
117-
context: "libbeat: Ubuntu x86_64 Unit Tests with requirefips build tag"
119+
context: "libbeat: Ubuntu x86_64 Go Unit Tests with fips provider and requirefips build tag"
118120

119121
- label: ":ubuntu: Libbeat: Ubuntu x86_64 fips140=only Unit Tests"
120122
key: "mandatory-linux-unit-test-fips-only"

CHANGELOG.next.asciidoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,8 @@ otherwise no tag is added. {issue}42208[42208] {pull}42403[42403]
474474
- Add support for relationship expansion to EntraID entity analytics provider. {issue}43324[43324] {pull}44761[44761]
475475
- Update CEL mito extensions to v1.21.0. {issue}40762[40762] {pull}45107[45107]
476476
- Update CEL mito extensions to v1.22.0. {pull}45245[45245]
477+
- Allow empty HTTPJSON cursor template value evaluations to be ignored by Fleet health status updates. {pull}45361[45361]
478+
- Add support for generalized token authentication to CEL input. {pull}45359[45359]
477479

478480
*Auditbeat*
479481

docs/extend/contributing-docs.md

Lines changed: 17 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,16 @@
22
mapped_pages:
33
- https://www.elastic.co/guide/en/beats/devguide/current/contributing-docs.html
44
applies_to:
5-
stack: discontinued 8.18
5+
stack: ga 9.0
66
---
77

8-
# Contributing to the docs [contributing-docs]
9-
10-
The Beats documentation follows the tagging guidelines described in the [Docs HOWTO](https://github.com/elastic/docs/blob/master/README.asciidoc). However it extends these capabilities in a couple ways:
11-
12-
* The documentation makes extensive use of [AsciiDoc conditionals](https://docs.asciidoctor.org/asciidoc/latest/directives/conditionals/) to provide content that is reused across multiple books. This means that there might not be a single source file for each published HTML page. Some files are shared across multiple books, either as complete pages or snippets. For more details, refer to [Where to find the Beats docs source](#where-to-find-files).
13-
* The documentation includes some files that are generated from YAML source or pieced together from content that lives in `_meta` directories under the code (for example, the module and exported fields documentation). For more details, refer to [Generated docs](#generated-docs).
14-
15-
16-
## Where to find the Beats docs source [where-to-find-files]
17-
18-
Because the Beats documentation makes use of shared content, doc generation scripts, and componentization, the source files are located in several places:
19-
20-
| Documentation | Location of source files |
21-
| --- | --- |
22-
| Main docs for the Beat, including index files | `<beatname>/docs` |
23-
| Shared docs and Beats Platform Reference | `libbeat/docs` |
24-
| Processor docs | `docs` folders under processors in `libbeat/processors/`,`x-pack/<beatname>/processors/`, and `x-pack/libbeat/processors/` |
25-
| Output docs | `docs` folders under outputs in `libbeat/outputs/` |
26-
| Module docs | `_meta` folders under modules and datasets in `libbeat/module/`,`<beatname>/module/`, and `x-pack/<beatname>/module/` |
27-
28-
The [conf.yaml](https://github.com/elastic/docs/blob/master/conf.yaml) file in the `docs` repo shows all the resources used to build each book. This file is used to drive the classic docs build and is the source of truth for file locations.
29-
30-
::::{tip}
31-
If you can’t find the source for a page you want to update, go to the published page at www.elastic.co and click the Edit link to navigate to the source.
32-
::::
33-
34-
35-
The Beats documentation build also has dependencies on the following files in the [docs](https://github.com/elastic/docs) repo:
36-
37-
* `shared/versions/stack/<version>.asciidoc`
38-
* `shared/attributes.asciidoc`
8+
# Contributing to the docs
399

10+
The Beats documentation is written in Markdown and is built using [elastic/docs-builder](https://github.com/elastic/docs-builder). Most Markdown files should be edited directly, but some Markdown files are generated.
4011

4112
## Generated docs [generated-docs]
4213

43-
After updating `docs.asciidoc` files in `_meta` directories, you must run the doc collector scripts to regenerate the docs.
14+
After updating `docs.md` files in `_meta` directories, you must run the doc collector scripts to regenerate the docs.
4415

4516
Make sure you [set up your Beats development environment](./index.md#setting-up-dev-environment) and use the correct Go version. The Go version is listed in the `version.asciidoc` file for the branch you want to update.
4617

@@ -52,7 +23,6 @@ To run the docs collector scripts, change to the beats directory and run:
5223
The `make update` command overwrites files in the `docs` directories **without warning**. If you accidentally update a generated file and run `make update`, your changes will be overwritten.
5324
::::
5425

55-
5626
To format your files, you might also need to run this command:
5727

5828
`make fmt`
@@ -61,24 +31,24 @@ The make command calls the following scripts to generate the docs:
6131

6232
[auditbeat/scripts/docs_collector.py](https://github.com/elastic/beats/blob/main/auditbeat/scripts/docs_collector.py) generates:
6333

64-
* `auditbeat/docs/modules_list.asciidoc`
65-
* `auditbeat/docs/modules/*.asciidoc`
34+
* `docs/reference/auditbeat/auditbeat-modules.md`
35+
* `docs/reference/auditbeat/auditbeat-module-*.md`
6636

6737
[filebeat/scripts/docs_collector.py](https://github.com/elastic/beats/blob/main/filebeat/scripts/docs_collector.py) generates:
6838

69-
* `filebeat/docs/modules_list.asciidoc`
70-
* `filebeat/docs/modules/*.asciidoc`
39+
* `docs/reference/filebeat/filebeat-modules.md`
40+
* `docs/reference/filebeat/filebeat-module-*.md`
7141

7242
[metricbeat/scripts/mage/docs_collector.go](https://github.com/elastic/beats/blob/main/metricbeat/scripts/mage/docs_collector.go) generates:
7343

74-
* `metricbeat/docs/modules_list.asciidoc`
75-
* `metricbeat/docs/modules/*.asciidoc`
44+
* `docs/reference/metricbeat/metricbeat-modules.md`
45+
* `docs/reference/metricbeat/metricbeat-module-*.md`
7646

77-
[libbeat/scripts/generate_fields_docs.py](https://github.com/elastic/beats/blob/main/libbeat/scripts/generate_fields_docs.py) generates
47+
[libbeat/scripts/generate_fields_docs.py](https://github.com/elastic/beats/blob/main/libbeat/scripts/generate_fields_docs.py) generates:
7848

79-
* `auditbeat/docs/fields.asciidoc`
80-
* `filebeat/docs/fields.asciidoc`
81-
* `heartbeat/docs/fields.asciidoc`
82-
* `metricbeat/docs/fields.asciidoc`
83-
* `packetbeat/docs/fields.asciidoc`
84-
* `winlogbeat/docs/fields.asciidoc`
49+
* `docs/reference/auditbeat/exported-fields.md`
50+
* `docs/reference/filebeat/exported-fields.md`
51+
* `docs/reference/heartbeat/exported-fields.md`
52+
* `docs/reference/metricbeat/exported-fields.md`
53+
* `docs/reference/packetbeat/exported-fields.md`
54+
* `docs/reference/winlogbeat/exported-fields.md`

docs/reference/filebeat/filebeat-input-cel.md

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ Host environment variables are made available via the global map `env`. Only env
250250

251251
The CEL environment enables the [optional types](https://pkg.go.dev/github.com/google/cel-go/cel#OptionalTypes) library using the version defined [here](https://pkg.go.dev/github.com/elastic/mito@v1.22.0/lib#OptionalTypesVersion) and the [two-variable comprehensions extensions](https://pkg.go.dev/github.com/google/cel-go/ext#TwoVarComprehensions) library using the version defined [here](https://pkg.go.dev/github.com/elastic/mito@v1.22.0/lib#TwoVarComprehensionVersion).
252252

253-
Additionally, it supports authentication via Basic Authentication, Digest Authentication or OAuth2.
253+
Additionally, it supports authentication via Basic Authentication, Digest Authentication or OAuth2, or token authentication.
254254

255255
Example configurations with authentication:
256256

@@ -294,6 +294,23 @@ filebeat.inputs:
294294
resource.url: http://localhost
295295
```
296296

297+
```yaml
298+
filebeat.inputs:
299+
- type: cel
300+
auth.token:
301+
type: Bearer
302+
value: supersecret_bearer_token
303+
resource.url: http://localhost
304+
```
305+
306+
```yaml
307+
filebeat.inputs:
308+
- type: cel
309+
auth.token:
310+
type: Token
311+
value: supersecret_token
312+
resource.url: http://localhost
313+
```
297314

298315
## Input state [input-state-cel]
299316

@@ -617,6 +634,27 @@ Only one of the credentials settings can be set at once. For more information pl
617634

618635

619636

637+
### `auth.token.enabled` [_auth_token_enabled]
638+
639+
When set to `false`, disables the token authentication configuration. Default: `true`.
640+
641+
::::{note}
642+
Token authentication settings are disabled if either `enabled` is set to `false` or the `auth.token` section is missing.
643+
::::
644+
645+
646+
647+
### `auth.token.type` [_auth_token_type]
648+
649+
The type of token to authenticate with, for example "Token" or "Bearer".
650+
651+
652+
### `auth.token.value` [_auth_token_value]
653+
654+
The token value to use.
655+
656+
657+
620658
### `resource.url` [resource-parameters]
621659

622660
The URL of the HTTP API. Required.

libbeat/api/server.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"net/http"
2424
"net/url"
2525
"strconv"
26+
"sync"
2627

2728
"github.com/gorilla/mux"
2829

@@ -37,6 +38,7 @@ type Server struct {
3738
mux *mux.Router
3839
l net.Listener
3940
config Config
41+
wg sync.WaitGroup
4042
}
4143

4244
// New creates a new API Server with no routes attached.
@@ -63,16 +65,23 @@ func New(log *logp.Logger, config *config.C) (*Server, error) {
6365
// Start starts the HTTP server and accepting new connection.
6466
func (s *Server) Start() {
6567
s.log.Info("Starting stats endpoint")
68+
s.wg.Add(1)
6669
go func(l net.Listener) {
70+
defer s.wg.Done()
6771
s.log.Infof("Metrics endpoint listening on: %s (configured: %s)", l.Addr().String(), s.config.Host)
68-
err := http.Serve(l, s.mux)
72+
err := http.Serve(l, s.mux) //nolint:gosec // Keep original behavior
6973
s.log.Infof("Stats endpoint (%s) finished: %v", l.Addr().String(), err)
7074
}(s.l)
7175
}
7276

7377
// Stop stops the API server and free any resource associated with the process like unix sockets.
7478
func (s *Server) Stop() error {
75-
return s.l.Close()
79+
err := s.l.Close()
80+
if err != nil {
81+
return fmt.Errorf("error stopping monitoring server: %w", err)
82+
}
83+
s.wg.Wait()
84+
return nil
7685
}
7786

7887
// AttachHandler will attach a handler at the specified route. Routes are

libbeat/esleg/eslegclient/bulkapi.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,12 @@ type bulkRequest struct {
6363
type BulkResponse json.RawMessage
6464

6565
// Bulk performs many index/delete operations in a single API call.
66+
// `header` is an additional set of custom HTTP headers that will be set to the HTTP request
6667
// Implements: http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html
6768
func (conn *Connection) Bulk(
6869
ctx context.Context,
6970
index, docType string,
71+
header http.Header,
7072
params map[string]string, body []interface{},
7173
) (int, BulkResponse, error) {
7274
if len(body) == 0 {
@@ -80,14 +82,18 @@ func (conn *Connection) Bulk(
8082
return 0, nil, err
8183
}
8284

83-
mergedParams := mergeParams(conn.ConnectionSettings.Parameters, params)
85+
mergedParams := mergeParams(conn.Parameters, params)
8486

8587
requ, err := newBulkRequest(conn.URL, index, docType, mergedParams, enc)
8688
if err != nil {
8789
apm.CaptureError(ctx, err).Send()
8890
return 0, nil, err
8991
}
9092
requ.requ = apmHttpV2.RequestWithContext(ctx, requ.requ)
93+
// multiple values per header are not supported
94+
for name := range header {
95+
requ.requ.Header.Set(name, header.Get(name))
96+
}
9197

9298
return conn.sendBulkRequest(requ)
9399
}

libbeat/esleg/eslegclient/bulkapi_integration_test.go

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,9 @@ import (
2424
"fmt"
2525
"os"
2626
"testing"
27-
28-
"github.com/elastic/elastic-agent-libs/logp"
2927
)
3028

3129
func TestBulk(t *testing.T) {
32-
logp.TestingSetup(logp.WithSelectors("elasticsearch"))
33-
3430
client := getTestingElasticsearch(t)
3531
index := fmt.Sprintf("packetbeat-unittest-%d", os.Getpid())
3632

@@ -54,7 +50,7 @@ func TestBulk(t *testing.T) {
5450
params := map[string]string{
5551
"refresh": "true",
5652
}
57-
_, _, err := client.Bulk(context.Background(), index, "", params, body)
53+
_, _, err := client.Bulk(context.Background(), index, "", nil, params, body)
5854
if err != nil {
5955
t.Fatalf("Bulk() returned error: %s", err)
6056
}
@@ -77,8 +73,6 @@ func TestBulk(t *testing.T) {
7773
}
7874

7975
func TestEmptyBulk(t *testing.T) {
80-
logp.TestingSetup(logp.WithSelectors("elasticsearch"))
81-
8276
client := getTestingElasticsearch(t)
8377
index := fmt.Sprintf("packetbeat-unittest-%d", os.Getpid())
8478

@@ -87,7 +81,7 @@ func TestEmptyBulk(t *testing.T) {
8781
params := map[string]string{
8882
"refresh": "true",
8983
}
90-
_, resp, err := client.Bulk(context.Background(), index, "", params, body)
84+
_, resp, err := client.Bulk(context.Background(), index, "", nil, params, body)
9185
if err != nil {
9286
t.Fatalf("Bulk() returned error: %s", err)
9387
}
@@ -97,8 +91,6 @@ func TestEmptyBulk(t *testing.T) {
9791
}
9892

9993
func TestBulkMoreOperations(t *testing.T) {
100-
logp.TestingSetup(logp.WithSelectors("elasticsearch"))
101-
10294
client := getTestingElasticsearch(t)
10395
index := fmt.Sprintf("packetbeat-unittest-%d", os.Getpid())
10496

@@ -151,7 +143,7 @@ func TestBulkMoreOperations(t *testing.T) {
151143
params := map[string]string{
152144
"refresh": "true",
153145
}
154-
_, resp, err := client.Bulk(context.Background(), index, "", params, body)
146+
_, resp, err := client.Bulk(context.Background(), index, "", nil, params, body)
155147
if err != nil {
156148
t.Fatalf("Bulk() returned error: %s [%s]", err, resp)
157149
}

0 commit comments

Comments
 (0)