Skip to content

Commit 88f341b

Browse files
authored
Merge branch 'master' into systemtest-migrate-profiling
2 parents 1ca38f5 + 750ea89 commit 88f341b

File tree

146 files changed

+4756
-4303
lines changed

Some content is hidden

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

146 files changed

+4756
-4303
lines changed

.go-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.14.7
1+
1.14.12

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.14.7
1+
FROM golang:1.14.12
22
MAINTAINER Nicolas Ruflin <ruflin@elastic.co>
33

44
RUN set -x && \

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ To get started with APM please see our [Getting Started Guide](https://www.elast
1717

1818
### Requirements
1919

20-
* [Golang](https://golang.org/dl/) 1.14.7
20+
* [Golang](https://golang.org/dl/) 1.14.12
2121

2222
### Install
2323

_meta/beat.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ apm-server:
2727
# Maximum number of new connections to accept simultaneously (0 means unlimited).
2828
#max_connections: 0
2929

30+
# Custom HTTP headers to add to all HTTP responses, e.g. for security policy compliance.
31+
#response_headers:
32+
# X-My-Header: Contents of the header
33+
3034
# If true (default), APM Server captures the IP of the instrumented service
3135
# or the IP and User Agent of the real user (RUM requests).
3236
#capture_personal_data: true

apm-server.docker.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ apm-server:
2727
# Maximum number of new connections to accept simultaneously (0 means unlimited).
2828
#max_connections: 0
2929

30+
# Custom HTTP headers to add to all HTTP responses, e.g. for security policy compliance.
31+
#response_headers:
32+
# X-My-Header: Contents of the header
33+
3034
# If true (default), APM Server captures the IP of the instrumented service
3135
# or the IP and User Agent of the real user (RUM requests).
3236
#capture_personal_data: true

apm-server.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ apm-server:
2727
# Maximum number of new connections to accept simultaneously (0 means unlimited).
2828
#max_connections: 0
2929

30+
# Custom HTTP headers to add to all HTTP responses, e.g. for security policy compliance.
31+
#response_headers:
32+
# X-My-Header: Contents of the header
33+
3034
# If true (default), APM Server captures the IP of the instrumented service
3135
# or the IP and User Agent of the real user (RUM requests).
3236
#capture_personal_data: true

apmpackage/README.md

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
## Developer documentation
2+
3+
### ~Requirements
4+
5+
- Checkout `elastic/package-registry`, `elastic/package-storage` and `elastic/beats`
6+
- Have `elastic/package-spec` at hand
7+
8+
### Guide
9+
10+
#### Update / fix a package
11+
12+
1. Actual work
13+
- Make changes in `apmpackage/apm/<version>`, `apmpackage/docs/README.template.md` and/or code as needed
14+
- Run `make update`. That will update fields, pipeline and doc files based on apm-server fields and pipeline defs.
15+
16+
2. Run the registry
17+
- Checkout a fresh master from the registry and run `mage build`
18+
- Copy `apmpackage/apm` in apm-server to `build/package-storage/packages` in the registry
19+
- `go run .`
20+
21+
3. Run the stack
22+
- Update Kibana settings with `xpack.fleet.registryUrl: http://localhost:8080`
23+
- Start Kibana and Elasticsearch with X-Pack enabled. One way to do it is with a local Kibana:
24+
- `yarn es snapshot --license trial --ssl -E xpack.security.authc.api_key.enabled=true`
25+
- `yarn start --ssl`
26+
27+
4. Test
28+
- Go to the Fleet UI, install the integration and test what you need. You generally will want to have a look at the
29+
installed assets (ie. templates and pipelines), and the generated `apm` input in the policy.
30+
- If you need to change the package, you *must* remove the installed integration first. You can use the UI
31+
or the API, eg: `curl -X DELETE -k -u elastic:changeme https://localhost:5601/abc/api/fleet/epm/packages/apm-0.1.0 -H 'kbn-xsrf: xyz'`
32+
See [API docs](https://github.com/elastic/kibana/tree/master/x-pack/plugins/fleet/dev_docs/api) for details.
33+
You normally don't need to restart the registry (an exception to this is eg. if you change a `hbs` template file).
34+
35+
5. Upload to the snapshot registry
36+
- When everything works and `apmpackage/apm/` changes have been merged to `master`, copy the new package to
37+
`package-storage/packages` in the `package-storage` repo, `snapshot` branch.
38+
Do *NOT* override any existing packages. Instead, bump the qualifier version. Eg: rename `apm/0.1.0-dev.1` to `apm/0.1.0-dev.2`
39+
- Bump the qualifier in the contents too: `find . -type f -print0 | xargs -0 sed -i "" "s/0.1.0-dev.1/0.1.0-dev.2/g"`
40+
This step can be done in a separate commit to facilitate review.
41+
42+
43+
#### Create a new package version
44+
45+
Follow steps described above, except:
46+
47+
1. New local version
48+
- Copy `apmpackage/apm/<latest-version>` to `apmpackage/apm/<next-version>`.
49+
- Add a new version mapping in the `versionMapping` variable at the top of `apmpackage/cmd/gen-package/main.go`.
50+
Most likely this won't be needed in the future.
51+
- Then do any changes in the new folder. The rest of the steps are the same.
52+
53+
2. First dev version
54+
- When copying to the `package-storage`, create the first version qualifier instead of bumping the last one.
55+
Eg: `apm/0.2.0` -> `apm/0.2.0-dev.1`
56+
57+
58+
#### Run the Elastic Agent
59+
60+
If you do code changes or a whole new version, you need to run the Elastic Agent locally.
61+
Most of the work here is done in `beats/x-pack/elastic-agent`
62+
63+
0. Optional: Update the spec
64+
65+
The spec informs whether the Elastic Agent should or should not start apm-server based on the policy file,
66+
and what settings to pass via GRPC call.
67+
- Edit `spec/apm-server.yml`
68+
- `mage update`
69+
70+
1. Build / Package
71+
72+
*First time*
73+
- `DEV=true PLATFORMS=darwin mage package` (replace platform as needed)
74+
- Untar `build/distributions` contents
75+
76+
*Every time after*
77+
- `DEV=true mage build`
78+
- Copy `build/elastic-agent` to `build/distributions/elastic-agent-<version>-<platform>/data/elastic-agent-<hash>/`
79+
80+
2. Override policy / apm-server
81+
- Use the right `elastic-agent.yml` policy
82+
83+
It might be one you just generated with the UI, or one you have at hand with an apm input.
84+
Copy to `build/distributions/elastic-agent-<version>-<platform>/elastic-agent.yml`
85+
86+
- Override apm-server in `install` and `downloads` folders. Approximately:
87+
```
88+
# compile apm-server
89+
cd ~/<path>/apm-server
90+
make && make update
91+
92+
# tar and compress
93+
cp build/fields/fields.yml .
94+
tar cvf apm-server-<stack-version>-<platform>.tar apm-server LICENSE.txt NOTICE.txt README.md apm-server.yml ingest fields.yml
95+
gzip apm-server-<stack-version>-<platform>.tar
96+
sha512sum apm-server-<stack-version>-<platform>.tar.gz | tee apm-server-<stack-version>-<platform>.tar.gz.sha512
97+
98+
# delete old stuff
99+
cd ~/<path>/beats/x-pack/elastic-agent/build/distributions/elastic-agent-<version>-<platform>/data/elastic-agent-<hash>/downloads
100+
rm apm*
101+
rm -rf ../install/apm*
102+
103+
# copy new files
104+
mv <path>/apm-server-<stack-version>-<platform>.tar* .
105+
mkdir -p ../install/apm-server-<stack-version>-<platform>
106+
tar zxvf apm-server-<stack-version>-<platform> -C ../install/apm-server-<stack-version>-<platform>
107+
```
108+
3. Run the Elastic Agent
109+
- `./build/distributions/<blablabla>/elastic-agent -e`
110+
- Check apm-server logs at `build/distributions/<blablabla>/data/<blablabla>/logs/default`
111+
112+
(The last default in the path comes from the namespace in the policy)
113+
114+
#### Promote a package
115+
116+
Generally it should be done between FF and release.
117+
1. Remove the qualifier version from the package
118+
2. Push to the corresponding production branch(es)
119+
120+
121+
### Caveats
122+
123+
Fleet is under active development and this guide might become obsolete quickly.
124+
125+
Take everything with a grain of salt.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"description": "Add an ingest timestamp for APM events",
3+
"processors": [
4+
{
5+
"set": {
6+
"field": "event.ingested",
7+
"if": "ctx.processor?.event != 'span'",
8+
"value": "{{_ingest.timestamp}}"
9+
}
10+
}
11+
]
12+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"description": "Removes metadata fields available already on the parent transaction, to save storage",
3+
"processors": [
4+
{
5+
"remove": {
6+
"field": [
7+
"host",
8+
"process",
9+
"user",
10+
"user_agent",
11+
"container",
12+
"kubernetes",
13+
"service.node",
14+
"service.version",
15+
"service.language",
16+
"service.runtime",
17+
"service.framework"
18+
],
19+
"if": "ctx.processor?.event == 'span'",
20+
"ignore_failure": true,
21+
"ignore_missing": true
22+
}
23+
}
24+
]
25+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"description": "Add user agent information for APM events",
3+
"processors": [
4+
{
5+
"user_agent": {
6+
"field": "user_agent.original",
7+
"ignore_failure": true,
8+
"ignore_missing": true,
9+
"target_field": "user_agent"
10+
}
11+
}
12+
]
13+
}

0 commit comments

Comments
 (0)