Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy client.ip to source.ip #2771

Merged
merged 3 commits into from Oct 8, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 12 additions & 3 deletions _meta/fields.common.yml
Expand Up @@ -524,13 +524,22 @@
dynamic: false
type: group
fields:
- name: ip
type: ip
description: >
IP address of the client of a recorded event.
This is typically obtained from a request's X-Forwarded-For or the X-Real-IP header or falls back to a given configuration for remote address.
overwrite: true

- name: source
dynamic: false
type: group
fields:
- name: ip
type: ip
description: >
IP of the user where the event is recorded, typically a web browser.
This is obtained from the X-Forwarded-For header, of which the first entry is the IP of the original client.
This value however might not be necessarily trusted, as it can be forged by a malicious user.
IP address of the source of a recorded event.
This is typically obtained from a request's X-Forwarded-For or the X-Real-IP header or falls back to a given configuration for remote address.
overwrite: true

- name: user_agent
Expand Down
Expand Up @@ -307,6 +307,9 @@
},
"version": "5.1.3"
},
"source": {
"ip": "12.53.12.1"
},
"timestamp": {
"us": 1494342245999999
},
Expand Down
Expand Up @@ -253,6 +253,9 @@
},
"version": "5.1.3"
},
"source": {
"ip": "12.53.12.1"
},
"timestamp": {
"us": 1496170407154000
},
Expand Down
1 change: 1 addition & 0 deletions changelogs/head.asciidoc
Expand Up @@ -4,5 +4,6 @@
[float]
==== Added
- Add `service.node.configured_name` to Intake API and transform to `service.node.name` for ES output {pull}2746[2746].
- Index value from `client.ip` in `source.ip`for SIEM integration {pull}2771[2771].
simitt marked this conversation as resolved.
Show resolved Hide resolved

https://github.com/elastic/apm-server/compare/7.4\...master[View commits]
3 changes: 3 additions & 0 deletions docs/data/elasticsearch/generated/errors.json
Expand Up @@ -290,6 +290,9 @@
},
"version": "5.1.3"
},
"source": {
"ip": "12.53.12.1"
},
"timestamp": {
"us": 1494342245999999
},
Expand Down
3 changes: 3 additions & 0 deletions docs/data/elasticsearch/generated/transactions.json
Expand Up @@ -219,6 +219,9 @@
},
"version": "5.1.3"
},
"source": {
"ip": "12.53.12.1"
},
"timestamp": {
"us": 1496170407154000
},
Expand Down
13 changes: 12 additions & 1 deletion docs/fields.asciidoc
Expand Up @@ -793,7 +793,18 @@ type: keyword
*`client.ip`*::
+
--
IP of the user where the event is recorded, typically a web browser. This is obtained from the X-Forwarded-For header, of which the first entry is the IP of the original client. This value however might not be necessarily trusted, as it can be forged by a malicious user.
IP address of the client of a recorded event. This is typically obtained from a request's X-Forwarded-For or the X-Real-IP header or falls back to a given configuration for remote address.


type: ip

--


*`source.ip`*::
+
--
IP address of the source of a recorded event. This is typically obtained from a request's X-Forwarded-For or the X-Real-IP header or falls back to a given configuration for remote address.


type: ip
Expand Down
2 changes: 1 addition & 1 deletion include/fields.go

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion model/error/event.go
Expand Up @@ -194,7 +194,9 @@ func (e *Event) Transform(tctx *transform.Context) []beat.Event {
tctx.Metadata.Set(fields)
// then add event specific information
utility.Update(fields, "user", e.User.Fields())
utility.DeepUpdate(fields, "client", e.Http.ClientFields(e.User.ClientFields()))
clientIP := e.Http.ClientFields(e.User.ClientFields())
utility.DeepUpdate(fields, "client", clientIP)
utility.DeepUpdate(fields, "source", clientIP)
utility.DeepUpdate(fields, "user_agent", e.User.UserAgentFields())
utility.DeepUpdate(fields, "service", e.Service.Fields(emptyString, emptyString))
utility.DeepUpdate(fields, "agent", e.Service.AgentFields())
Expand Down
1 change: 1 addition & 0 deletions model/error/event_test.go
Expand Up @@ -651,6 +651,7 @@ func TestEvents(t *testing.T) {
"agent": common.MapStr{"name": "go", "version": "1.0"},
"user": common.MapStr{"email": email},
"client": common.MapStr{"ip": userIp},
"source": common.MapStr{"ip": userIp},
"user_agent": common.MapStr{"original": userAgent},
"error": common.MapStr{
"custom": common.MapStr{
Expand Down
4 changes: 3 additions & 1 deletion model/transaction/event.go
Expand Up @@ -182,7 +182,9 @@ func (e *Event) Transform(tctx *transform.Context) []beat.Event {

// then merge event specific information
utility.Update(fields, "user", e.User.Fields())
utility.DeepUpdate(fields, "client", e.Http.ClientFields(e.User.ClientFields()))
clientIP := e.Http.ClientFields(e.User.ClientFields())
utility.DeepUpdate(fields, "client", clientIP)
utility.DeepUpdate(fields, "source", clientIP)
utility.DeepUpdate(fields, "user_agent", e.User.UserAgentFields())
utility.DeepUpdate(fields, "service", e.Service.Fields(emptyString, emptyString))
utility.DeepUpdate(fields, "agent", e.Service.AgentFields())
Expand Down
1 change: 1 addition & 0 deletions model/transaction/event_test.go
Expand Up @@ -370,6 +370,7 @@ func TestEventsTransformWithMetadata(t *testing.T) {
txWithContextEs := common.MapStr{
"user": common.MapStr{"id": "123", "name": "jane"},
"client": common.MapStr{"ip": "63.23.123.4"},
"source": common.MapStr{"ip": "63.23.123.4"},
"user_agent": common.MapStr{"original": userAgent},
"host": common.MapStr{
"architecture": "darwin",
Expand Down
2 changes: 1 addition & 1 deletion processor/stream/package_tests/error_attrs_test.go
Expand Up @@ -55,7 +55,7 @@ func errorPayloadAttrsNotInFields() *tests.Set {
func errorFieldsNotInPayloadAttrs() *tests.Set {
return tests.NewSet(
"view errors", "error id icon",
"host.ip", "transaction.name",
"host.ip", "transaction.name", "source.ip",
tests.Group("observer"),
tests.Group("user"),
tests.Group("client"),
Expand Down
1 change: 1 addition & 0 deletions processor/stream/package_tests/span_attrs_test.go
Expand Up @@ -64,6 +64,7 @@ func spanFieldsNotInPayloadAttrs() *tests.Set {
tests.Group("service"),
tests.Group("user"),
tests.Group("client"),
tests.Group("source"),
tests.Group("http"),
tests.Group("url"),
tests.Group("span.self_time"),
Expand Down
1 change: 1 addition & 0 deletions processor/stream/package_tests/transaction_attrs_test.go
Expand Up @@ -56,6 +56,7 @@ func transactionFieldsNotInPayloadAttrs() *tests.Set {
"host.ip",
"transaction.duration.count",
"transaction.marks.*.*",
"source.ip",
tests.Group("observer"),
tests.Group("user"),
tests.Group("client"),
Expand Down
Expand Up @@ -290,6 +290,9 @@
},
"version": "5.1.3"
},
"source": {
"ip": "12.53.12.1"
},
"timestamp": {
"us": 1494342245999999
},
Expand Down
Expand Up @@ -219,6 +219,9 @@
},
"version": "5.1.3"
},
"source": {
"ip": "12.53.12.1"
},
"timestamp": {
"us": 1496170407154000
},
Expand Down
3 changes: 3 additions & 0 deletions tests/system/error.approved.json
Expand Up @@ -210,6 +210,9 @@
"region_name": "Indiana"
}
},
"source": {
"ip": "12.53.12.1"
},
"url": {
"domain": "www.example.com",
"fragment": "#hash",
Expand Down
3 changes: 3 additions & 0 deletions tests/system/transaction.approved.json
Expand Up @@ -149,6 +149,9 @@
"region_name": "Indiana"
}
},
"source": {
"ip": "12.53.12.1"
},
"labels": {
"number_code": 2,
"bool_error": false,
Expand Down