From 590627003e637fedd5f26da1466aa0982d663627 Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Thu, 12 May 2022 15:09:58 +0200 Subject: [PATCH] Revert "Generate documentation for imported external nested fields" (#817) Revert "Generate documentation for imported external nested fields (#814)" This reverts commit 6b03219d2c0b373d4639f268c7634d0c0019b7c6 --- go.mod | 2 +- go.sum | 4 +- internal/docs/exported_fields.go | 29 +++++----- .../gcp/data_stream/compute/fields/agent.yml | 56 +++++++++++++++++++ .../gcp/data_stream/compute/fields/ecs.yml | 16 ++++++ test/packages/parallel/gcp/docs/compute.md | 16 ++---- 6 files changed, 95 insertions(+), 28 deletions(-) diff --git a/go.mod b/go.mod index 0e2670eb3..41f24ec7f 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index 1daa9eb12..f3727a41e 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/internal/docs/exported_fields.go b/internal/docs/exported_fields.go index 87b8c9cec..59babdae9 100644 --- a/internal/docs/exported_fields.go +++ b/internal/docs/exported_fields.go @@ -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, diff --git a/test/packages/parallel/gcp/data_stream/compute/fields/agent.yml b/test/packages/parallel/gcp/data_stream/compute/fields/agent.yml index 57264f48b..2a31d79f4 100644 --- a/test/packages/parallel/gcp/data_stream/compute/fields/agent.yml +++ b/test/packages/parallel/gcp/data_stream/compute/fields/agent.yml @@ -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 diff --git a/test/packages/parallel/gcp/data_stream/compute/fields/ecs.yml b/test/packages/parallel/gcp/data_stream/compute/fields/ecs.yml index 5cf1142be..83e3f6f12 100644 --- a/test/packages/parallel/gcp/data_stream/compute/fields/ecs.yml +++ b/test/packages/parallel/gcp/data_stream/compute/fields/ecs.yml @@ -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 diff --git a/test/packages/parallel/gcp/docs/compute.md b/test/packages/parallel/gcp/docs/compute.md index e2c2d38e8..c3c4b42f5 100644 --- a/test/packages/parallel/gcp/docs/compute.md +++ b/test/packages/parallel/gcp/docs/compute.md @@ -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 | @@ -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 |