Skip to content

Commit

Permalink
Revert "Generate documentation for imported external nested fields" (#…
Browse files Browse the repository at this point in the history
…817)

Revert "Generate documentation for imported external nested fields (#814)"

This reverts commit 6b03219
  • Loading branch information
jsoriano authored May 12, 2022
1 parent 86c08f2 commit 5906270
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 28 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/elastic/go-elasticsearch/v7 v7.17.1
github.com/elastic/go-licenser v0.4.0
github.com/elastic/go-ucfg v0.8.4
github.com/elastic/package-spec v1.8.0
github.com/elastic/package-spec v1.8.1
github.com/fatih/color v1.13.0
github.com/go-git/go-billy/v5 v5.3.1
github.com/go-git/go-git/v5 v5.4.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,8 @@ github.com/elastic/go-licenser v0.4.0 h1:jLq6A5SilDS/Iz1ABRkO6BHy91B9jBora8FwGRs
github.com/elastic/go-licenser v0.4.0/go.mod h1:V56wHMpmdURfibNBggaSBfqgPxyT1Tldns1i87iTEvU=
github.com/elastic/go-ucfg v0.8.4 h1:OAHTnubzXKsYYYWVzl8psLcS5mCbNKjXxtMY41itthk=
github.com/elastic/go-ucfg v0.8.4/go.mod h1:4E8mPOLSUV9hQ7sgLEJ4bvt0KhMuDJa8joDT2QGAEKA=
github.com/elastic/package-spec v1.8.0 h1:/5P4SwQhJgfULRg1b7I83TOzij4/L+J39o1LJiJTiJ0=
github.com/elastic/package-spec v1.8.0/go.mod h1:KzGTSDqCkdhmL1IFpOH2ZQNSSE9JEhNtndxU3ZrQilA=
github.com/elastic/package-spec v1.8.1 h1:FOBODPtIrKsNSDuRMPy8zDmEj8A2/ZyevnlfwCKi+ms=
github.com/elastic/package-spec v1.8.1/go.mod h1:KzGTSDqCkdhmL1IFpOH2ZQNSSE9JEhNtndxU3ZrQilA=
github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153 h1:yUdfgN0XgIJw7foRItutHYUIhlcKzcSf5vDpdhQAKTc=
github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc=
github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs=
Expand Down
29 changes: 14 additions & 15 deletions internal/docs/exported_fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,22 +125,21 @@ func visitFields(namePrefix string, f fields.FieldDefinition, records []fieldsTa
}
name += f.Name

if f.External != "" {
imported, err := fdm.ImportField(f.External, name)
if err != nil {
return nil, errors.Wrap(err, "can't import field")
}

// Override imported fields with the definition, except for the type and external.
var updated fields.FieldDefinition
updated.Update(imported)
updated.Update(f)
updated.Type = imported.Type
updated.External = ""
f = updated
}

if len(f.Fields) == 0 && f.Type != "group" {
if f.External != "" {
imported, err := fdm.ImportField(f.External, name)
if err != nil {
return nil, errors.Wrap(err, "can't import field")
}

// Override imported fields with the definition, except for the type and external.
var updated fields.FieldDefinition
updated.Update(imported)
updated.Update(f)
updated.Type = imported.Type
updated.External = ""
f = updated
}
records = append(records, fieldsTableRecord{
name: name,
description: f.Description,
Expand Down
56 changes: 56 additions & 0 deletions test/packages/parallel/gcp/data_stream/compute/fields/agent.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,59 @@
- name: cloud
title: Cloud
group: 2
description: Fields related to the cloud or infrastructure the events are coming from.
footnote: 'Examples: If Metricbeat is running on an GCP Compute VM and fetches data from its host, the cloud info contains the data about this machine. If Metricbeat runs on a remote machine outside the cloud and fetches data from a service running in the cloud, the field contains cloud data from the machine the service is running on.'
type: group
fields:
- name: account.id
level: extended
type: keyword
ignore_above: 1024
description: '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.'
example: 666777888999
- name: availability_zone
level: extended
type: keyword
ignore_above: 1024
description: Availability zone in which this host is running.
example: us-east-1c
- name: instance.id
level: extended
type: keyword
ignore_above: 1024
description: Instance ID of the host machine.
example: i-1234567890abcdef0
- name: instance.name
level: extended
type: keyword
ignore_above: 1024
description: Instance name of the host machine.
- name: machine.type
level: extended
type: keyword
ignore_above: 1024
description: Machine type of the host machine.
example: t2.medium
- name: provider
level: extended
type: keyword
ignore_above: 1024
description: Name of the cloud provider. Example values are aws, azure, gcp, or digitalocean.
example: aws
- name: region
level: extended
type: keyword
ignore_above: 1024
description: Region in which this host is running.
example: us-east-1
- name: project.id
type: keyword
description: Name of the project in Google Cloud.
- name: image.id
type: keyword
description: Image ID for the cloud instance.
- name: container
title: Container
group: 2
Expand Down
16 changes: 16 additions & 0 deletions test/packages/parallel/gcp/data_stream/compute/fields/ecs.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
- external: ecs
name: cloud
- external: ecs
name: cloud.account.id
- external: ecs
name: cloud.account.name
- external: ecs
name: cloud.availability_zone
- external: ecs
name: cloud.instance.id
- external: ecs
name: cloud.machine.type
- external: ecs
name: cloud.provider
- external: ecs
name: cloud.region
- external: ecs
name: ecs.version
- external: ecs
name: error
- external: ecs
name: error.message
- external: ecs
name: service.type
16 changes: 6 additions & 10 deletions test/packages/parallel/gcp/docs/compute.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,17 @@ An example event for `compute` looks as following:
| Field | Description | Type |
|---|---|---|
| @timestamp | Event timestamp. | date |
| cloud | Fields related to the cloud or infrastructure the events are coming from. | group |
| 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 |
| 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 |
| cloud.availability_zone | Availability zone in which this host, resource, or service is located. | keyword |
| cloud.availability_zone | Availability zone in which this host is running. | keyword |
| cloud.image.id | Image ID for the cloud instance. | keyword |
| cloud.instance.id | Instance ID of the host machine. | keyword |
| cloud.instance.name | Instance name of the host machine. | keyword |
| cloud.machine.type | Machine type of the host machine. | keyword |
| cloud.project.id | The cloud project identifier. Examples: Google Cloud Project id, Azure Project id. | keyword |
| cloud.project.name | The cloud project name. Examples: Google Cloud Project name, Azure Project name. | keyword |
| cloud.project.id | Name of the project in Google Cloud. | keyword |
| cloud.provider | Name of the cloud provider. Example values are aws, azure, gcp, or digitalocean. | keyword |
| cloud.region | Region in which this host, resource, or service is located. | keyword |
| 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 |
| cloud.region | Region in which this host is running. | keyword |
| container.id | Unique container id. | keyword |
| container.image.name | Name of the image the container was built on. | keyword |
| container.labels | Image labels. | object |
Expand All @@ -117,12 +117,8 @@ An example event for `compute` looks as following:
| data_stream.namespace | Data stream namespace. | constant_keyword |
| data_stream.type | Data stream type. | constant_keyword |
| 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 |
| error.code | Error code describing the error. | keyword |
| error.id | Unique identifier for the error. | keyword |
| 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 |
| error.message | Error message. | match_only_text |
| error.stack_trace | The stack trace of this error in plain text. | wildcard |
| error.stack_trace.text | Multi-field of `error.stack_trace`. | match_only_text |
| error.type | The type of the error, for example the class name of the exception. | keyword |
| event.dataset | Event dataset | constant_keyword |
| event.module | Event module | constant_keyword |
| gcp.compute.firewall.dropped.bytes | Incoming bytes dropped by the firewall | long |
Expand Down

0 comments on commit 5906270

Please sign in to comment.