Skip to content

Commit f4ad774

Browse files
committed
add ecs-migration.yml
1 parent a843f56 commit f4ad774

File tree

5 files changed

+135
-39
lines changed

5 files changed

+135
-39
lines changed

_meta/ecs-migration.yml

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# The ECS migration file contains the information about all the fields which are migrated to ECS in 7.0.
2+
# The goal of the file is to potentially have scripts on top of this information to convert visualisations and templates
3+
# based on this information in an automated way and to keep track of all changes which were applied.
4+
#
5+
# The format of the file is as following:
6+
#
7+
# - from: source-field-in-6.x
8+
# to: target-filed-in-ECS
9+
# # Alias field is useful for fields where there is a 1-1 mapping from old to new
10+
# alias: true-if-alias-is-required-in-6x (default is true)
11+
# # Copy to is useful for fields where multiple fields map to the same ECS field
12+
# copy_to: true-if-field-should-be-copied-to-target-in-6x (default is false)
13+
14+
- from: context.service.agent.name
15+
to: agent.name
16+
17+
- from: context.service.agent.version
18+
to: agent.version
19+
20+
- from: context.system.architecture
21+
to: host.architecture
22+
23+
- from: context.system.ip
24+
to: host.ip
25+
26+
- from: context.system.hostname
27+
to: host.name
28+
29+
- from: context.system.platform
30+
to: host.os.platform
31+
32+
- from: context.request.method
33+
to: http.method
34+
35+
- from: context.request.http_version
36+
to: http.version
37+
38+
- from: context.tags
39+
to: labels
40+
alias: false
41+
copy_to: true
42+
43+
- from: context.process.pid
44+
to: process.pid
45+
46+
- from: context.process.ppid
47+
to: process.ppid
48+
49+
- from: context.process.title
50+
to: process.title
51+
52+
# not in ECS
53+
- from: context.service.environment
54+
to: service.environment
55+
56+
# not in ECS
57+
- from: context.service.framework.name
58+
to: service.framework.name
59+
60+
# not in ECS
61+
- from: context.service.framework.version
62+
to: service.framework.version
63+
64+
# not in ECS
65+
- from: context.service.language.name
66+
to: service.language.name
67+
68+
# not in ECS
69+
- from: context.service.language.version
70+
to: service.language.version
71+
72+
- from: context.service.name
73+
to: service.name
74+
75+
# not in ECS
76+
- from: context.service.runtime.name
77+
to: service.runtime.name
78+
79+
# not in ECS
80+
- from: context.service.runtime.version
81+
to: service.runtime.version
82+
83+
- from: context.request.url.full
84+
to: url.original
85+
86+
- from: context.request.url.hash
87+
to: url.fragment
88+
89+
- from: context.request.url.hostname
90+
to: url.domain
91+
92+
- from: context.request.url.pathname
93+
to: url.path
94+
95+
- from: context.request.url.port
96+
to: url.port
97+
alias: false
98+
copy_to: true
99+
100+
- from: context.request.url.search
101+
to: url.query
102+
103+
- from: context.request.url.protocol
104+
to: url.scheme
105+
alias: false
106+
copy_to: true
107+
108+
- from: context.user.email
109+
to: user.email
110+
111+
- from: context.user.id
112+
to: user.id
113+
114+
- from: context.user.username
115+
to: user.name

_meta/fields.common.yml

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -446,19 +446,9 @@
446446
type: group
447447
dynamic: false
448448
fields:
449-
- name: href
450-
type: group
451-
fields:
452-
- name: original
453-
type: alias
454-
path: context.request.url.raw
455-
456-
- name: host
457-
type: group
458-
fields:
459-
- name: name
460-
type: alias
461-
path: context.request.url.hostname
449+
- name: domain
450+
type: alias
451+
path: context.request.url.hostname
462452

463453
- name: fragment
464454
type: alias
@@ -469,12 +459,8 @@
469459
path: context.request.url.full
470460

471461
- name: path
472-
type: group
473-
fields:
474-
- name: original
475-
type: alias
476-
path: context.request.url.pathname
477-
# TODO: multifield original.text
462+
type: alias
463+
path: context.request.url.pathname
478464

479465
# context.request.url.port keyword -> long
480466
- name: port
@@ -483,12 +469,9 @@
483469
The port of the request, e.g. 443.
484470
485471
- name: query
486-
type: group
487-
fields:
488-
- name: query
489-
type: alias
490-
path: context.request.url.search
491-
# TODO: multifield original.text
472+
type: alias
473+
path: context.request.url.search
474+
# TODO: multifield original.text
492475

493476
# context.request.url.protocol minus the ":"
494477
- name: scheme

docs/fields.asciidoc

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -685,15 +685,6 @@ type: alias
685685
--
686686
687687
688-
689-
*`context.request.url.raw`*::
690-
+
691-
--
692-
type: alias
693-
694-
--
695-
696-
697688
*`context.request.url.hostname`*::
698689
+
699690
--
@@ -715,7 +706,6 @@ type: alias
715706
716707
--
717708
718-
719709
*`context.request.url.pathname`*::
720710
+
721711
--
@@ -733,7 +723,6 @@ The port of the request, e.g. 443.
733723
734724
--
735725
736-
737726
*`context.request.url.search`*::
738727
+
739728
--

include/fields.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/system/test_ecs_mappings.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,9 @@ def test_ecs_migration(self):
3434
all_fields = set()
3535
alias_fields = set()
3636
for f, a in flatmap(yaml.load(self.command_output)["mappings"]["doc"]["properties"]):
37+
all_fields.add(f)
3738
if a.get("type") == "alias":
3839
alias_fields.add(a["path"])
39-
else:
40-
all_fields.add(f)
4140

4241
# fields with special exception, due to mapping type changes, etc
4342
# no comment means unchanged
@@ -68,6 +67,16 @@ def test_ecs_migration(self):
6867
should_not_be_aliased = alias_fields - all_fields
6968
self.assertFalse(should_not_be_aliased, json.dumps(sorted(should_not_be_aliased)))
7069

70+
# check the migration log too
71+
with open(self._beat_path_join("_meta", "ecs-migration.yml")) as f:
72+
for m in yaml.load(f):
73+
if m.get("alias", True):
74+
self.assertIn(m["from"], alias_fields)
75+
elif m.get("copy_to", False):
76+
self.assertIn(m["from"], all_fields)
77+
self.assertIn(m["to"], all_fields)
78+
79+
# check that all fields are accounted for
7180
not_aliased = all_fields - alias_fields - exception_fields
7281
self.assertFalse(not_aliased,
7382
"\nall fields ({:d}):\n{}\n\naliased ({:d}):\n{}\n\nunaccounted for ({:d}):\n{}".format(

0 commit comments

Comments
 (0)