Skip to content

Commit 6b03219

Browse files
authored
Generate documentation for imported external nested fields (#814)
1 parent f0b24d2 commit 6b03219

File tree

2 files changed

+24
-18
lines changed

2 files changed

+24
-18
lines changed

internal/docs/exported_fields.go

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -125,21 +125,22 @@ func visitFields(namePrefix string, f fields.FieldDefinition, records []fieldsTa
125125
}
126126
name += f.Name
127127

128-
if len(f.Fields) == 0 && f.Type != "group" {
129-
if f.External != "" {
130-
imported, err := fdm.ImportField(f.External, name)
131-
if err != nil {
132-
return nil, errors.Wrap(err, "can't import field")
133-
}
134-
135-
// Override imported fields with the definition, except for the type and external.
136-
var updated fields.FieldDefinition
137-
updated.Update(imported)
138-
updated.Update(f)
139-
updated.Type = imported.Type
140-
updated.External = ""
141-
f = updated
128+
if f.External != "" {
129+
imported, err := fdm.ImportField(f.External, name)
130+
if err != nil {
131+
return nil, errors.Wrap(err, "can't import field")
142132
}
133+
134+
// Override imported fields with the definition, except for the type and external.
135+
var updated fields.FieldDefinition
136+
updated.Update(imported)
137+
updated.Update(f)
138+
updated.Type = imported.Type
139+
updated.External = ""
140+
f = updated
141+
}
142+
143+
if len(f.Fields) == 0 && f.Type != "group" {
143144
records = append(records, fieldsTableRecord{
144145
name: name,
145146
description: f.Description,

test/packages/parallel/gcp/docs/compute.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,17 +98,18 @@ An example event for `compute` looks as following:
9898
| Field | Description | Type |
9999
|---|---|---|
100100
| @timestamp | Event timestamp. | date |
101-
| cloud | Fields related to the cloud or infrastructure the events are coming from. | group |
102101
| cloud.account.id | The cloud account or organization id used to identify different entities in a multi-tenant environment. Examples: AWS account id, Google Cloud ORG Id, or other unique identifier. | keyword |
103102
| cloud.account.name | The cloud account name or alias used to identify different entities in a multi-tenant environment. Examples: AWS account name, Google Cloud ORG display name. | keyword |
104103
| cloud.availability_zone | Availability zone in which this host is running. | keyword |
105104
| cloud.image.id | Image ID for the cloud instance. | keyword |
106105
| cloud.instance.id | Instance ID of the host machine. | keyword |
107106
| cloud.instance.name | Instance name of the host machine. | keyword |
108107
| cloud.machine.type | Machine type of the host machine. | keyword |
109-
| cloud.project.id | Name of the project in Google Cloud. | keyword |
108+
| cloud.project.id | The cloud project identifier. Examples: Google Cloud Project id, Azure Project id. | keyword |
109+
| cloud.project.name | The cloud project name. Examples: Google Cloud Project name, Azure Project name. | keyword |
110110
| cloud.provider | Name of the cloud provider. Example values are aws, azure, gcp, or digitalocean. | keyword |
111-
| cloud.region | Region in which this host is running. | keyword |
111+
| cloud.region | Region in which this host, resource, or service is located. | keyword |
112+
| cloud.service.name | The cloud service name is intended to distinguish services running on different platforms within a provider, eg AWS EC2 vs Lambda, GCP GCE vs App Engine, Azure VM vs App Server. Examples: app engine, app service, cloud run, fargate, lambda. | keyword |
112113
| container.id | Unique container id. | keyword |
113114
| container.image.name | Name of the image the container was built on. | keyword |
114115
| container.labels | Image labels. | object |
@@ -117,8 +118,12 @@ An example event for `compute` looks as following:
117118
| data_stream.namespace | Data stream namespace. | constant_keyword |
118119
| data_stream.type | Data stream type. | constant_keyword |
119120
| ecs.version | ECS version this event conforms to. `ecs.version` is a required field and must exist in all events. When querying across multiple indices -- which may conform to slightly different ECS versions -- this field lets integrations adjust to the schema version of the events. | keyword |
120-
| error | These fields can represent errors of any kind. Use them for errors that happen while fetching events or in cases where the event itself contains an error. | group |
121+
| error.code | Error code describing the error. | keyword |
122+
| error.id | Unique identifier for the error. | keyword |
121123
| error.message | Error message. | match_only_text |
124+
| error.stack_trace | The stack trace of this error in plain text. | wildcard |
125+
| error.stack_trace.text | Multi-field of `error.stack_trace`. | match_only_text |
126+
| error.type | The type of the error, for example the class name of the exception. | keyword |
122127
| event.dataset | Event dataset | constant_keyword |
123128
| event.module | Event module | constant_keyword |
124129
| gcp.compute.firewall.dropped.bytes | Incoming bytes dropped by the firewall | long |

0 commit comments

Comments
 (0)