From 8d26505cc2e8684d4d92394bba0ec9bb73980110 Mon Sep 17 00:00:00 2001 From: Tetiana Kravchenko Date: Mon, 23 Jan 2023 10:38:44 +0100 Subject: [PATCH 01/24] add generic metadata fetcher Signed-off-by: Tetiana Kravchenko --- .../add_cloud_metadata/generic_fetcher.go | 56 +++++++ .../add_cloud_metadata/provider_aws_ec2.go | 156 ++++++++---------- 2 files changed, 124 insertions(+), 88 deletions(-) create mode 100644 libbeat/processors/add_cloud_metadata/generic_fetcher.go diff --git a/libbeat/processors/add_cloud_metadata/generic_fetcher.go b/libbeat/processors/add_cloud_metadata/generic_fetcher.go new file mode 100644 index 000000000000..bc34d6bcc628 --- /dev/null +++ b/libbeat/processors/add_cloud_metadata/generic_fetcher.go @@ -0,0 +1,56 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package add_cloud_metadata + +import ( + "context" + "net/http" + + cfg "github.com/elastic/elastic-agent-libs/config" + "github.com/elastic/elastic-agent-libs/mapstr" +) + +type genericFetcher struct { + provider string + conv schemaConv + fetchRawProviderMetadata func(context.Context, http.Client, *result) +} + +func newGenericMetadataFetcher( + c *cfg.C, + provider string, + conv schemaConv, + genericFetcherMeta func(context.Context, http.Client, *result), +) (*genericFetcher, error) { + + gFetcher := &genericFetcher{provider, conv, genericFetcherMeta} + return gFetcher, nil +} + +func (g *genericFetcher) fetchMetadata(ctx context.Context, client http.Client) result { + res := result{provider: g.provider, metadata: mapstr.M{}} + g.fetchRawProviderMetadata(ctx, client, &res) + if res.err != nil { + return res + } + // Apply schema. + res.metadata = g.conv(res.metadata) + res.metadata.Put("cloud.provider", g.provider) + + return res +} diff --git a/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go b/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go index 54ac4eaf9b28..b3504effddf4 100644 --- a/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go +++ b/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go @@ -18,21 +18,21 @@ package add_cloud_metadata import ( - "fmt" - "io" - "io/ioutil" - "net" + "context" "net/http" + awssdk "github.com/aws/aws-sdk-go-v2/aws" + awscfg "github.com/aws/aws-sdk-go-v2/config" + "github.com/aws/aws-sdk-go-v2/feature/ec2/imds" + "github.com/aws/aws-sdk-go-v2/service/ec2" + "github.com/aws/aws-sdk-go-v2/service/ec2/types" "github.com/elastic/elastic-agent-libs/logp" "github.com/elastic/elastic-agent-libs/mapstr" - s "github.com/elastic/beats/v7/libbeat/common/schema" - c "github.com/elastic/beats/v7/libbeat/common/schema/mapstriface" conf "github.com/elastic/elastic-agent-libs/config" - "github.com/elastic/elastic-agent-libs/transport/tlscommon" ) +//TODO: adjust tests and delete consts: const ( ec2InstanceIdentityURI = "/2014-02-25/dynamic/instance-identity/document" ec2InstanceIMDSv2TokenValueHeader = "X-aws-ec2-metadata-token" @@ -41,102 +41,82 @@ const ( ec2InstanceIMDSv2TokenURI = "/latest/api/token" ) -// fetches IMDSv2 token, returns empty one on errors -func getIMDSv2Token(c *conf.C) string { - logger := logp.NewLogger("add_cloud_metadata") +// AWS EC2 Metadata Service +var ec2MetadataFetcher = provider{ + Name: "aws-ec2", - config := defaultConfig() - if err := c.Unpack(&config); err != nil { - logger.Warnf("error when load config for getting IMDSv2 token: %s. No token in the metadata request will be used.", err) - return "" - } + Local: true, - tlsConfig, err := tlscommon.LoadTLSConfig(config.TLS) - if err != nil { - logger.Warnf("error when load TLS config for getting IMDSv2 token: %s. No token in the metadata request will be used.", err) - return "" - } + Create: func(_ string, config *conf.C) (metadataFetcher, error) { + ec2Schema := func(m map[string]interface{}) mapstr.M { + m["service"] = mapstr.M{ + "name": "EC2", + } + return mapstr.M{"cloud": m} + } - client := http.Client{ - Timeout: config.Timeout, - Transport: &http.Transport{ - DisableKeepAlives: true, - DialContext: (&net.Dialer{ - Timeout: config.Timeout, - KeepAlive: 0, - }).DialContext, - TLSClientConfig: tlsConfig.ToConfig(), - }, - } + fetcher, err := newGenericMetadataFetcher(config, "aws", ec2Schema, fetchRawProviderMetadata) + return fetcher, err + }, +} - tokenReq, err := http.NewRequest("PUT", fmt.Sprintf("http://%s%s", metadataHost, ec2InstanceIMDSv2TokenURI), nil) - if err != nil { - logger.Warnf("error when make token request for getting IMDSv2 token: %s. No token in the metadata request will be used.", err) - return "" - } +// fetchRaw queries raw metadata from a hosting provider's metadata service. +func fetchRawProviderMetadata( + ctx context.Context, + client http.Client, + result *result, +) { + logger := logp.NewLogger("add_cloud_metadata") + // config := defaultConfig() + // if err := c.Unpack(&config); err != nil { + // logger.Warnf("error when load config for getting IMDSv2 token: %s. No token in the metadata request will be used.", err) + // } - tokenReq.Header.Add(ec2InstanceIMDSv2TokenTTLHeader, ec2InstanceIMDSv2TokenTTLValue) - rsp, err := client.Do(tokenReq) - if rsp == nil { - logger.Warnf("read token request for getting IMDSv2 token returns empty: %s. No token in the metadata request will be used.", err) - return "" + // LoadDefaultConfig loads the Ec2 role credentials + awsConfig, err := awscfg.LoadDefaultConfig(context.TODO(), awscfg.WithHTTPClient(&client)) + if err != nil { + logger.Warnf("error when loading AWS default configuration: %s.", err) } - defer func(body io.ReadCloser) { - if body != nil { - body.Close() - } - }(rsp.Body) + awsClient := imds.NewFromConfig(awsConfig) + instanceIdentity, err := awsClient.GetInstanceIdentityDocument(context.TODO(), &imds.GetInstanceIdentityDocumentInput{}) if err != nil { - logger.Warnf("error when read token request for getting IMDSv2 token: %s. No token in the metadata request will be used.", err) - return "" + logger.Warnf("error when fetching EC2 Identity Document: %s.", err) } - if rsp.StatusCode != http.StatusOK { - logger.Warnf("error when check request status for getting IMDSv2 token: http request status %d. No token in the metadata request will be used.", rsp.StatusCode) - return "" + // Region must be set to be able to get EC2 Tags + awsConfig.Region = instanceIdentity.Region + + svc := ec2.NewFromConfig(awsConfig) + input := &ec2.DescribeTagsInput{ + Filters: []types.Filter{ + { + Name: awssdk.String("resource-id"), + Values: []string{ + *awssdk.String(instanceIdentity.InstanceIdentityDocument.InstanceID), + }, + }, + { + Name: awssdk.String("key"), + Values: []string{ + *awssdk.String("eks:cluster-name"), + }, + }, + }, } - all, err := ioutil.ReadAll(rsp.Body) + tagsResult, err := svc.DescribeTags(context.TODO(), input) if err != nil { - logger.Warnf("error when reading token request for getting IMDSv2 token: %s. No token in the metadata request will be used.", err) - return "" + logger.Warnf("error when fetching EC2 Tags: %s.", err) } - return string(all) -} - -// AWS EC2 Metadata Service -var ec2MetadataFetcher = provider{ - Name: "aws-ec2", - - Local: true, - - Create: func(_ string, config *conf.C) (metadataFetcher, error) { - ec2Schema := func(m map[string]interface{}) mapstr.M { - m["serviceName"] = "EC2" - out, _ := s.Schema{ - "instance": s.Object{"id": c.Str("instanceId")}, - "machine": s.Object{"type": c.Str("instanceType")}, - "region": c.Str("region"), - "availability_zone": c.Str("availabilityZone"), - "service": s.Object{ - "name": c.Str("serviceName"), - }, - "account": s.Object{"id": c.Str("accountId")}, - "image": s.Object{"id": c.Str("imageId")}, - }.Apply(m) - return mapstr.M{"cloud": out} - } - - headers := make(map[string]string, 1) - token := getIMDSv2Token(config) - if len(token) > 0 { - headers[ec2InstanceIMDSv2TokenValueHeader] = token - } + result.metadata.Put("cloud.orchestrator.cluster.name", tagsResult.Tags[0].Value) + result.metadata.Put("cloud.instance.id", instanceIdentity.InstanceIdentityDocument.InstanceID) + result.metadata.Put("cloud.machine.type", instanceIdentity.InstanceIdentityDocument.InstanceType) + result.metadata.Put("cloud.region", instanceIdentity.InstanceIdentityDocument.Region) + result.metadata.Put("cloud.availability_zone", instanceIdentity.InstanceIdentityDocument.AvailabilityZone) + result.metadata.Put("cloud.account.id", instanceIdentity.InstanceIdentityDocument.AccountID) + result.metadata.Put("cloud.image.id", instanceIdentity.InstanceIdentityDocument.ImageID) - fetcher, err := newMetadataFetcher(config, "aws", headers, metadataHost, ec2Schema, ec2InstanceIdentityURI) - return fetcher, err - }, } From 481f65cfda378b3ea3b018f08e5c31f64e307fa0 Mon Sep 17 00:00:00 2001 From: Tetiana Kravchenko Date: Mon, 10 Apr 2023 13:46:15 +0200 Subject: [PATCH 02/24] merge main Signed-off-by: Tetiana Kravchenko --- dev-tools/kubernetes/Tiltfile | 24 ++- .../sys/fs/cgroup/blkio/cgroup.clone_children | 1 + .../sys/fs/cgroup/blkio/cgroup.sane_behavior | 1 + .../notify_on_release | 1 + .../tasks | 1 + .../fs/cgroup/blkio/docker/notify_on_release | 1 + .../docker/sys/fs/cgroup/blkio/docker/tasks | 0 .../sys/fs/cgroup/blkio/notify_on_release | 1 + .../docker/sys/fs/cgroup/blkio/release_agent | 1 + .../testdata/docker/sys/fs/cgroup/blkio/tasks | 158 ++++++++++++++++++ .../sys/fs/cgroup/cpu/cgroup.clone_children | 1 + .../sys/fs/cgroup/cpu/cgroup.sane_behavior | 1 + .../notify_on_release | 1 + .../tasks | 37 ++++ .../fs/cgroup/cpu/docker/notify_on_release | 1 + .../docker/sys/fs/cgroup/cpu/docker/tasks | 0 .../sys/fs/cgroup/cpu/notify_on_release | 1 + .../docker/sys/fs/cgroup/cpu/release_agent | 1 + .../testdata/docker/sys/fs/cgroup/cpu/tasks | 158 ++++++++++++++++++ .../fs/cgroup/cpuacct/cgroup.clone_children | 1 + .../fs/cgroup/cpuacct/cgroup.sane_behavior | 1 + .../notify_on_release | 1 + .../tasks | 37 ++++ .../cgroup/cpuacct/docker/notify_on_release | 1 + .../docker/sys/fs/cgroup/cpuacct/docker/tasks | 0 .../sys/fs/cgroup/cpuacct/notify_on_release | 1 + .../sys/fs/cgroup/cpuacct/release_agent | 1 + .../docker/sys/fs/cgroup/cpuacct/tasks | 158 ++++++++++++++++++ .../sys/fs/cgroup/cpuset/cgroup.sane_behavior | 1 + .../notify_on_release | 1 + .../tasks | 37 ++++ .../fs/cgroup/cpuset/docker/notify_on_release | 1 + .../docker/sys/fs/cgroup/cpuset/docker/tasks | 0 .../sys/fs/cgroup/cpuset/notify_on_release | 1 + .../docker/sys/fs/cgroup/cpuset/release_agent | 1 + .../docker/sys/fs/cgroup/cpuset/tasks | 158 ++++++++++++++++++ .../fs/cgroup/memory/cgroup.clone_children | 1 + .../sys/fs/cgroup/memory/cgroup.event_control | 0 .../sys/fs/cgroup/memory/cgroup.sane_behavior | 1 + .../notify_on_release | 1 + .../tasks | 37 ++++ .../fs/cgroup/memory/docker/notify_on_release | 1 + .../docker/sys/fs/cgroup/memory/docker/tasks | 0 .../sys/fs/cgroup/memory/memory.force_empty | 0 .../memory/memory.move_charge_at_immigrate | 1 + .../sys/fs/cgroup/memory/memory.use_hierarchy | 1 + .../sys/fs/cgroup/memory/notify_on_release | 1 + .../docker/sys/fs/cgroup/memory/release_agent | 1 + .../docker/sys/fs/cgroup/memory/tasks | 158 ++++++++++++++++++ .../add_cloud_metadata/generic_fetcher.go | 4 +- .../add_cloud_metadata/provider_aws_ec2.go | 14 +- 51 files changed, 998 insertions(+), 14 deletions(-) create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/cgroup.clone_children create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/cgroup.sane_behavior create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/notify_on_release create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/tasks create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/notify_on_release create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/release_agent create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/tasks create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/cgroup.clone_children create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/cgroup.sane_behavior create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/notify_on_release create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/tasks create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/notify_on_release create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/release_agent create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/tasks create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/cgroup.clone_children create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/cgroup.sane_behavior create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/notify_on_release create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/tasks create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/notify_on_release create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/release_agent create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/tasks create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/cgroup.sane_behavior create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/notify_on_release create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/tasks create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/notify_on_release create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/release_agent create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/tasks create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/cgroup.clone_children create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/cgroup.event_control create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/cgroup.sane_behavior create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/notify_on_release create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/tasks create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/memory.force_empty create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/memory.move_charge_at_immigrate create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/memory.use_hierarchy create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/notify_on_release create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/release_agent create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/tasks diff --git a/dev-tools/kubernetes/Tiltfile b/dev-tools/kubernetes/Tiltfile index edfef02550ea..13b7e204c92e 100644 --- a/dev-tools/kubernetes/Tiltfile +++ b/dev-tools/kubernetes/Tiltfile @@ -47,6 +47,18 @@ def build( default_registry(docker_registry) print("Docker registry: {}".format(docker_registry)) + if k8s_env == "aws": + # In order to push to AWS you need ti run: + # aws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin XXXXX.dkr.ecr.us-east-2.amazonaws.com/metricbeat-debug + # + # More info at https://docs.aws.amazon.com/AmazonECR/latest/userguide/docker-push-ecr-image.html + docker_registry = "627286350134.dkr.ecr.us-east-2.amazonaws.com".format( + docker_image) + + default_registry(docker_registry) + print("Docker registry: {}".format(docker_registry)) + + print("Docker image: {}".format(docker_image)) docker_file = '{}/Dockerfile.{}'.format(beat, mode) @@ -149,7 +161,7 @@ def beat( if arch not in ["arm64", "amd64"]: print("Invalid arch: {}".format(arch)) exit(-1) - if k8s_env not in ["kind", "gcp"]: + if k8s_env not in ["kind", "gcp", "aws"]: print("Invalid k8s_env: {}".format(k8s_env)) exit(-1) if k8s_cluster not in ["single", "multi"]: @@ -191,10 +203,10 @@ def beat( k8s_expose(beat=beat, mode=mode, k8s_cluster=k8s_cluster) -beat(beat="heartbeat", - mode="debug", - # mode="run", - arch="arm64", - k8s_env="kind", +beat(beat="metricbeat", + # mode="debug", + mode="run", + arch="amd64", + k8s_env="aws", k8s_cluster="single", ) diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/cgroup.clone_children b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/cgroup.clone_children new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/cgroup.clone_children @@ -0,0 +1 @@ +0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/cgroup.sane_behavior b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/cgroup.sane_behavior new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/cgroup.sane_behavior @@ -0,0 +1 @@ +0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release @@ -0,0 +1 @@ +0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks new file mode 100644 index 000000000000..2ab15755dfe0 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks @@ -0,0 +1 @@ +11668 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/notify_on_release new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/notify_on_release @@ -0,0 +1 @@ +0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/tasks new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/notify_on_release new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/notify_on_release @@ -0,0 +1 @@ +0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/release_agent b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/release_agent new file mode 100644 index 000000000000..8b137891791f --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/release_agent @@ -0,0 +1 @@ + diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/tasks new file mode 100644 index 000000000000..27537f94a4b3 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/tasks @@ -0,0 +1,158 @@ +1 +2 +3 +5 +7 +8 +9 +10 +11 +13 +14 +15 +16 +18 +19 +20 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +40 +41 +42 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +123 +124 +151 +152 +155 +156 +157 +158 +171 +202 +272 +322 +323 +388 +519 +574 +575 +576 +620 +648 +659 +734 +748 +750 +752 +753 +754 +755 +756 +771 +772 +773 +777 +778 +795 +797 +798 +799 +809 +816 +840 +885 +886 +887 +909 +911 +912 +969 +975 +976 +977 +978 +979 +989 +1056 +1154 +1161 +1293 +1294 +1296 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/cgroup.clone_children b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/cgroup.clone_children new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/cgroup.clone_children @@ -0,0 +1 @@ +0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/cgroup.sane_behavior b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/cgroup.sane_behavior new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/cgroup.sane_behavior @@ -0,0 +1 @@ +0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release @@ -0,0 +1 @@ +0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks new file mode 100644 index 000000000000..16ae34357356 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks @@ -0,0 +1,37 @@ +985 +1006 +1007 +1008 +1009 +1010 +1011 +1012 +1013 +1014 +1015 +1016 +1017 +1018 +1019 +1020 +1021 +1048 +1049 +1052 +1053 +1054 +1055 +1057 +1058 +1059 +1060 +1061 +1062 +1063 +1064 +1065 +1066 +1067 +1068 +1069 +1070 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/notify_on_release new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/notify_on_release @@ -0,0 +1 @@ +0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/tasks new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/notify_on_release new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/notify_on_release @@ -0,0 +1 @@ +0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/release_agent b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/release_agent new file mode 100644 index 000000000000..8b137891791f --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/release_agent @@ -0,0 +1 @@ + diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/tasks new file mode 100644 index 000000000000..27537f94a4b3 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/tasks @@ -0,0 +1,158 @@ +1 +2 +3 +5 +7 +8 +9 +10 +11 +13 +14 +15 +16 +18 +19 +20 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +40 +41 +42 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +123 +124 +151 +152 +155 +156 +157 +158 +171 +202 +272 +322 +323 +388 +519 +574 +575 +576 +620 +648 +659 +734 +748 +750 +752 +753 +754 +755 +756 +771 +772 +773 +777 +778 +795 +797 +798 +799 +809 +816 +840 +885 +886 +887 +909 +911 +912 +969 +975 +976 +977 +978 +979 +989 +1056 +1154 +1161 +1293 +1294 +1296 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/cgroup.clone_children b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/cgroup.clone_children new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/cgroup.clone_children @@ -0,0 +1 @@ +0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/cgroup.sane_behavior b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/cgroup.sane_behavior new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/cgroup.sane_behavior @@ -0,0 +1 @@ +0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release @@ -0,0 +1 @@ +0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks new file mode 100644 index 000000000000..16ae34357356 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks @@ -0,0 +1,37 @@ +985 +1006 +1007 +1008 +1009 +1010 +1011 +1012 +1013 +1014 +1015 +1016 +1017 +1018 +1019 +1020 +1021 +1048 +1049 +1052 +1053 +1054 +1055 +1057 +1058 +1059 +1060 +1061 +1062 +1063 +1064 +1065 +1066 +1067 +1068 +1069 +1070 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/notify_on_release new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/notify_on_release @@ -0,0 +1 @@ +0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/tasks new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/notify_on_release new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/notify_on_release @@ -0,0 +1 @@ +0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/release_agent b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/release_agent new file mode 100644 index 000000000000..8b137891791f --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/release_agent @@ -0,0 +1 @@ + diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/tasks new file mode 100644 index 000000000000..27537f94a4b3 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/tasks @@ -0,0 +1,158 @@ +1 +2 +3 +5 +7 +8 +9 +10 +11 +13 +14 +15 +16 +18 +19 +20 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +40 +41 +42 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +123 +124 +151 +152 +155 +156 +157 +158 +171 +202 +272 +322 +323 +388 +519 +574 +575 +576 +620 +648 +659 +734 +748 +750 +752 +753 +754 +755 +756 +771 +772 +773 +777 +778 +795 +797 +798 +799 +809 +816 +840 +885 +886 +887 +909 +911 +912 +969 +975 +976 +977 +978 +979 +989 +1056 +1154 +1161 +1293 +1294 +1296 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/cgroup.sane_behavior b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/cgroup.sane_behavior new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/cgroup.sane_behavior @@ -0,0 +1 @@ +0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release @@ -0,0 +1 @@ +0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks new file mode 100644 index 000000000000..16ae34357356 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks @@ -0,0 +1,37 @@ +985 +1006 +1007 +1008 +1009 +1010 +1011 +1012 +1013 +1014 +1015 +1016 +1017 +1018 +1019 +1020 +1021 +1048 +1049 +1052 +1053 +1054 +1055 +1057 +1058 +1059 +1060 +1061 +1062 +1063 +1064 +1065 +1066 +1067 +1068 +1069 +1070 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/notify_on_release new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/notify_on_release @@ -0,0 +1 @@ +0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/tasks new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/notify_on_release new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/notify_on_release @@ -0,0 +1 @@ +0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/release_agent b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/release_agent new file mode 100644 index 000000000000..8b137891791f --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/release_agent @@ -0,0 +1 @@ + diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/tasks new file mode 100644 index 000000000000..27537f94a4b3 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/tasks @@ -0,0 +1,158 @@ +1 +2 +3 +5 +7 +8 +9 +10 +11 +13 +14 +15 +16 +18 +19 +20 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +40 +41 +42 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +123 +124 +151 +152 +155 +156 +157 +158 +171 +202 +272 +322 +323 +388 +519 +574 +575 +576 +620 +648 +659 +734 +748 +750 +752 +753 +754 +755 +756 +771 +772 +773 +777 +778 +795 +797 +798 +799 +809 +816 +840 +885 +886 +887 +909 +911 +912 +969 +975 +976 +977 +978 +979 +989 +1056 +1154 +1161 +1293 +1294 +1296 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/cgroup.clone_children b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/cgroup.clone_children new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/cgroup.clone_children @@ -0,0 +1 @@ +0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/cgroup.event_control b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/cgroup.event_control new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/cgroup.sane_behavior b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/cgroup.sane_behavior new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/cgroup.sane_behavior @@ -0,0 +1 @@ +0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release @@ -0,0 +1 @@ +0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks new file mode 100644 index 000000000000..16ae34357356 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks @@ -0,0 +1,37 @@ +985 +1006 +1007 +1008 +1009 +1010 +1011 +1012 +1013 +1014 +1015 +1016 +1017 +1018 +1019 +1020 +1021 +1048 +1049 +1052 +1053 +1054 +1055 +1057 +1058 +1059 +1060 +1061 +1062 +1063 +1064 +1065 +1066 +1067 +1068 +1069 +1070 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/notify_on_release new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/notify_on_release @@ -0,0 +1 @@ +0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/tasks new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/memory.force_empty b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/memory.force_empty new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/memory.move_charge_at_immigrate b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/memory.move_charge_at_immigrate new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/memory.move_charge_at_immigrate @@ -0,0 +1 @@ +0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/memory.use_hierarchy b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/memory.use_hierarchy new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/memory.use_hierarchy @@ -0,0 +1 @@ +0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/notify_on_release new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/notify_on_release @@ -0,0 +1 @@ +0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/release_agent b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/release_agent new file mode 100644 index 000000000000..8b137891791f --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/release_agent @@ -0,0 +1 @@ + diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/tasks new file mode 100644 index 000000000000..27537f94a4b3 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/tasks @@ -0,0 +1,158 @@ +1 +2 +3 +5 +7 +8 +9 +10 +11 +13 +14 +15 +16 +18 +19 +20 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +40 +41 +42 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +123 +124 +151 +152 +155 +156 +157 +158 +171 +202 +272 +322 +323 +388 +519 +574 +575 +576 +620 +648 +659 +734 +748 +750 +752 +753 +754 +755 +756 +771 +772 +773 +777 +778 +795 +797 +798 +799 +809 +816 +840 +885 +886 +887 +909 +911 +912 +969 +975 +976 +977 +978 +979 +989 +1056 +1154 +1161 +1293 +1294 +1296 diff --git a/libbeat/processors/add_cloud_metadata/generic_fetcher.go b/libbeat/processors/add_cloud_metadata/generic_fetcher.go index bc34d6bcc628..9e41422319ef 100644 --- a/libbeat/processors/add_cloud_metadata/generic_fetcher.go +++ b/libbeat/processors/add_cloud_metadata/generic_fetcher.go @@ -19,6 +19,7 @@ package add_cloud_metadata import ( "context" + "fmt" "net/http" cfg "github.com/elastic/elastic-agent-libs/config" @@ -48,8 +49,7 @@ func (g *genericFetcher) fetchMetadata(ctx context.Context, client http.Client) if res.err != nil { return res } - // Apply schema. - res.metadata = g.conv(res.metadata) + fmt.Printf("res: %s", res) res.metadata.Put("cloud.provider", g.provider) return res diff --git a/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go b/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go index b3504effddf4..c10f8adabfc2 100644 --- a/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go +++ b/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go @@ -32,7 +32,7 @@ import ( conf "github.com/elastic/elastic-agent-libs/config" ) -//TODO: adjust tests and delete consts: +// TODO: adjust tests and delete consts: const ( ec2InstanceIdentityURI = "/2014-02-25/dynamic/instance-identity/document" ec2InstanceIMDSv2TokenValueHeader = "X-aws-ec2-metadata-token" @@ -75,18 +75,20 @@ func fetchRawProviderMetadata( // LoadDefaultConfig loads the Ec2 role credentials awsConfig, err := awscfg.LoadDefaultConfig(context.TODO(), awscfg.WithHTTPClient(&client)) if err != nil { - logger.Warnf("error when loading AWS default configuration: %s.", err) + logger.Debugf("error loading AWS default configuration: %s.", err) + return } awsClient := imds.NewFromConfig(awsConfig) instanceIdentity, err := awsClient.GetInstanceIdentityDocument(context.TODO(), &imds.GetInstanceIdentityDocumentInput{}) if err != nil { - logger.Warnf("error when fetching EC2 Identity Document: %s.", err) + logger.Warnf("error fetching EC2 Identity Document: %s.", err) } // Region must be set to be able to get EC2 Tags - awsConfig.Region = instanceIdentity.Region + awsRegion := instanceIdentity.InstanceIdentityDocument.Region + awsConfig.Region = awsRegion svc := ec2.NewFromConfig(awsConfig) input := &ec2.DescribeTagsInput{ @@ -108,13 +110,13 @@ func fetchRawProviderMetadata( tagsResult, err := svc.DescribeTags(context.TODO(), input) if err != nil { - logger.Warnf("error when fetching EC2 Tags: %s.", err) + logger.Warnf("error fetching EC2 Tags: %s.", err) } result.metadata.Put("cloud.orchestrator.cluster.name", tagsResult.Tags[0].Value) result.metadata.Put("cloud.instance.id", instanceIdentity.InstanceIdentityDocument.InstanceID) result.metadata.Put("cloud.machine.type", instanceIdentity.InstanceIdentityDocument.InstanceType) - result.metadata.Put("cloud.region", instanceIdentity.InstanceIdentityDocument.Region) + result.metadata.Put("cloud.region", awsRegion) result.metadata.Put("cloud.availability_zone", instanceIdentity.InstanceIdentityDocument.AvailabilityZone) result.metadata.Put("cloud.account.id", instanceIdentity.InstanceIdentityDocument.AccountID) result.metadata.Put("cloud.image.id", instanceIdentity.InstanceIdentityDocument.ImageID) From 76a4da41183e7ffcd7d32e4692337a4b3fc74fd0 Mon Sep 17 00:00:00 2001 From: Tetiana Kravchenko Date: Mon, 10 Apr 2023 13:52:15 +0200 Subject: [PATCH 03/24] clean up Signed-off-by: Tetiana Kravchenko --- .../sys/fs/cgroup/blkio/cgroup.clone_children | 1 - .../sys/fs/cgroup/blkio/cgroup.sane_behavior | 1 - .../notify_on_release | 1 - .../tasks | 1 - .../fs/cgroup/blkio/docker/notify_on_release | 1 - .../docker/sys/fs/cgroup/blkio/docker/tasks | 0 .../sys/fs/cgroup/blkio/notify_on_release | 1 - .../docker/sys/fs/cgroup/blkio/release_agent | 1 - .../testdata/docker/sys/fs/cgroup/blkio/tasks | 158 ------------------ .../sys/fs/cgroup/cpu/cgroup.clone_children | 1 - .../sys/fs/cgroup/cpu/cgroup.sane_behavior | 1 - .../notify_on_release | 1 - .../tasks | 37 ---- .../fs/cgroup/cpu/docker/notify_on_release | 1 - .../docker/sys/fs/cgroup/cpu/docker/tasks | 0 .../sys/fs/cgroup/cpu/notify_on_release | 1 - .../docker/sys/fs/cgroup/cpu/release_agent | 1 - .../testdata/docker/sys/fs/cgroup/cpu/tasks | 158 ------------------ .../fs/cgroup/cpuacct/cgroup.clone_children | 1 - .../fs/cgroup/cpuacct/cgroup.sane_behavior | 1 - .../notify_on_release | 1 - .../tasks | 37 ---- .../cgroup/cpuacct/docker/notify_on_release | 1 - .../docker/sys/fs/cgroup/cpuacct/docker/tasks | 0 .../sys/fs/cgroup/cpuacct/notify_on_release | 1 - .../sys/fs/cgroup/cpuacct/release_agent | 1 - .../docker/sys/fs/cgroup/cpuacct/tasks | 158 ------------------ .../sys/fs/cgroup/cpuset/cgroup.sane_behavior | 1 - .../notify_on_release | 1 - .../tasks | 37 ---- .../fs/cgroup/cpuset/docker/notify_on_release | 1 - .../docker/sys/fs/cgroup/cpuset/docker/tasks | 0 .../sys/fs/cgroup/cpuset/notify_on_release | 1 - .../docker/sys/fs/cgroup/cpuset/release_agent | 1 - .../docker/sys/fs/cgroup/cpuset/tasks | 158 ------------------ .../fs/cgroup/memory/cgroup.clone_children | 1 - .../sys/fs/cgroup/memory/cgroup.event_control | 0 .../sys/fs/cgroup/memory/cgroup.sane_behavior | 1 - .../notify_on_release | 1 - .../tasks | 37 ---- .../fs/cgroup/memory/docker/notify_on_release | 1 - .../docker/sys/fs/cgroup/memory/docker/tasks | 0 .../sys/fs/cgroup/memory/memory.force_empty | 0 .../memory/memory.move_charge_at_immigrate | 1 - .../sys/fs/cgroup/memory/memory.use_hierarchy | 1 - .../sys/fs/cgroup/memory/notify_on_release | 1 - .../docker/sys/fs/cgroup/memory/release_agent | 1 - .../docker/sys/fs/cgroup/memory/tasks | 158 ------------------ 48 files changed, 970 deletions(-) delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/cgroup.clone_children delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/cgroup.sane_behavior delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/notify_on_release delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/tasks delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/notify_on_release delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/release_agent delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/tasks delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/cgroup.clone_children delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/cgroup.sane_behavior delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/notify_on_release delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/tasks delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/notify_on_release delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/release_agent delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/tasks delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/cgroup.clone_children delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/cgroup.sane_behavior delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/notify_on_release delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/tasks delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/notify_on_release delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/release_agent delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/tasks delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/cgroup.sane_behavior delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/notify_on_release delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/tasks delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/notify_on_release delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/release_agent delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/tasks delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/cgroup.clone_children delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/cgroup.event_control delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/cgroup.sane_behavior delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/notify_on_release delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/tasks delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/memory.force_empty delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/memory.move_charge_at_immigrate delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/memory.use_hierarchy delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/notify_on_release delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/release_agent delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/tasks diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/cgroup.clone_children b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/cgroup.clone_children deleted file mode 100644 index 573541ac9702..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/cgroup.clone_children +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/cgroup.sane_behavior b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/cgroup.sane_behavior deleted file mode 100644 index 573541ac9702..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/cgroup.sane_behavior +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release deleted file mode 100644 index 573541ac9702..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks deleted file mode 100644 index 2ab15755dfe0..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks +++ /dev/null @@ -1 +0,0 @@ -11668 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/notify_on_release deleted file mode 100644 index 573541ac9702..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/notify_on_release +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/tasks deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/notify_on_release deleted file mode 100644 index 573541ac9702..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/notify_on_release +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/release_agent b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/release_agent deleted file mode 100644 index 8b137891791f..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/release_agent +++ /dev/null @@ -1 +0,0 @@ - diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/tasks deleted file mode 100644 index 27537f94a4b3..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/tasks +++ /dev/null @@ -1,158 +0,0 @@ -1 -2 -3 -5 -7 -8 -9 -10 -11 -13 -14 -15 -16 -18 -19 -20 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -40 -41 -42 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -123 -124 -151 -152 -155 -156 -157 -158 -171 -202 -272 -322 -323 -388 -519 -574 -575 -576 -620 -648 -659 -734 -748 -750 -752 -753 -754 -755 -756 -771 -772 -773 -777 -778 -795 -797 -798 -799 -809 -816 -840 -885 -886 -887 -909 -911 -912 -969 -975 -976 -977 -978 -979 -989 -1056 -1154 -1161 -1293 -1294 -1296 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/cgroup.clone_children b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/cgroup.clone_children deleted file mode 100644 index 573541ac9702..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/cgroup.clone_children +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/cgroup.sane_behavior b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/cgroup.sane_behavior deleted file mode 100644 index 573541ac9702..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/cgroup.sane_behavior +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release deleted file mode 100644 index 573541ac9702..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks deleted file mode 100644 index 16ae34357356..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks +++ /dev/null @@ -1,37 +0,0 @@ -985 -1006 -1007 -1008 -1009 -1010 -1011 -1012 -1013 -1014 -1015 -1016 -1017 -1018 -1019 -1020 -1021 -1048 -1049 -1052 -1053 -1054 -1055 -1057 -1058 -1059 -1060 -1061 -1062 -1063 -1064 -1065 -1066 -1067 -1068 -1069 -1070 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/notify_on_release deleted file mode 100644 index 573541ac9702..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/notify_on_release +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/tasks deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/notify_on_release deleted file mode 100644 index 573541ac9702..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/notify_on_release +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/release_agent b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/release_agent deleted file mode 100644 index 8b137891791f..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/release_agent +++ /dev/null @@ -1 +0,0 @@ - diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/tasks deleted file mode 100644 index 27537f94a4b3..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/tasks +++ /dev/null @@ -1,158 +0,0 @@ -1 -2 -3 -5 -7 -8 -9 -10 -11 -13 -14 -15 -16 -18 -19 -20 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -40 -41 -42 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -123 -124 -151 -152 -155 -156 -157 -158 -171 -202 -272 -322 -323 -388 -519 -574 -575 -576 -620 -648 -659 -734 -748 -750 -752 -753 -754 -755 -756 -771 -772 -773 -777 -778 -795 -797 -798 -799 -809 -816 -840 -885 -886 -887 -909 -911 -912 -969 -975 -976 -977 -978 -979 -989 -1056 -1154 -1161 -1293 -1294 -1296 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/cgroup.clone_children b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/cgroup.clone_children deleted file mode 100644 index 573541ac9702..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/cgroup.clone_children +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/cgroup.sane_behavior b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/cgroup.sane_behavior deleted file mode 100644 index 573541ac9702..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/cgroup.sane_behavior +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release deleted file mode 100644 index 573541ac9702..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks deleted file mode 100644 index 16ae34357356..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks +++ /dev/null @@ -1,37 +0,0 @@ -985 -1006 -1007 -1008 -1009 -1010 -1011 -1012 -1013 -1014 -1015 -1016 -1017 -1018 -1019 -1020 -1021 -1048 -1049 -1052 -1053 -1054 -1055 -1057 -1058 -1059 -1060 -1061 -1062 -1063 -1064 -1065 -1066 -1067 -1068 -1069 -1070 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/notify_on_release deleted file mode 100644 index 573541ac9702..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/notify_on_release +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/tasks deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/notify_on_release deleted file mode 100644 index 573541ac9702..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/notify_on_release +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/release_agent b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/release_agent deleted file mode 100644 index 8b137891791f..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/release_agent +++ /dev/null @@ -1 +0,0 @@ - diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/tasks deleted file mode 100644 index 27537f94a4b3..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/tasks +++ /dev/null @@ -1,158 +0,0 @@ -1 -2 -3 -5 -7 -8 -9 -10 -11 -13 -14 -15 -16 -18 -19 -20 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -40 -41 -42 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -123 -124 -151 -152 -155 -156 -157 -158 -171 -202 -272 -322 -323 -388 -519 -574 -575 -576 -620 -648 -659 -734 -748 -750 -752 -753 -754 -755 -756 -771 -772 -773 -777 -778 -795 -797 -798 -799 -809 -816 -840 -885 -886 -887 -909 -911 -912 -969 -975 -976 -977 -978 -979 -989 -1056 -1154 -1161 -1293 -1294 -1296 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/cgroup.sane_behavior b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/cgroup.sane_behavior deleted file mode 100644 index 573541ac9702..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/cgroup.sane_behavior +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release deleted file mode 100644 index 573541ac9702..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks deleted file mode 100644 index 16ae34357356..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks +++ /dev/null @@ -1,37 +0,0 @@ -985 -1006 -1007 -1008 -1009 -1010 -1011 -1012 -1013 -1014 -1015 -1016 -1017 -1018 -1019 -1020 -1021 -1048 -1049 -1052 -1053 -1054 -1055 -1057 -1058 -1059 -1060 -1061 -1062 -1063 -1064 -1065 -1066 -1067 -1068 -1069 -1070 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/notify_on_release deleted file mode 100644 index 573541ac9702..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/notify_on_release +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/tasks deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/notify_on_release deleted file mode 100644 index 573541ac9702..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/notify_on_release +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/release_agent b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/release_agent deleted file mode 100644 index 8b137891791f..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/release_agent +++ /dev/null @@ -1 +0,0 @@ - diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/tasks deleted file mode 100644 index 27537f94a4b3..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/tasks +++ /dev/null @@ -1,158 +0,0 @@ -1 -2 -3 -5 -7 -8 -9 -10 -11 -13 -14 -15 -16 -18 -19 -20 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -40 -41 -42 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -123 -124 -151 -152 -155 -156 -157 -158 -171 -202 -272 -322 -323 -388 -519 -574 -575 -576 -620 -648 -659 -734 -748 -750 -752 -753 -754 -755 -756 -771 -772 -773 -777 -778 -795 -797 -798 -799 -809 -816 -840 -885 -886 -887 -909 -911 -912 -969 -975 -976 -977 -978 -979 -989 -1056 -1154 -1161 -1293 -1294 -1296 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/cgroup.clone_children b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/cgroup.clone_children deleted file mode 100644 index 573541ac9702..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/cgroup.clone_children +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/cgroup.event_control b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/cgroup.event_control deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/cgroup.sane_behavior b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/cgroup.sane_behavior deleted file mode 100644 index 573541ac9702..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/cgroup.sane_behavior +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release deleted file mode 100644 index 573541ac9702..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks deleted file mode 100644 index 16ae34357356..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks +++ /dev/null @@ -1,37 +0,0 @@ -985 -1006 -1007 -1008 -1009 -1010 -1011 -1012 -1013 -1014 -1015 -1016 -1017 -1018 -1019 -1020 -1021 -1048 -1049 -1052 -1053 -1054 -1055 -1057 -1058 -1059 -1060 -1061 -1062 -1063 -1064 -1065 -1066 -1067 -1068 -1069 -1070 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/notify_on_release deleted file mode 100644 index 573541ac9702..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/notify_on_release +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/tasks deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/memory.force_empty b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/memory.force_empty deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/memory.move_charge_at_immigrate b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/memory.move_charge_at_immigrate deleted file mode 100644 index 573541ac9702..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/memory.move_charge_at_immigrate +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/memory.use_hierarchy b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/memory.use_hierarchy deleted file mode 100644 index 573541ac9702..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/memory.use_hierarchy +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/notify_on_release deleted file mode 100644 index 573541ac9702..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/notify_on_release +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/release_agent b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/release_agent deleted file mode 100644 index 8b137891791f..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/release_agent +++ /dev/null @@ -1 +0,0 @@ - diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/tasks deleted file mode 100644 index 27537f94a4b3..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/tasks +++ /dev/null @@ -1,158 +0,0 @@ -1 -2 -3 -5 -7 -8 -9 -10 -11 -13 -14 -15 -16 -18 -19 -20 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -40 -41 -42 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -123 -124 -151 -152 -155 -156 -157 -158 -171 -202 -272 -322 -323 -388 -519 -574 -575 -576 -620 -648 -659 -734 -748 -750 -752 -753 -754 -755 -756 -771 -772 -773 -777 -778 -795 -797 -798 -799 -809 -816 -840 -885 -886 -887 -909 -911 -912 -969 -975 -976 -977 -978 -979 -989 -1056 -1154 -1161 -1293 -1294 -1296 From d65971228695cdf4ee2dbadbb6c339458700c5c6 Mon Sep 17 00:00:00 2001 From: Tetiana Kravchenko Date: Tue, 18 Apr 2023 17:56:56 +0200 Subject: [PATCH 04/24] move tagDescribe to different func Signed-off-by: Tetiana Kravchenko --- .../add_cloud_metadata/provider_aws_ec2.go | 59 +-- .../provider_aws_ec2_test.go | 384 +++++++++++------- 2 files changed, 266 insertions(+), 177 deletions(-) diff --git a/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go b/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go index c10f8adabfc2..cd269f6fbdb5 100644 --- a/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go +++ b/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go @@ -19,6 +19,7 @@ package add_cloud_metadata import ( "context" + "fmt" "net/http" awssdk "github.com/aws/aws-sdk-go-v2/aws" @@ -32,15 +33,6 @@ import ( conf "github.com/elastic/elastic-agent-libs/config" ) -// TODO: adjust tests and delete consts: -const ( - ec2InstanceIdentityURI = "/2014-02-25/dynamic/instance-identity/document" - ec2InstanceIMDSv2TokenValueHeader = "X-aws-ec2-metadata-token" - ec2InstanceIMDSv2TokenTTLHeader = "X-aws-ec2-metadata-token-ttl-seconds" - ec2InstanceIMDSv2TokenTTLValue = "21600" - ec2InstanceIMDSv2TokenURI = "/latest/api/token" -) - // AWS EC2 Metadata Service var ec2MetadataFetcher = provider{ Name: "aws-ec2", @@ -67,12 +59,8 @@ func fetchRawProviderMetadata( result *result, ) { logger := logp.NewLogger("add_cloud_metadata") - // config := defaultConfig() - // if err := c.Unpack(&config); err != nil { - // logger.Warnf("error when load config for getting IMDSv2 token: %s. No token in the metadata request will be used.", err) - // } - // LoadDefaultConfig loads the Ec2 role credentials + // LoadDefaultConfig loads the EC2 role credentials awsConfig, err := awscfg.LoadDefaultConfig(context.TODO(), awscfg.WithHTTPClient(&client)) if err != nil { logger.Debugf("error loading AWS default configuration: %s.", err) @@ -86,23 +74,48 @@ func fetchRawProviderMetadata( logger.Warnf("error fetching EC2 Identity Document: %s.", err) } - // Region must be set to be able to get EC2 Tags + // AWS Region must be set to be able to get EC2 Tags awsRegion := instanceIdentity.InstanceIdentityDocument.Region awsConfig.Region = awsRegion + clusterName, err := fetchEC2ClusterNameTag(awsConfig, instanceIdentity.InstanceIdentityDocument.InstanceID) + if err != nil { + logger.Debugf("error fetching cluster name metadata: %s.", err) + } + + accountID := instanceIdentity.InstanceIdentityDocument.AccountID + + // for AWS cluster ID is used cluster ARN: arn:partition:service:region:account-id:resource-type/resource-id, example: + // arn:aws:eks:us-east-2:627286350134:cluster/cluster-name + if *clusterName != "" { + clusterARN := fmt.Sprintf("arn:aws:eks:%s:%s:cluster/%s", awsRegion, accountID, *clusterName) + + result.metadata.Put("cloud.orchestrator.cluster.name", clusterName) + result.metadata.Put("cloud.orchestrator.cluster.id", clusterARN) + } + + result.metadata.Put("cloud.instance.id", instanceIdentity.InstanceIdentityDocument.InstanceID) + result.metadata.Put("cloud.machine.type", instanceIdentity.InstanceIdentityDocument.InstanceType) + result.metadata.Put("cloud.region", awsRegion) + result.metadata.Put("cloud.availability_zone", instanceIdentity.InstanceIdentityDocument.AvailabilityZone) + result.metadata.Put("cloud.account.id", accountID) + result.metadata.Put("cloud.image.id", instanceIdentity.InstanceIdentityDocument.ImageID) +} + +func fetchEC2ClusterNameTag(awsConfig awssdk.Config, instanceID string) (*string, error) { svc := ec2.NewFromConfig(awsConfig) input := &ec2.DescribeTagsInput{ Filters: []types.Filter{ { Name: awssdk.String("resource-id"), Values: []string{ - *awssdk.String(instanceIdentity.InstanceIdentityDocument.InstanceID), + instanceID, }, }, { Name: awssdk.String("key"), Values: []string{ - *awssdk.String("eks:cluster-name"), + "eks:cluster-name", }, }, }, @@ -110,15 +123,7 @@ func fetchRawProviderMetadata( tagsResult, err := svc.DescribeTags(context.TODO(), input) if err != nil { - logger.Warnf("error fetching EC2 Tags: %s.", err) + return nil, fmt.Errorf("error fetching EC2 Tags: %s", err) } - - result.metadata.Put("cloud.orchestrator.cluster.name", tagsResult.Tags[0].Value) - result.metadata.Put("cloud.instance.id", instanceIdentity.InstanceIdentityDocument.InstanceID) - result.metadata.Put("cloud.machine.type", instanceIdentity.InstanceIdentityDocument.InstanceType) - result.metadata.Put("cloud.region", awsRegion) - result.metadata.Put("cloud.availability_zone", instanceIdentity.InstanceIdentityDocument.AvailabilityZone) - result.metadata.Put("cloud.account.id", instanceIdentity.InstanceIdentityDocument.AccountID) - result.metadata.Put("cloud.image.id", instanceIdentity.InstanceIdentityDocument.ImageID) - + return tagsResult.Tags[0].Value, nil } diff --git a/libbeat/processors/add_cloud_metadata/provider_aws_ec2_test.go b/libbeat/processors/add_cloud_metadata/provider_aws_ec2_test.go index b167917a97b0..5a88494fee24 100644 --- a/libbeat/processors/add_cloud_metadata/provider_aws_ec2_test.go +++ b/libbeat/processors/add_cloud_metadata/provider_aws_ec2_test.go @@ -18,21 +18,42 @@ package add_cloud_metadata import ( - "fmt" + "context" "net/http" "net/http/httptest" "os" "testing" + "github.com/aws/aws-sdk-go-v2/feature/ec2/imds" + "github.com/aws/aws-sdk-go-v2/service/ec2" "github.com/stretchr/testify/assert" "github.com/elastic/beats/v7/libbeat/beat" + "github.com/elastic/beats/v7/x-pack/metricbeat/module/aws" conf "github.com/elastic/elastic-agent-libs/config" "github.com/elastic/elastic-agent-libs/logp" "github.com/elastic/elastic-agent-libs/mapstr" ) -func createEC2MockAPI(responseMap map[string]string) *httptest.Server { +type MockIMDSClient struct { + imds.Client + GetInstanceIdentityDocumentFunc func(ctx context.Context, params *imds.GetInstanceIdentityDocumentInput, optFns ...func(*imds.Options)) (*imds.GetInstanceIdentityDocumentOutput, error) +} + +type MockEC2Client struct { + ec2.Client + DescribeTagsFunc func(ctx context.Context, params *ec2.DescribeTagsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeTagsOutput, error) +} + +func (m *MockIMDSClient) GetInstanceIdentityDocument(ctx context.Context, params *imds.GetInstanceIdentityDocumentInput, optFns ...func(*imds.Options)) (*imds.GetInstanceIdentityDocumentOutput, error) { + return m.GetInstanceIdentityDocumentFunc(ctx, params, optFns...) +} + +func (e *MockEC2Client) DescribeTags(ctx context.Context, params *ec2.DescribeTagsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeTagsOutput, error) { + return e.DescribeTagsFunc(ctx, params, optFns...) +} + +func createIMDSMockAPI(responseMap map[string]string) *httptest.Server { h := func(w http.ResponseWriter, r *http.Request) { if res, ok := responseMap[r.RequestURI]; ok { w.Write([]byte(res)) @@ -62,48 +83,59 @@ func TestRetrieveAWSMetadataEC2(t *testing.T) { instanceIDDoc1 = "i-11111111" imageIDDoc1 = "ami-abcd1234" instanceTypeDoc1 = "t2.medium" + clusterNameDoc1 = "test" instanceIDDoc2 = "i-22222222" - templateDoc = `{ - "accountId" : "%s", - "region" : "%s", - "availabilityZone" : "%s", - "instanceId" : "%s", - "imageId" : "%s", - "instanceType" : "%s", - "devpayProductCodes" : null, - "privateIp" : "10.0.0.1", - "version" : "2010-08-31", - "billingProducts" : null, - "pendingTime" : "2016-09-20T15:43:02Z", - "architecture" : "x86_64", - "kernelId" : null, - "ramdiskId" : null - }` - ) + // templateDoc = `{ + // "accountId" : "%s", + // "region" : "%s", + // "availabilityZone" : "%s", + // "instanceId" : "%s", + // "imageId" : "%s", + // "instanceType" : "%s", + // "devpayProductCodes" : null, + // "privateIp" : "10.0.0.1", + // "version" : "2010-08-31", + // "billingProducts" : null, + // "pendingTime" : "2016-09-20T15:43:02Z", + // "architecture" : "x86_64", + // "kernelId" : null, + // "ramdiskId" : null + // }` + // ) - sampleEC2Doc1 := fmt.Sprintf( - templateDoc, - accountIDDoc1, - regionDoc1, - availabilityZoneDoc1, - instanceIDDoc1, - imageIDDoc1, - instanceTypeDoc1, + // sampleEC2Doc1 := fmt.Sprintf( + // templateDoc, + // accountIDDoc1, + // regionDoc1, + // availabilityZoneDoc1, + // instanceIDDoc1, + // imageIDDoc1, + // instanceTypeDoc1, ) - var testCases = []struct { - testName string - ec2ResponseMap map[string]string - processorOverwrite bool - previousEvent mapstr.M - - expectedEvent mapstr.M + var tests = []struct { + testName string + mockGetInstanceIdentityDocumentFunc func(ctx context.Context, params *imds.GetInstanceIdentityDocumentInput, optFns ...func(*imds.Options)) (*imds.GetInstanceIdentityDocumentOutput, error) + processorOverwrite bool + previousEvent mapstr.M + expectedEvent mapstr.M }{ { - testName: "all fields from processor", - ec2ResponseMap: map[string]string{ec2InstanceIdentityURI: sampleEC2Doc1}, + testName: "valid instance identity document", + mockGetInstanceIdentityDocumentFunc: func(ctx context.Context, params *imds.GetInstanceIdentityDocumentInput, optFns ...func(*imds.Options)) (*imds.GetInstanceIdentityDocumentOutput, error) { + return &imds.GetInstanceIdentityDocumentOutput{ + InstanceIdentityDocument: imds.InstanceIdentityDocument{ + AvailabilityZone: availabilityZoneDoc1, + Region: regionDoc1, + InstanceID: instanceIDDoc1, + InstanceType: instanceTypeDoc1, + AccountID: accountIDDoc1, + ImageID: imageIDDoc1, + }, + }, nil + }, processorOverwrite: false, previousEvent: mapstr.M{}, expectedEvent: mapstr.M{ @@ -118,142 +150,194 @@ func TestRetrieveAWSMetadataEC2(t *testing.T) { "service": mapstr.M{ "name": "EC2", }, + // "orchestrator": mapstr.M{ + // "cluster": mapstr.M{ + // "name": clusterNameDoc1, + // "id": fmt.Sprintf("arn:aws:eks:%s:%s:cluster/%s", regionDoc1, accountIDDoc1, clusterNameDoc1), + // }, + // }, }, }, }, + } - { - testName: "instanceId pre-informed, no overwrite", - ec2ResponseMap: map[string]string{ec2InstanceIdentityURI: sampleEC2Doc1}, - processorOverwrite: false, - previousEvent: mapstr.M{ - "cloud": mapstr.M{ - "instance": mapstr.M{"id": instanceIDDoc2}, - }, - }, - expectedEvent: mapstr.M{ - "cloud": mapstr.M{ - "instance": mapstr.M{"id": instanceIDDoc2}, - }, - }, - }, + // var testCases = []struct { + // testName string + // ec2ResponseMap map[string]string + // processorOverwrite bool + // previousEvent mapstr.M - { - // NOTE: In this case, add_cloud_metadata will overwrite cloud fields because - // it won't detect cloud.provider as a cloud field. This is not the behavior we - // expect and will find a better solution later in issue 11697. - testName: "only cloud.provider pre-informed, no overwrite", - ec2ResponseMap: map[string]string{ec2InstanceIdentityURI: sampleEC2Doc1}, - processorOverwrite: false, - previousEvent: mapstr.M{ - "cloud.provider": "aws", - }, - expectedEvent: mapstr.M{ - "cloud.provider": "aws", - "cloud": mapstr.M{ - "provider": "aws", - "account": mapstr.M{"id": accountIDDoc1}, - "instance": mapstr.M{"id": instanceIDDoc1}, - "machine": mapstr.M{"type": instanceTypeDoc1}, - "image": mapstr.M{"id": imageIDDoc1}, - "region": regionDoc1, - "availability_zone": availabilityZoneDoc1, - "service": mapstr.M{ - "name": "EC2", - }, - }, - }, - }, + // expectedEvent mapstr.M + // }{ + // // { + // // testName: "all fields from processor", + // // ec2ResponseMap: map[string]string{ec2InstanceIdentityURI: sampleEC2Doc1}, + // // processorOverwrite: false, + // // previousEvent: mapstr.M{}, + // // expectedEvent: mapstr.M{ + // // "cloud": mapstr.M{ + // // "provider": "aws", + // // "account": mapstr.M{"id": accountIDDoc1}, + // // "instance": mapstr.M{"id": instanceIDDoc1}, + // // "machine": mapstr.M{"type": instanceTypeDoc1}, + // // "image": mapstr.M{"id": imageIDDoc1}, + // // "region": regionDoc1, + // // "availability_zone": availabilityZoneDoc1, + // // "service": mapstr.M{ + // // "name": "EC2", + // // }, + // // "orchestrator": mapstr.M{ + // // "cluster": mapstr.M{ + // // "name": clusterNameDoc1, + // // "id": fmt.Sprintf("arn:aws:eks:%s:%s:cluster/%s", regionDoc1, accountIDDoc1, clusterNameDoc1), + // // }, + // // }, + // // }, + // // }, + // // }, - { - testName: "all fields from processor, overwrite", - ec2ResponseMap: map[string]string{ec2InstanceIdentityURI: sampleEC2Doc1}, - processorOverwrite: true, - previousEvent: mapstr.M{}, - expectedEvent: mapstr.M{ - "cloud": mapstr.M{ - "provider": "aws", - "account": mapstr.M{"id": accountIDDoc1}, - "instance": mapstr.M{"id": instanceIDDoc1}, - "machine": mapstr.M{"type": instanceTypeDoc1}, - "image": mapstr.M{"id": imageIDDoc1}, - "region": regionDoc1, - "availability_zone": availabilityZoneDoc1, - "service": mapstr.M{ - "name": "EC2", - }, - }, - }, - }, + // // { + // // testName: "instanceId pre-informed, no overwrite", + // // ec2ResponseMap: map[string]string{ec2InstanceIdentityURI: sampleEC2Doc1}, + // // processorOverwrite: false, + // // previousEvent: mapstr.M{ + // // "cloud": mapstr.M{ + // // "instance": mapstr.M{"id": instanceIDDoc2}, + // // }, + // // }, + // // expectedEvent: mapstr.M{ + // // "cloud": mapstr.M{ + // // "instance": mapstr.M{"id": instanceIDDoc2}, + // // }, + // // }, + // // }, - { - testName: "instanceId pre-informed, overwrite", - ec2ResponseMap: map[string]string{ec2InstanceIdentityURI: sampleEC2Doc1}, - processorOverwrite: true, - previousEvent: mapstr.M{ - "cloud": mapstr.M{ - "instance": mapstr.M{"id": instanceIDDoc2}, - }, - }, - expectedEvent: mapstr.M{ - "cloud": mapstr.M{ - "provider": "aws", - "account": mapstr.M{"id": accountIDDoc1}, - "instance": mapstr.M{"id": instanceIDDoc1}, - "machine": mapstr.M{"type": instanceTypeDoc1}, - "image": mapstr.M{"id": imageIDDoc1}, - "region": regionDoc1, - "availability_zone": availabilityZoneDoc1, - "service": mapstr.M{ - "name": "EC2", - }, - }, - }, - }, + // // { + // // // NOTE: In this case, add_cloud_metadata will overwrite cloud fields because + // // // it won't detect cloud.provider as a cloud field. This is not the behavior we + // // // expect and will find a better solution later in issue 11697. + // // testName: "only cloud.provider pre-informed, no overwrite", + // // ec2ResponseMap: map[string]string{ec2InstanceIdentityURI: sampleEC2Doc1}, + // // processorOverwrite: false, + // // previousEvent: mapstr.M{ + // // "cloud.provider": "aws", + // // }, + // // expectedEvent: mapstr.M{ + // // "cloud.provider": "aws", + // // "cloud": mapstr.M{ + // // "provider": "aws", + // // "account": mapstr.M{"id": accountIDDoc1}, + // // "instance": mapstr.M{"id": instanceIDDoc1}, + // // "machine": mapstr.M{"type": instanceTypeDoc1}, + // // "image": mapstr.M{"id": imageIDDoc1}, + // // "region": regionDoc1, + // // "availability_zone": availabilityZoneDoc1, + // // "service": mapstr.M{ + // // "name": "EC2", + // // }, + // // }, + // // }, + // // }, - { - testName: "only cloud.provider pre-informed, overwrite", - ec2ResponseMap: map[string]string{ec2InstanceIdentityURI: sampleEC2Doc1}, - processorOverwrite: false, - previousEvent: mapstr.M{ - "cloud.provider": "aws", - }, - expectedEvent: mapstr.M{ - "cloud.provider": "aws", - "cloud": mapstr.M{ - "provider": "aws", - "account": mapstr.M{"id": accountIDDoc1}, - "instance": mapstr.M{"id": instanceIDDoc1}, - "machine": mapstr.M{"type": instanceTypeDoc1}, - "image": mapstr.M{"id": imageIDDoc1}, - "region": regionDoc1, - "availability_zone": availabilityZoneDoc1, - "service": mapstr.M{ - "name": "EC2", - }, - }, - }, - }, - } + // // { + // // testName: "all fields from processor, overwrite", + // // ec2ResponseMap: map[string]string{ec2InstanceIdentityURI: sampleEC2Doc1}, + // // processorOverwrite: true, + // // previousEvent: mapstr.M{}, + // // expectedEvent: mapstr.M{ + // // "cloud": mapstr.M{ + // // "provider": "aws", + // // "account": mapstr.M{"id": accountIDDoc1}, + // // "instance": mapstr.M{"id": instanceIDDoc1}, + // // "machine": mapstr.M{"type": instanceTypeDoc1}, + // // "image": mapstr.M{"id": imageIDDoc1}, + // // "region": regionDoc1, + // // "availability_zone": availabilityZoneDoc1, + // // "service": mapstr.M{ + // // "name": "EC2", + // // }, + // // }, + // // }, + // // }, + + // // { + // // testName: "instanceId pre-informed, overwrite", + // // ec2ResponseMap: map[string]string{ec2InstanceIdentityURI: sampleEC2Doc1}, + // // processorOverwrite: true, + // // previousEvent: mapstr.M{ + // // "cloud": mapstr.M{ + // // "instance": mapstr.M{"id": instanceIDDoc2}, + // // }, + // // }, + // // expectedEvent: mapstr.M{ + // // "cloud": mapstr.M{ + // // "provider": "aws", + // // "account": mapstr.M{"id": accountIDDoc1}, + // // "instance": mapstr.M{"id": instanceIDDoc1}, + // // "machine": mapstr.M{"type": instanceTypeDoc1}, + // // "image": mapstr.M{"id": imageIDDoc1}, + // // "region": regionDoc1, + // // "availability_zone": availabilityZoneDoc1, + // // "service": mapstr.M{ + // // "name": "EC2", + // // }, + // // }, + // // }, + // // }, + + // // { + // // testName: "only cloud.provider pre-informed, overwrite", + // // ec2ResponseMap: map[string]string{ec2InstanceIdentityURI: sampleEC2Doc1}, + // // processorOverwrite: false, + // // previousEvent: mapstr.M{ + // // "cloud.provider": "aws", + // // }, + // // expectedEvent: mapstr.M{ + // // "cloud.provider": "aws", + // // "cloud": mapstr.M{ + // // "provider": "aws", + // // "account": mapstr.M{"id": accountIDDoc1}, + // // "instance": mapstr.M{"id": instanceIDDoc1}, + // // "machine": mapstr.M{"type": instanceTypeDoc1}, + // // "image": mapstr.M{"id": imageIDDoc1}, + // // "region": regionDoc1, + // // "availability_zone": availabilityZoneDoc1, + // // "service": mapstr.M{ + // // "name": "EC2", + // // }, + // // }, + // // }, + // // }, + // } - for _, tc := range testCases { + for _, tc := range tests { t.Run(tc.testName, func(t *testing.T) { - server := createEC2MockAPI(tc.ec2ResponseMap) - defer server.Close() + + mockClient := &MockIMDSClient{ + GetInstanceIdentityDocumentFunc: tc.mockGetInstanceIdentityDocumentFunc, + } + + oldNewFromConfig := imds.NewFromConfig + imds.NewFromConfig = func(cfg aws.Config, optFns ...func(*imds.Options)) *imds.Client { + return (*imds.Client)(mockClient) + } + defer func() { imds.NewFromConfig = oldNewFromConfig }() config, err := conf.NewConfigFrom(map[string]interface{}{ - "host": server.Listener.Addr().String(), "overwrite": tc.processorOverwrite, }) if err != nil { t.Fatalf("error creating config from map: %s", err.Error()) } - cmp, err := New(config) if err != nil { t.Fatalf("error creating new metadata processor: %s", err.Error()) } + // client := http.Client{} + // res := result{provider: "ec2", metadata: mapstr.M{}} + // fetchRawProviderMetadata(context.Background(), client, &res) + actual, err := cmp.Run(&beat.Event{Fields: tc.previousEvent}) if err != nil { t.Fatalf("error running processor: %s", err.Error()) From 737f3d3e23a63b4723b2078f01b1c17292df7a02 Mon Sep 17 00:00:00 2001 From: Tetiana Kravchenko Date: Mon, 24 Apr 2023 09:38:51 +0200 Subject: [PATCH 05/24] add tests for add_cloud_metadata Signed-off-by: Tetiana Kravchenko --- .../add_cloud_metadata/generic_fetcher.go | 5 +- .../add_cloud_metadata/provider_aws_ec2.go | 52 ++-- .../provider_aws_ec2_test.go | 227 ++++++++---------- 3 files changed, 140 insertions(+), 144 deletions(-) diff --git a/libbeat/processors/add_cloud_metadata/generic_fetcher.go b/libbeat/processors/add_cloud_metadata/generic_fetcher.go index 9e41422319ef..4467c1e49030 100644 --- a/libbeat/processors/add_cloud_metadata/generic_fetcher.go +++ b/libbeat/processors/add_cloud_metadata/generic_fetcher.go @@ -19,7 +19,6 @@ package add_cloud_metadata import ( "context" - "fmt" "net/http" cfg "github.com/elastic/elastic-agent-libs/config" @@ -28,7 +27,7 @@ import ( type genericFetcher struct { provider string - conv schemaConv + schema schemaConv fetchRawProviderMetadata func(context.Context, http.Client, *result) } @@ -49,7 +48,7 @@ func (g *genericFetcher) fetchMetadata(ctx context.Context, client http.Client) if res.err != nil { return res } - fmt.Printf("res: %s", res) + res.metadata = g.schema(res.metadata) res.metadata.Put("cloud.provider", g.provider) return res diff --git a/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go b/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go index cd269f6fbdb5..e92b08e89228 100644 --- a/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go +++ b/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go @@ -33,6 +33,22 @@ import ( conf "github.com/elastic/elastic-agent-libs/config" ) +type IMDSClient interface { + GetInstanceIdentityDocument(ctx context.Context, params *imds.GetInstanceIdentityDocumentInput, optFns ...func(*imds.Options)) (*imds.GetInstanceIdentityDocumentOutput, error) +} + +var NewIMDSClient func(cfg awssdk.Config) IMDSClient = func(cfg awssdk.Config) IMDSClient { + return imds.NewFromConfig(cfg) +} + +type EC2Client interface { + DescribeTags(ctx context.Context, params *ec2.DescribeTagsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeTagsOutput, error) +} + +var NewEC2Client func(cfg awssdk.Config) EC2Client = func(cfg awssdk.Config) EC2Client { + return ec2.NewFromConfig(cfg) +} + // AWS EC2 Metadata Service var ec2MetadataFetcher = provider{ Name: "aws-ec2", @@ -66,8 +82,7 @@ func fetchRawProviderMetadata( logger.Debugf("error loading AWS default configuration: %s.", err) return } - - awsClient := imds.NewFromConfig(awsConfig) + awsClient := NewIMDSClient(awsConfig) instanceIdentity, err := awsClient.GetInstanceIdentityDocument(context.TODO(), &imds.GetInstanceIdentityDocumentInput{}) if err != nil { @@ -85,25 +100,25 @@ func fetchRawProviderMetadata( accountID := instanceIdentity.InstanceIdentityDocument.AccountID + result.metadata.Put("instance.id", instanceIdentity.InstanceIdentityDocument.InstanceID) + result.metadata.Put("machine.type", instanceIdentity.InstanceIdentityDocument.InstanceType) + result.metadata.Put("region", awsRegion) + result.metadata.Put("availability_zone", instanceIdentity.InstanceIdentityDocument.AvailabilityZone) + result.metadata.Put("account.id", accountID) + result.metadata.Put("image.id", instanceIdentity.InstanceIdentityDocument.ImageID) + // for AWS cluster ID is used cluster ARN: arn:partition:service:region:account-id:resource-type/resource-id, example: // arn:aws:eks:us-east-2:627286350134:cluster/cluster-name - if *clusterName != "" { - clusterARN := fmt.Sprintf("arn:aws:eks:%s:%s:cluster/%s", awsRegion, accountID, *clusterName) + if clusterName != "" { + clusterARN := fmt.Sprintf("arn:aws:eks:%s:%s:cluster/%v", awsRegion, accountID, clusterName) - result.metadata.Put("cloud.orchestrator.cluster.name", clusterName) - result.metadata.Put("cloud.orchestrator.cluster.id", clusterARN) + result.metadata.Put("orchestrator.cluster.name", clusterName) + result.metadata.Put("orchestrator.cluster.id", clusterARN) } - - result.metadata.Put("cloud.instance.id", instanceIdentity.InstanceIdentityDocument.InstanceID) - result.metadata.Put("cloud.machine.type", instanceIdentity.InstanceIdentityDocument.InstanceType) - result.metadata.Put("cloud.region", awsRegion) - result.metadata.Put("cloud.availability_zone", instanceIdentity.InstanceIdentityDocument.AvailabilityZone) - result.metadata.Put("cloud.account.id", accountID) - result.metadata.Put("cloud.image.id", instanceIdentity.InstanceIdentityDocument.ImageID) } -func fetchEC2ClusterNameTag(awsConfig awssdk.Config, instanceID string) (*string, error) { - svc := ec2.NewFromConfig(awsConfig) +func fetchEC2ClusterNameTag(awsConfig awssdk.Config, instanceID string) (string, error) { + svc := NewEC2Client(awsConfig) input := &ec2.DescribeTagsInput{ Filters: []types.Filter{ { @@ -123,7 +138,10 @@ func fetchEC2ClusterNameTag(awsConfig awssdk.Config, instanceID string) (*string tagsResult, err := svc.DescribeTags(context.TODO(), input) if err != nil { - return nil, fmt.Errorf("error fetching EC2 Tags: %s", err) + return "", fmt.Errorf("error fetching EC2 Tags: %s", err) + } + if len(tagsResult.Tags) > 0 { + return *tagsResult.Tags[0].Value, nil } - return tagsResult.Tags[0].Value, nil + return "", nil } diff --git a/libbeat/processors/add_cloud_metadata/provider_aws_ec2_test.go b/libbeat/processors/add_cloud_metadata/provider_aws_ec2_test.go index 5a88494fee24..426909de2255 100644 --- a/libbeat/processors/add_cloud_metadata/provider_aws_ec2_test.go +++ b/libbeat/processors/add_cloud_metadata/provider_aws_ec2_test.go @@ -19,56 +19,42 @@ package add_cloud_metadata import ( "context" - "net/http" - "net/http/httptest" + "fmt" "os" "testing" + awssdk "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/feature/ec2/imds" "github.com/aws/aws-sdk-go-v2/service/ec2" + "github.com/aws/aws-sdk-go-v2/service/ec2/types" "github.com/stretchr/testify/assert" "github.com/elastic/beats/v7/libbeat/beat" - "github.com/elastic/beats/v7/x-pack/metricbeat/module/aws" conf "github.com/elastic/elastic-agent-libs/config" "github.com/elastic/elastic-agent-libs/logp" "github.com/elastic/elastic-agent-libs/mapstr" ) type MockIMDSClient struct { - imds.Client GetInstanceIdentityDocumentFunc func(ctx context.Context, params *imds.GetInstanceIdentityDocumentInput, optFns ...func(*imds.Options)) (*imds.GetInstanceIdentityDocumentOutput, error) } -type MockEC2Client struct { - ec2.Client - DescribeTagsFunc func(ctx context.Context, params *ec2.DescribeTagsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeTagsOutput, error) -} - func (m *MockIMDSClient) GetInstanceIdentityDocument(ctx context.Context, params *imds.GetInstanceIdentityDocumentInput, optFns ...func(*imds.Options)) (*imds.GetInstanceIdentityDocumentOutput, error) { return m.GetInstanceIdentityDocumentFunc(ctx, params, optFns...) } -func (e *MockEC2Client) DescribeTags(ctx context.Context, params *ec2.DescribeTagsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeTagsOutput, error) { - return e.DescribeTagsFunc(ctx, params, optFns...) +type MockEC2Client struct { + DescribeTagsFunc func(ctx context.Context, params *ec2.DescribeTagsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeTagsOutput, error) } -func createIMDSMockAPI(responseMap map[string]string) *httptest.Server { - h := func(w http.ResponseWriter, r *http.Request) { - if res, ok := responseMap[r.RequestURI]; ok { - w.Write([]byte(res)) - return - } - http.Error(w, "not found", http.StatusNotFound) - } - return httptest.NewServer(http.HandlerFunc(h)) +func (e *MockEC2Client) DescribeTags(ctx context.Context, params *ec2.DescribeTagsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeTagsOutput, error) { + return e.DescribeTagsFunc(ctx, params, optFns...) } func TestMain(m *testing.M) { logp.TestingSetup() code := m.Run() os.Exit(code) - } func TestRetrieveAWSMetadataEC2(t *testing.T) { @@ -80,51 +66,28 @@ func TestRetrieveAWSMetadataEC2(t *testing.T) { accountIDDoc1 = "111111111111111" regionDoc1 = "us-east-1" availabilityZoneDoc1 = "us-east-1c" - instanceIDDoc1 = "i-11111111" imageIDDoc1 = "ami-abcd1234" instanceTypeDoc1 = "t2.medium" - clusterNameDoc1 = "test" - - instanceIDDoc2 = "i-22222222" - - // templateDoc = `{ - // "accountId" : "%s", - // "region" : "%s", - // "availabilityZone" : "%s", - // "instanceId" : "%s", - // "imageId" : "%s", - // "instanceType" : "%s", - // "devpayProductCodes" : null, - // "privateIp" : "10.0.0.1", - // "version" : "2010-08-31", - // "billingProducts" : null, - // "pendingTime" : "2016-09-20T15:43:02Z", - // "architecture" : "x86_64", - // "kernelId" : null, - // "ramdiskId" : null - // }` - // ) - - // sampleEC2Doc1 := fmt.Sprintf( - // templateDoc, - // accountIDDoc1, - // regionDoc1, - // availabilityZoneDoc1, - // instanceIDDoc1, - // imageIDDoc1, - // instanceTypeDoc1, + instanceIDDoc2 = "i-22222222" + ) + var ( + clusterNameKey string = "eks:cluster-name" + clusterNameValue string = "test" + instanceIDKey string = "resource-id" + instanceIDDoc1 string = "i-11111111" ) var tests = []struct { - testName string - mockGetInstanceIdentityDocumentFunc func(ctx context.Context, params *imds.GetInstanceIdentityDocumentInput, optFns ...func(*imds.Options)) (*imds.GetInstanceIdentityDocumentOutput, error) - processorOverwrite bool - previousEvent mapstr.M - expectedEvent mapstr.M + testName string + mockGetInstanceIdentity func(ctx context.Context, params *imds.GetInstanceIdentityDocumentInput, optFns ...func(*imds.Options)) (*imds.GetInstanceIdentityDocumentOutput, error) + mockEc2Tags func(ctx context.Context, params *ec2.DescribeTagsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeTagsOutput, error) + processorOverwrite bool + previousEvent mapstr.M + expectedEvent mapstr.M }{ { - testName: "valid instance identity document", - mockGetInstanceIdentityDocumentFunc: func(ctx context.Context, params *imds.GetInstanceIdentityDocumentInput, optFns ...func(*imds.Options)) (*imds.GetInstanceIdentityDocumentOutput, error) { + testName: "valid instance identity document, no cluster tags", + mockGetInstanceIdentity: func(ctx context.Context, params *imds.GetInstanceIdentityDocumentInput, optFns ...func(*imds.Options)) (*imds.GetInstanceIdentityDocumentOutput, error) { return &imds.GetInstanceIdentityDocumentOutput{ InstanceIdentityDocument: imds.InstanceIdentityDocument{ AvailabilityZone: availabilityZoneDoc1, @@ -136,6 +99,11 @@ func TestRetrieveAWSMetadataEC2(t *testing.T) { }, }, nil }, + mockEc2Tags: func(ctx context.Context, params *ec2.DescribeTagsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeTagsOutput, error) { + return &ec2.DescribeTagsOutput{ + Tags: []types.TagDescription{}, + }, nil + }, processorOverwrite: false, previousEvent: mapstr.M{}, expectedEvent: mapstr.M{ @@ -147,70 +115,74 @@ func TestRetrieveAWSMetadataEC2(t *testing.T) { "image": mapstr.M{"id": imageIDDoc1}, "region": regionDoc1, "availability_zone": availabilityZoneDoc1, - "service": mapstr.M{ - "name": "EC2", + "service": mapstr.M{"name": "EC2"}, + }, + }, + }, + { + testName: "all fields from processor", + mockGetInstanceIdentity: func(ctx context.Context, params *imds.GetInstanceIdentityDocumentInput, optFns ...func(*imds.Options)) (*imds.GetInstanceIdentityDocumentOutput, error) { + return &imds.GetInstanceIdentityDocumentOutput{ + InstanceIdentityDocument: imds.InstanceIdentityDocument{ + AvailabilityZone: availabilityZoneDoc1, + Region: regionDoc1, + InstanceID: instanceIDDoc1, + InstanceType: instanceTypeDoc1, + AccountID: accountIDDoc1, + ImageID: imageIDDoc1, + }, + }, nil + }, + mockEc2Tags: func(ctx context.Context, params *ec2.DescribeTagsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeTagsOutput, error) { + return &ec2.DescribeTagsOutput{ + Tags: []types.TagDescription{ + { + Key: &clusterNameKey, + Value: &clusterNameValue, + }, { + Key: &instanceIDKey, + Value: &instanceIDDoc1, + }, + }, + }, nil + }, + processorOverwrite: false, + previousEvent: mapstr.M{}, + expectedEvent: mapstr.M{ + "cloud": mapstr.M{ + "provider": "aws", + "account": mapstr.M{"id": accountIDDoc1}, + "instance": mapstr.M{"id": instanceIDDoc1}, + "machine": mapstr.M{"type": instanceTypeDoc1}, + "image": mapstr.M{"id": imageIDDoc1}, + "region": regionDoc1, + "availability_zone": availabilityZoneDoc1, + "service": mapstr.M{"name": "EC2"}, + "orchestrator": mapstr.M{ + "cluster": mapstr.M{ + "name": clusterNameValue, + "id": fmt.Sprintf("arn:aws:eks:%s:%s:cluster/%s", regionDoc1, accountIDDoc1, clusterNameValue), + }, }, - // "orchestrator": mapstr.M{ - // "cluster": mapstr.M{ - // "name": clusterNameDoc1, - // "id": fmt.Sprintf("arn:aws:eks:%s:%s:cluster/%s", regionDoc1, accountIDDoc1, clusterNameDoc1), - // }, - // }, }, }, }, } - - // var testCases = []struct { - // testName string - // ec2ResponseMap map[string]string - // processorOverwrite bool - // previousEvent mapstr.M - - // expectedEvent mapstr.M - // }{ - // // { - // // testName: "all fields from processor", - // // ec2ResponseMap: map[string]string{ec2InstanceIdentityURI: sampleEC2Doc1}, - // // processorOverwrite: false, - // // previousEvent: mapstr.M{}, - // // expectedEvent: mapstr.M{ - // // "cloud": mapstr.M{ - // // "provider": "aws", - // // "account": mapstr.M{"id": accountIDDoc1}, - // // "instance": mapstr.M{"id": instanceIDDoc1}, - // // "machine": mapstr.M{"type": instanceTypeDoc1}, - // // "image": mapstr.M{"id": imageIDDoc1}, - // // "region": regionDoc1, - // // "availability_zone": availabilityZoneDoc1, - // // "service": mapstr.M{ - // // "name": "EC2", - // // }, - // // "orchestrator": mapstr.M{ - // // "cluster": mapstr.M{ - // // "name": clusterNameDoc1, - // // "id": fmt.Sprintf("arn:aws:eks:%s:%s:cluster/%s", regionDoc1, accountIDDoc1, clusterNameDoc1), - // // }, - // // }, - // // }, - // // }, - // // }, - - // // { - // // testName: "instanceId pre-informed, no overwrite", - // // ec2ResponseMap: map[string]string{ec2InstanceIdentityURI: sampleEC2Doc1}, - // // processorOverwrite: false, - // // previousEvent: mapstr.M{ - // // "cloud": mapstr.M{ - // // "instance": mapstr.M{"id": instanceIDDoc2}, - // // }, - // // }, - // // expectedEvent: mapstr.M{ - // // "cloud": mapstr.M{ - // // "instance": mapstr.M{"id": instanceIDDoc2}, - // // }, - // // }, - // // }, + // { + // testName: "instanceId pre-informed, no overwrite", + // ec2ResponseMap: map[string]string{ec2InstanceIdentityURI: sampleEC2Doc1}, + // processorOverwrite: false, + // previousEvent: mapstr.M{ + // "cloud": mapstr.M{ + // "instance": mapstr.M{"id": instanceIDDoc2}, + // }, + // }, + // expectedEvent: mapstr.M{ + // "cloud": mapstr.M{ + // "instance": mapstr.M{"id": instanceIDDoc2}, + // }, + // }, + // }, // // { // // // NOTE: In this case, add_cloud_metadata will overwrite cloud fields because @@ -313,15 +285,19 @@ func TestRetrieveAWSMetadataEC2(t *testing.T) { for _, tc := range tests { t.Run(tc.testName, func(t *testing.T) { - mockClient := &MockIMDSClient{ - GetInstanceIdentityDocumentFunc: tc.mockGetInstanceIdentityDocumentFunc, + NewIMDSClient = func(cfg awssdk.Config) IMDSClient { + return &MockIMDSClient{ + GetInstanceIdentityDocumentFunc: tc.mockGetInstanceIdentity, + } } + defer func() { NewIMDSClient = func(cfg awssdk.Config) IMDSClient { return imds.NewFromConfig(cfg) } }() - oldNewFromConfig := imds.NewFromConfig - imds.NewFromConfig = func(cfg aws.Config, optFns ...func(*imds.Options)) *imds.Client { - return (*imds.Client)(mockClient) + NewEC2Client = func(cfg awssdk.Config) EC2Client { + return &MockEC2Client{ + DescribeTagsFunc: tc.mockEc2Tags, + } } - defer func() { imds.NewFromConfig = oldNewFromConfig }() + defer func() { NewEC2Client = func(cfg awssdk.Config) EC2Client { return ec2.NewFromConfig(cfg) } }() config, err := conf.NewConfigFrom(map[string]interface{}{ "overwrite": tc.processorOverwrite, @@ -338,6 +314,9 @@ func TestRetrieveAWSMetadataEC2(t *testing.T) { // res := result{provider: "ec2", metadata: mapstr.M{}} // fetchRawProviderMetadata(context.Background(), client, &res) + // awsConfig := awssdk.Config{} + // , err := fetchIdentityDocument(awsConfig) + actual, err := cmp.Run(&beat.Event{Fields: tc.previousEvent}) if err != nil { t.Fatalf("error running processor: %s", err.Error()) From 9255c710244d705a313842d0b4756b2fd0b84bb6 Mon Sep 17 00:00:00 2001 From: Tetiana Kravchenko Date: Mon, 24 Apr 2023 10:06:12 +0200 Subject: [PATCH 06/24] Tiltfile: fix docker_registry, use more generic value Signed-off-by: Tetiana Kravchenko --- dev-tools/kubernetes/Tiltfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev-tools/kubernetes/Tiltfile b/dev-tools/kubernetes/Tiltfile index 13b7e204c92e..cd4fc3b79672 100644 --- a/dev-tools/kubernetes/Tiltfile +++ b/dev-tools/kubernetes/Tiltfile @@ -52,7 +52,7 @@ def build( # aws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin XXXXX.dkr.ecr.us-east-2.amazonaws.com/metricbeat-debug # # More info at https://docs.aws.amazon.com/AmazonECR/latest/userguide/docker-push-ecr-image.html - docker_registry = "627286350134.dkr.ecr.us-east-2.amazonaws.com".format( + docker_registry = "XXXXX.dkr.ecr.us-east-2.amazonaws.com".format( docker_image) default_registry(docker_registry) From db67e1bdf48e55233ce45a360627b233d248548c Mon Sep 17 00:00:00 2001 From: Tetiana Kravchenko Date: Mon, 24 Apr 2023 10:36:33 +0200 Subject: [PATCH 07/24] add notice file Signed-off-by: Tetiana Kravchenko --- NOTICE.txt | 424 ++++++++++++++++++++++++++--------------------------- go.mod | 2 +- 2 files changed, 213 insertions(+), 213 deletions(-) diff --git a/NOTICE.txt b/NOTICE.txt index fa7b5ee0a980..6c529546b4b8 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -3471,6 +3471,218 @@ Contents of probable licence file $GOMODCACHE/github.com/aws/aws-sdk-go-v2/crede limitations under the License. +-------------------------------------------------------------------------------- +Dependency : github.com/aws/aws-sdk-go-v2/feature/ec2/imds +Version: v1.12.7 +Licence type (autodetected): Apache-2.0 +-------------------------------------------------------------------------------- + +Contents of probable licence file $GOMODCACHE/github.com/aws/aws-sdk-go-v2/feature/ec2/imds@v1.12.7/LICENSE.txt: + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + -------------------------------------------------------------------------------- Dependency : github.com/aws/aws-sdk-go-v2/feature/s3/manager Version: v1.11.17 @@ -29272,218 +29484,6 @@ Contents of probable licence file $GOMODCACHE/github.com/aws/aws-sdk-go-v2/aws/p limitations under the License. --------------------------------------------------------------------------------- -Dependency : github.com/aws/aws-sdk-go-v2/feature/ec2/imds -Version: v1.12.7 -Licence type (autodetected): Apache-2.0 --------------------------------------------------------------------------------- - -Contents of probable licence file $GOMODCACHE/github.com/aws/aws-sdk-go-v2/feature/ec2/imds@v1.12.7/LICENSE.txt: - - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - -------------------------------------------------------------------------------- Dependency : github.com/aws/aws-sdk-go-v2/internal/configsources Version: v1.1.13 diff --git a/go.mod b/go.mod index 30202c3165e6..9ee3eb7a3879 100644 --- a/go.mod +++ b/go.mod @@ -187,6 +187,7 @@ require ( cloud.google.com/go v0.105.0 github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.4.1 github.com/Azure/go-autorest/autorest/adal v0.9.14 + github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.7 github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.17 github.com/aws/aws-sdk-go-v2/service/cloudformation v1.20.4 github.com/aws/aws-sdk-go-v2/service/kinesis v1.15.8 @@ -235,7 +236,6 @@ require ( github.com/armon/go-radix v1.0.0 // indirect github.com/aws/aws-sdk-go v1.38.60 // indirect github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.3 // indirect - github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.7 // indirect github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.13 // indirect github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.7 // indirect github.com/aws/aws-sdk-go-v2/internal/ini v1.3.14 // indirect From bb5e429cb1f905225f29260e0fd20790d1f9b4a5 Mon Sep 17 00:00:00 2001 From: Tetiana Kravchenko Date: Wed, 26 Apr 2023 15:36:35 +0200 Subject: [PATCH 08/24] fix tests - add former test cases; fix linter issues Signed-off-by: Tetiana Kravchenko --- .../add_cloud_metadata/generic_fetcher.go | 2 +- .../add_cloud_metadata/provider_aws_ec2.go | 18 +- .../provider_aws_ec2_test.go | 303 ++++++++++-------- 3 files changed, 184 insertions(+), 139 deletions(-) diff --git a/libbeat/processors/add_cloud_metadata/generic_fetcher.go b/libbeat/processors/add_cloud_metadata/generic_fetcher.go index 4467c1e49030..9a1fa95fb88a 100644 --- a/libbeat/processors/add_cloud_metadata/generic_fetcher.go +++ b/libbeat/processors/add_cloud_metadata/generic_fetcher.go @@ -49,7 +49,7 @@ func (g *genericFetcher) fetchMetadata(ctx context.Context, client http.Client) return res } res.metadata = g.schema(res.metadata) - res.metadata.Put("cloud.provider", g.provider) + _, _ = res.metadata.Put("cloud.provider", g.provider) return res } diff --git a/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go b/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go index e92b08e89228..dc7b0ef22d46 100644 --- a/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go +++ b/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go @@ -100,20 +100,20 @@ func fetchRawProviderMetadata( accountID := instanceIdentity.InstanceIdentityDocument.AccountID - result.metadata.Put("instance.id", instanceIdentity.InstanceIdentityDocument.InstanceID) - result.metadata.Put("machine.type", instanceIdentity.InstanceIdentityDocument.InstanceType) - result.metadata.Put("region", awsRegion) - result.metadata.Put("availability_zone", instanceIdentity.InstanceIdentityDocument.AvailabilityZone) - result.metadata.Put("account.id", accountID) - result.metadata.Put("image.id", instanceIdentity.InstanceIdentityDocument.ImageID) + _, _ = result.metadata.Put("instance.id", instanceIdentity.InstanceIdentityDocument.InstanceID) + _, _ = result.metadata.Put("machine.type", instanceIdentity.InstanceIdentityDocument.InstanceType) + _, _ = result.metadata.Put("region", awsRegion) + _, _ = result.metadata.Put("availability_zone", instanceIdentity.InstanceIdentityDocument.AvailabilityZone) + _, _ = result.metadata.Put("account.id", accountID) + _, _ = result.metadata.Put("image.id", instanceIdentity.InstanceIdentityDocument.ImageID) // for AWS cluster ID is used cluster ARN: arn:partition:service:region:account-id:resource-type/resource-id, example: // arn:aws:eks:us-east-2:627286350134:cluster/cluster-name if clusterName != "" { clusterARN := fmt.Sprintf("arn:aws:eks:%s:%s:cluster/%v", awsRegion, accountID, clusterName) - result.metadata.Put("orchestrator.cluster.name", clusterName) - result.metadata.Put("orchestrator.cluster.id", clusterARN) + _, _ = result.metadata.Put("orchestrator.cluster.name", clusterName) + _, _ = result.metadata.Put("orchestrator.cluster.id", clusterARN) } } @@ -138,7 +138,7 @@ func fetchEC2ClusterNameTag(awsConfig awssdk.Config, instanceID string) (string, tagsResult, err := svc.DescribeTags(context.TODO(), input) if err != nil { - return "", fmt.Errorf("error fetching EC2 Tags: %s", err) + return "", fmt.Errorf("error fetching EC2 Tags: %w", err) } if len(tagsResult.Tags) > 0 { return *tagsResult.Tags[0].Value, nil diff --git a/libbeat/processors/add_cloud_metadata/provider_aws_ec2_test.go b/libbeat/processors/add_cloud_metadata/provider_aws_ec2_test.go index 426909de2255..e283b205c203 100644 --- a/libbeat/processors/add_cloud_metadata/provider_aws_ec2_test.go +++ b/libbeat/processors/add_cloud_metadata/provider_aws_ec2_test.go @@ -52,14 +52,13 @@ func (e *MockEC2Client) DescribeTags(ctx context.Context, params *ec2.DescribeTa } func TestMain(m *testing.M) { - logp.TestingSetup() + _ = logp.TestingSetup() code := m.Run() os.Exit(code) } func TestRetrieveAWSMetadataEC2(t *testing.T) { - - const ( + var ( // not the best way to use a response template // but this should serve until we need to test // documents containing very different values @@ -69,12 +68,10 @@ func TestRetrieveAWSMetadataEC2(t *testing.T) { imageIDDoc1 = "ami-abcd1234" instanceTypeDoc1 = "t2.medium" instanceIDDoc2 = "i-22222222" - ) - var ( - clusterNameKey string = "eks:cluster-name" - clusterNameValue string = "test" - instanceIDKey string = "resource-id" - instanceIDDoc1 string = "i-11111111" + clusterNameKey = "eks:cluster-name" + clusterNameValue = "test" + instanceIDKey = "resource-id" + instanceIDDoc1 = "i-11111111" ) var tests = []struct { @@ -167,120 +164,175 @@ func TestRetrieveAWSMetadataEC2(t *testing.T) { }, }, }, + { + testName: "instanceId pre-informed, no overwrite", + mockGetInstanceIdentity: func(ctx context.Context, params *imds.GetInstanceIdentityDocumentInput, optFns ...func(*imds.Options)) (*imds.GetInstanceIdentityDocumentOutput, error) { + return &imds.GetInstanceIdentityDocumentOutput{ + InstanceIdentityDocument: imds.InstanceIdentityDocument{ + AvailabilityZone: availabilityZoneDoc1, + Region: regionDoc1, + InstanceID: instanceIDDoc1, + InstanceType: instanceTypeDoc1, + AccountID: accountIDDoc1, + ImageID: imageIDDoc1, + }, + }, nil + }, + mockEc2Tags: func(ctx context.Context, params *ec2.DescribeTagsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeTagsOutput, error) { + return &ec2.DescribeTagsOutput{ + Tags: []types.TagDescription{ + { + Key: &clusterNameKey, + Value: &clusterNameValue, + }, { + Key: &instanceIDKey, + Value: &instanceIDDoc1, + }, + }, + }, nil + }, + processorOverwrite: false, + previousEvent: mapstr.M{ + "cloud": mapstr.M{ + "instance": mapstr.M{"id": instanceIDDoc2}, + }, + }, + expectedEvent: mapstr.M{ + "cloud": mapstr.M{ + "instance": mapstr.M{"id": instanceIDDoc2}, + }, + }, + }, + { + // NOTE: In this case, add_cloud_metadata will overwrite cloud fields because + // it won't detect cloud.provider as a cloud field. This is not the behavior we + // expect and will find a better solution later in issue 11697. + testName: "only cloud.provider pre-informed, no overwrite", + mockGetInstanceIdentity: func(ctx context.Context, params *imds.GetInstanceIdentityDocumentInput, optFns ...func(*imds.Options)) (*imds.GetInstanceIdentityDocumentOutput, error) { + return &imds.GetInstanceIdentityDocumentOutput{ + InstanceIdentityDocument: imds.InstanceIdentityDocument{ + AvailabilityZone: availabilityZoneDoc1, + Region: regionDoc1, + InstanceID: instanceIDDoc1, + InstanceType: instanceTypeDoc1, + AccountID: accountIDDoc1, + ImageID: imageIDDoc1, + }, + }, nil + }, + mockEc2Tags: func(ctx context.Context, params *ec2.DescribeTagsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeTagsOutput, error) { + return &ec2.DescribeTagsOutput{ + Tags: []types.TagDescription{ + { + Key: &clusterNameKey, + Value: &clusterNameValue, + }, { + Key: &instanceIDKey, + Value: &instanceIDDoc1, + }, + }, + }, nil + }, + processorOverwrite: false, + previousEvent: mapstr.M{ + "cloud.provider": "aws", + }, + expectedEvent: mapstr.M{ + "cloud.provider": "aws", + "cloud": mapstr.M{ + "provider": "aws", + "account": mapstr.M{"id": accountIDDoc1}, + "instance": mapstr.M{"id": instanceIDDoc1}, + "machine": mapstr.M{"type": instanceTypeDoc1}, + "image": mapstr.M{"id": imageIDDoc1}, + "region": regionDoc1, + "availability_zone": availabilityZoneDoc1, + "service": mapstr.M{"name": "EC2"}, + "orchestrator": mapstr.M{ + "cluster": mapstr.M{ + "name": clusterNameValue, + "id": fmt.Sprintf("arn:aws:eks:%s:%s:cluster/%s", regionDoc1, accountIDDoc1, clusterNameValue), + }, + }, + }, + }, + }, + { + testName: "instanceId pre-informed, overwrite", + mockGetInstanceIdentity: func(ctx context.Context, params *imds.GetInstanceIdentityDocumentInput, optFns ...func(*imds.Options)) (*imds.GetInstanceIdentityDocumentOutput, error) { + return &imds.GetInstanceIdentityDocumentOutput{ + InstanceIdentityDocument: imds.InstanceIdentityDocument{ + AvailabilityZone: availabilityZoneDoc1, + Region: regionDoc1, + InstanceID: instanceIDDoc1, + InstanceType: instanceTypeDoc1, + AccountID: accountIDDoc1, + ImageID: imageIDDoc1, + }, + }, nil + }, + mockEc2Tags: func(ctx context.Context, params *ec2.DescribeTagsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeTagsOutput, error) { + return &ec2.DescribeTagsOutput{ + Tags: []types.TagDescription{}, + }, nil + }, + processorOverwrite: true, + previousEvent: mapstr.M{ + "cloud": mapstr.M{ + "instance": mapstr.M{"id": instanceIDDoc2}, + }, + }, + expectedEvent: mapstr.M{ + "cloud": mapstr.M{ + "provider": "aws", + "account": mapstr.M{"id": accountIDDoc1}, + "instance": mapstr.M{"id": instanceIDDoc1}, + "machine": mapstr.M{"type": instanceTypeDoc1}, + "image": mapstr.M{"id": imageIDDoc1}, + "region": regionDoc1, + "availability_zone": availabilityZoneDoc1, + "service": mapstr.M{"name": "EC2"}, + }, + }, + }, + { + testName: "only cloud.provider pre-informed, overwrite", + mockGetInstanceIdentity: func(ctx context.Context, params *imds.GetInstanceIdentityDocumentInput, optFns ...func(*imds.Options)) (*imds.GetInstanceIdentityDocumentOutput, error) { + return &imds.GetInstanceIdentityDocumentOutput{ + InstanceIdentityDocument: imds.InstanceIdentityDocument{ + AvailabilityZone: availabilityZoneDoc1, + Region: regionDoc1, + InstanceID: instanceIDDoc1, + InstanceType: instanceTypeDoc1, + AccountID: accountIDDoc1, + ImageID: imageIDDoc1, + }, + }, nil + }, + mockEc2Tags: func(ctx context.Context, params *ec2.DescribeTagsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeTagsOutput, error) { + return &ec2.DescribeTagsOutput{ + Tags: []types.TagDescription{}, + }, nil + }, + processorOverwrite: false, + previousEvent: mapstr.M{ + "cloud.provider": "aws", + }, + expectedEvent: mapstr.M{ + "cloud.provider": "aws", + "cloud": mapstr.M{ + "provider": "aws", + "account": mapstr.M{"id": accountIDDoc1}, + "instance": mapstr.M{"id": instanceIDDoc1}, + "machine": mapstr.M{"type": instanceTypeDoc1}, + "image": mapstr.M{"id": imageIDDoc1}, + "region": regionDoc1, + "availability_zone": availabilityZoneDoc1, + "service": mapstr.M{"name": "EC2"}, + }, + }, + }, } - // { - // testName: "instanceId pre-informed, no overwrite", - // ec2ResponseMap: map[string]string{ec2InstanceIdentityURI: sampleEC2Doc1}, - // processorOverwrite: false, - // previousEvent: mapstr.M{ - // "cloud": mapstr.M{ - // "instance": mapstr.M{"id": instanceIDDoc2}, - // }, - // }, - // expectedEvent: mapstr.M{ - // "cloud": mapstr.M{ - // "instance": mapstr.M{"id": instanceIDDoc2}, - // }, - // }, - // }, - - // // { - // // // NOTE: In this case, add_cloud_metadata will overwrite cloud fields because - // // // it won't detect cloud.provider as a cloud field. This is not the behavior we - // // // expect and will find a better solution later in issue 11697. - // // testName: "only cloud.provider pre-informed, no overwrite", - // // ec2ResponseMap: map[string]string{ec2InstanceIdentityURI: sampleEC2Doc1}, - // // processorOverwrite: false, - // // previousEvent: mapstr.M{ - // // "cloud.provider": "aws", - // // }, - // // expectedEvent: mapstr.M{ - // // "cloud.provider": "aws", - // // "cloud": mapstr.M{ - // // "provider": "aws", - // // "account": mapstr.M{"id": accountIDDoc1}, - // // "instance": mapstr.M{"id": instanceIDDoc1}, - // // "machine": mapstr.M{"type": instanceTypeDoc1}, - // // "image": mapstr.M{"id": imageIDDoc1}, - // // "region": regionDoc1, - // // "availability_zone": availabilityZoneDoc1, - // // "service": mapstr.M{ - // // "name": "EC2", - // // }, - // // }, - // // }, - // // }, - - // // { - // // testName: "all fields from processor, overwrite", - // // ec2ResponseMap: map[string]string{ec2InstanceIdentityURI: sampleEC2Doc1}, - // // processorOverwrite: true, - // // previousEvent: mapstr.M{}, - // // expectedEvent: mapstr.M{ - // // "cloud": mapstr.M{ - // // "provider": "aws", - // // "account": mapstr.M{"id": accountIDDoc1}, - // // "instance": mapstr.M{"id": instanceIDDoc1}, - // // "machine": mapstr.M{"type": instanceTypeDoc1}, - // // "image": mapstr.M{"id": imageIDDoc1}, - // // "region": regionDoc1, - // // "availability_zone": availabilityZoneDoc1, - // // "service": mapstr.M{ - // // "name": "EC2", - // // }, - // // }, - // // }, - // // }, - - // // { - // // testName: "instanceId pre-informed, overwrite", - // // ec2ResponseMap: map[string]string{ec2InstanceIdentityURI: sampleEC2Doc1}, - // // processorOverwrite: true, - // // previousEvent: mapstr.M{ - // // "cloud": mapstr.M{ - // // "instance": mapstr.M{"id": instanceIDDoc2}, - // // }, - // // }, - // // expectedEvent: mapstr.M{ - // // "cloud": mapstr.M{ - // // "provider": "aws", - // // "account": mapstr.M{"id": accountIDDoc1}, - // // "instance": mapstr.M{"id": instanceIDDoc1}, - // // "machine": mapstr.M{"type": instanceTypeDoc1}, - // // "image": mapstr.M{"id": imageIDDoc1}, - // // "region": regionDoc1, - // // "availability_zone": availabilityZoneDoc1, - // // "service": mapstr.M{ - // // "name": "EC2", - // // }, - // // }, - // // }, - // // }, - - // // { - // // testName: "only cloud.provider pre-informed, overwrite", - // // ec2ResponseMap: map[string]string{ec2InstanceIdentityURI: sampleEC2Doc1}, - // // processorOverwrite: false, - // // previousEvent: mapstr.M{ - // // "cloud.provider": "aws", - // // }, - // // expectedEvent: mapstr.M{ - // // "cloud.provider": "aws", - // // "cloud": mapstr.M{ - // // "provider": "aws", - // // "account": mapstr.M{"id": accountIDDoc1}, - // // "instance": mapstr.M{"id": instanceIDDoc1}, - // // "machine": mapstr.M{"type": instanceTypeDoc1}, - // // "image": mapstr.M{"id": imageIDDoc1}, - // // "region": regionDoc1, - // // "availability_zone": availabilityZoneDoc1, - // // "service": mapstr.M{ - // // "name": "EC2", - // // }, - // // }, - // // }, - // // }, - // } for _, tc := range tests { t.Run(tc.testName, func(t *testing.T) { @@ -310,13 +362,6 @@ func TestRetrieveAWSMetadataEC2(t *testing.T) { t.Fatalf("error creating new metadata processor: %s", err.Error()) } - // client := http.Client{} - // res := result{provider: "ec2", metadata: mapstr.M{}} - // fetchRawProviderMetadata(context.Background(), client, &res) - - // awsConfig := awssdk.Config{} - // , err := fetchIdentityDocument(awsConfig) - actual, err := cmp.Run(&beat.Event{Fields: tc.previousEvent}) if err != nil { t.Fatalf("error running processor: %s", err.Error()) From 98b5cb5a60108be18ba94d4af4dc3af199e64c1c Mon Sep 17 00:00:00 2001 From: Tetiana Kravchenko Date: Wed, 26 Apr 2023 17:35:30 +0200 Subject: [PATCH 09/24] handle correctly result.err Signed-off-by: Tetiana Kravchenko --- libbeat/processors/add_cloud_metadata/provider_aws_ec2.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go b/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go index dc7b0ef22d46..8e7fc3babb10 100644 --- a/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go +++ b/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go @@ -27,6 +27,8 @@ import ( "github.com/aws/aws-sdk-go-v2/feature/ec2/imds" "github.com/aws/aws-sdk-go-v2/service/ec2" "github.com/aws/aws-sdk-go-v2/service/ec2/types" + "github.com/pkg/errors" + "github.com/elastic/elastic-agent-libs/logp" "github.com/elastic/elastic-agent-libs/mapstr" @@ -80,13 +82,16 @@ func fetchRawProviderMetadata( awsConfig, err := awscfg.LoadDefaultConfig(context.TODO(), awscfg.WithHTTPClient(&client)) if err != nil { logger.Debugf("error loading AWS default configuration: %s.", err) + result.err = errors.Wrapf(err, "failed loading AWS default configuration") return } awsClient := NewIMDSClient(awsConfig) instanceIdentity, err := awsClient.GetInstanceIdentityDocument(context.TODO(), &imds.GetInstanceIdentityDocumentInput{}) if err != nil { - logger.Warnf("error fetching EC2 Identity Document: %s.", err) + logger.Debugf("error fetching EC2 Identity Document: %s.", err) + result.err = errors.Wrapf(err, "failed fetching EC2 Identity Document.") + return } // AWS Region must be set to be able to get EC2 Tags From fb0293ef5ba24b8a764757deb22ac5815396970a Mon Sep 17 00:00:00 2001 From: Tetiana Kravchenko Date: Mon, 23 Jan 2023 10:38:44 +0100 Subject: [PATCH 10/24] add generic metadata fetcher Signed-off-by: Tetiana Kravchenko --- .../add_cloud_metadata/generic_fetcher.go | 56 +++++++ .../add_cloud_metadata/provider_aws_ec2.go | 156 ++++++++---------- 2 files changed, 124 insertions(+), 88 deletions(-) create mode 100644 libbeat/processors/add_cloud_metadata/generic_fetcher.go diff --git a/libbeat/processors/add_cloud_metadata/generic_fetcher.go b/libbeat/processors/add_cloud_metadata/generic_fetcher.go new file mode 100644 index 000000000000..bc34d6bcc628 --- /dev/null +++ b/libbeat/processors/add_cloud_metadata/generic_fetcher.go @@ -0,0 +1,56 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package add_cloud_metadata + +import ( + "context" + "net/http" + + cfg "github.com/elastic/elastic-agent-libs/config" + "github.com/elastic/elastic-agent-libs/mapstr" +) + +type genericFetcher struct { + provider string + conv schemaConv + fetchRawProviderMetadata func(context.Context, http.Client, *result) +} + +func newGenericMetadataFetcher( + c *cfg.C, + provider string, + conv schemaConv, + genericFetcherMeta func(context.Context, http.Client, *result), +) (*genericFetcher, error) { + + gFetcher := &genericFetcher{provider, conv, genericFetcherMeta} + return gFetcher, nil +} + +func (g *genericFetcher) fetchMetadata(ctx context.Context, client http.Client) result { + res := result{provider: g.provider, metadata: mapstr.M{}} + g.fetchRawProviderMetadata(ctx, client, &res) + if res.err != nil { + return res + } + // Apply schema. + res.metadata = g.conv(res.metadata) + res.metadata.Put("cloud.provider", g.provider) + + return res +} diff --git a/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go b/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go index 54ac4eaf9b28..b3504effddf4 100644 --- a/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go +++ b/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go @@ -18,21 +18,21 @@ package add_cloud_metadata import ( - "fmt" - "io" - "io/ioutil" - "net" + "context" "net/http" + awssdk "github.com/aws/aws-sdk-go-v2/aws" + awscfg "github.com/aws/aws-sdk-go-v2/config" + "github.com/aws/aws-sdk-go-v2/feature/ec2/imds" + "github.com/aws/aws-sdk-go-v2/service/ec2" + "github.com/aws/aws-sdk-go-v2/service/ec2/types" "github.com/elastic/elastic-agent-libs/logp" "github.com/elastic/elastic-agent-libs/mapstr" - s "github.com/elastic/beats/v7/libbeat/common/schema" - c "github.com/elastic/beats/v7/libbeat/common/schema/mapstriface" conf "github.com/elastic/elastic-agent-libs/config" - "github.com/elastic/elastic-agent-libs/transport/tlscommon" ) +//TODO: adjust tests and delete consts: const ( ec2InstanceIdentityURI = "/2014-02-25/dynamic/instance-identity/document" ec2InstanceIMDSv2TokenValueHeader = "X-aws-ec2-metadata-token" @@ -41,102 +41,82 @@ const ( ec2InstanceIMDSv2TokenURI = "/latest/api/token" ) -// fetches IMDSv2 token, returns empty one on errors -func getIMDSv2Token(c *conf.C) string { - logger := logp.NewLogger("add_cloud_metadata") +// AWS EC2 Metadata Service +var ec2MetadataFetcher = provider{ + Name: "aws-ec2", - config := defaultConfig() - if err := c.Unpack(&config); err != nil { - logger.Warnf("error when load config for getting IMDSv2 token: %s. No token in the metadata request will be used.", err) - return "" - } + Local: true, - tlsConfig, err := tlscommon.LoadTLSConfig(config.TLS) - if err != nil { - logger.Warnf("error when load TLS config for getting IMDSv2 token: %s. No token in the metadata request will be used.", err) - return "" - } + Create: func(_ string, config *conf.C) (metadataFetcher, error) { + ec2Schema := func(m map[string]interface{}) mapstr.M { + m["service"] = mapstr.M{ + "name": "EC2", + } + return mapstr.M{"cloud": m} + } - client := http.Client{ - Timeout: config.Timeout, - Transport: &http.Transport{ - DisableKeepAlives: true, - DialContext: (&net.Dialer{ - Timeout: config.Timeout, - KeepAlive: 0, - }).DialContext, - TLSClientConfig: tlsConfig.ToConfig(), - }, - } + fetcher, err := newGenericMetadataFetcher(config, "aws", ec2Schema, fetchRawProviderMetadata) + return fetcher, err + }, +} - tokenReq, err := http.NewRequest("PUT", fmt.Sprintf("http://%s%s", metadataHost, ec2InstanceIMDSv2TokenURI), nil) - if err != nil { - logger.Warnf("error when make token request for getting IMDSv2 token: %s. No token in the metadata request will be used.", err) - return "" - } +// fetchRaw queries raw metadata from a hosting provider's metadata service. +func fetchRawProviderMetadata( + ctx context.Context, + client http.Client, + result *result, +) { + logger := logp.NewLogger("add_cloud_metadata") + // config := defaultConfig() + // if err := c.Unpack(&config); err != nil { + // logger.Warnf("error when load config for getting IMDSv2 token: %s. No token in the metadata request will be used.", err) + // } - tokenReq.Header.Add(ec2InstanceIMDSv2TokenTTLHeader, ec2InstanceIMDSv2TokenTTLValue) - rsp, err := client.Do(tokenReq) - if rsp == nil { - logger.Warnf("read token request for getting IMDSv2 token returns empty: %s. No token in the metadata request will be used.", err) - return "" + // LoadDefaultConfig loads the Ec2 role credentials + awsConfig, err := awscfg.LoadDefaultConfig(context.TODO(), awscfg.WithHTTPClient(&client)) + if err != nil { + logger.Warnf("error when loading AWS default configuration: %s.", err) } - defer func(body io.ReadCloser) { - if body != nil { - body.Close() - } - }(rsp.Body) + awsClient := imds.NewFromConfig(awsConfig) + instanceIdentity, err := awsClient.GetInstanceIdentityDocument(context.TODO(), &imds.GetInstanceIdentityDocumentInput{}) if err != nil { - logger.Warnf("error when read token request for getting IMDSv2 token: %s. No token in the metadata request will be used.", err) - return "" + logger.Warnf("error when fetching EC2 Identity Document: %s.", err) } - if rsp.StatusCode != http.StatusOK { - logger.Warnf("error when check request status for getting IMDSv2 token: http request status %d. No token in the metadata request will be used.", rsp.StatusCode) - return "" + // Region must be set to be able to get EC2 Tags + awsConfig.Region = instanceIdentity.Region + + svc := ec2.NewFromConfig(awsConfig) + input := &ec2.DescribeTagsInput{ + Filters: []types.Filter{ + { + Name: awssdk.String("resource-id"), + Values: []string{ + *awssdk.String(instanceIdentity.InstanceIdentityDocument.InstanceID), + }, + }, + { + Name: awssdk.String("key"), + Values: []string{ + *awssdk.String("eks:cluster-name"), + }, + }, + }, } - all, err := ioutil.ReadAll(rsp.Body) + tagsResult, err := svc.DescribeTags(context.TODO(), input) if err != nil { - logger.Warnf("error when reading token request for getting IMDSv2 token: %s. No token in the metadata request will be used.", err) - return "" + logger.Warnf("error when fetching EC2 Tags: %s.", err) } - return string(all) -} - -// AWS EC2 Metadata Service -var ec2MetadataFetcher = provider{ - Name: "aws-ec2", - - Local: true, - - Create: func(_ string, config *conf.C) (metadataFetcher, error) { - ec2Schema := func(m map[string]interface{}) mapstr.M { - m["serviceName"] = "EC2" - out, _ := s.Schema{ - "instance": s.Object{"id": c.Str("instanceId")}, - "machine": s.Object{"type": c.Str("instanceType")}, - "region": c.Str("region"), - "availability_zone": c.Str("availabilityZone"), - "service": s.Object{ - "name": c.Str("serviceName"), - }, - "account": s.Object{"id": c.Str("accountId")}, - "image": s.Object{"id": c.Str("imageId")}, - }.Apply(m) - return mapstr.M{"cloud": out} - } - - headers := make(map[string]string, 1) - token := getIMDSv2Token(config) - if len(token) > 0 { - headers[ec2InstanceIMDSv2TokenValueHeader] = token - } + result.metadata.Put("cloud.orchestrator.cluster.name", tagsResult.Tags[0].Value) + result.metadata.Put("cloud.instance.id", instanceIdentity.InstanceIdentityDocument.InstanceID) + result.metadata.Put("cloud.machine.type", instanceIdentity.InstanceIdentityDocument.InstanceType) + result.metadata.Put("cloud.region", instanceIdentity.InstanceIdentityDocument.Region) + result.metadata.Put("cloud.availability_zone", instanceIdentity.InstanceIdentityDocument.AvailabilityZone) + result.metadata.Put("cloud.account.id", instanceIdentity.InstanceIdentityDocument.AccountID) + result.metadata.Put("cloud.image.id", instanceIdentity.InstanceIdentityDocument.ImageID) - fetcher, err := newMetadataFetcher(config, "aws", headers, metadataHost, ec2Schema, ec2InstanceIdentityURI) - return fetcher, err - }, } From 5b5e54d0a8bdc52816fa0cfd6ed7a6f446be1585 Mon Sep 17 00:00:00 2001 From: Tetiana Kravchenko Date: Mon, 10 Apr 2023 13:46:15 +0200 Subject: [PATCH 11/24] merge main Signed-off-by: Tetiana Kravchenko --- dev-tools/kubernetes/Tiltfile | 24 ++- .../sys/fs/cgroup/blkio/cgroup.clone_children | 1 + .../sys/fs/cgroup/blkio/cgroup.sane_behavior | 1 + .../notify_on_release | 1 + .../tasks | 1 + .../fs/cgroup/blkio/docker/notify_on_release | 1 + .../docker/sys/fs/cgroup/blkio/docker/tasks | 0 .../sys/fs/cgroup/blkio/notify_on_release | 1 + .../docker/sys/fs/cgroup/blkio/release_agent | 1 + .../testdata/docker/sys/fs/cgroup/blkio/tasks | 158 ++++++++++++++++++ .../sys/fs/cgroup/cpu/cgroup.clone_children | 1 + .../sys/fs/cgroup/cpu/cgroup.sane_behavior | 1 + .../notify_on_release | 1 + .../tasks | 37 ++++ .../fs/cgroup/cpu/docker/notify_on_release | 1 + .../docker/sys/fs/cgroup/cpu/docker/tasks | 0 .../sys/fs/cgroup/cpu/notify_on_release | 1 + .../docker/sys/fs/cgroup/cpu/release_agent | 1 + .../testdata/docker/sys/fs/cgroup/cpu/tasks | 158 ++++++++++++++++++ .../fs/cgroup/cpuacct/cgroup.clone_children | 1 + .../fs/cgroup/cpuacct/cgroup.sane_behavior | 1 + .../notify_on_release | 1 + .../tasks | 37 ++++ .../cgroup/cpuacct/docker/notify_on_release | 1 + .../docker/sys/fs/cgroup/cpuacct/docker/tasks | 0 .../sys/fs/cgroup/cpuacct/notify_on_release | 1 + .../sys/fs/cgroup/cpuacct/release_agent | 1 + .../docker/sys/fs/cgroup/cpuacct/tasks | 158 ++++++++++++++++++ .../sys/fs/cgroup/cpuset/cgroup.sane_behavior | 1 + .../notify_on_release | 1 + .../tasks | 37 ++++ .../fs/cgroup/cpuset/docker/notify_on_release | 1 + .../docker/sys/fs/cgroup/cpuset/docker/tasks | 0 .../sys/fs/cgroup/cpuset/notify_on_release | 1 + .../docker/sys/fs/cgroup/cpuset/release_agent | 1 + .../docker/sys/fs/cgroup/cpuset/tasks | 158 ++++++++++++++++++ .../fs/cgroup/memory/cgroup.clone_children | 1 + .../sys/fs/cgroup/memory/cgroup.event_control | 0 .../sys/fs/cgroup/memory/cgroup.sane_behavior | 1 + .../notify_on_release | 1 + .../tasks | 37 ++++ .../fs/cgroup/memory/docker/notify_on_release | 1 + .../docker/sys/fs/cgroup/memory/docker/tasks | 0 .../sys/fs/cgroup/memory/memory.force_empty | 0 .../memory/memory.move_charge_at_immigrate | 1 + .../sys/fs/cgroup/memory/memory.use_hierarchy | 1 + .../sys/fs/cgroup/memory/notify_on_release | 1 + .../docker/sys/fs/cgroup/memory/release_agent | 1 + .../docker/sys/fs/cgroup/memory/tasks | 158 ++++++++++++++++++ .../add_cloud_metadata/generic_fetcher.go | 4 +- .../add_cloud_metadata/provider_aws_ec2.go | 14 +- 51 files changed, 998 insertions(+), 14 deletions(-) create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/cgroup.clone_children create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/cgroup.sane_behavior create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/notify_on_release create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/tasks create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/notify_on_release create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/release_agent create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/tasks create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/cgroup.clone_children create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/cgroup.sane_behavior create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/notify_on_release create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/tasks create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/notify_on_release create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/release_agent create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/tasks create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/cgroup.clone_children create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/cgroup.sane_behavior create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/notify_on_release create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/tasks create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/notify_on_release create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/release_agent create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/tasks create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/cgroup.sane_behavior create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/notify_on_release create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/tasks create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/notify_on_release create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/release_agent create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/tasks create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/cgroup.clone_children create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/cgroup.event_control create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/cgroup.sane_behavior create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/notify_on_release create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/tasks create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/memory.force_empty create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/memory.move_charge_at_immigrate create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/memory.use_hierarchy create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/notify_on_release create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/release_agent create mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/tasks diff --git a/dev-tools/kubernetes/Tiltfile b/dev-tools/kubernetes/Tiltfile index edfef02550ea..13b7e204c92e 100644 --- a/dev-tools/kubernetes/Tiltfile +++ b/dev-tools/kubernetes/Tiltfile @@ -47,6 +47,18 @@ def build( default_registry(docker_registry) print("Docker registry: {}".format(docker_registry)) + if k8s_env == "aws": + # In order to push to AWS you need ti run: + # aws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin XXXXX.dkr.ecr.us-east-2.amazonaws.com/metricbeat-debug + # + # More info at https://docs.aws.amazon.com/AmazonECR/latest/userguide/docker-push-ecr-image.html + docker_registry = "627286350134.dkr.ecr.us-east-2.amazonaws.com".format( + docker_image) + + default_registry(docker_registry) + print("Docker registry: {}".format(docker_registry)) + + print("Docker image: {}".format(docker_image)) docker_file = '{}/Dockerfile.{}'.format(beat, mode) @@ -149,7 +161,7 @@ def beat( if arch not in ["arm64", "amd64"]: print("Invalid arch: {}".format(arch)) exit(-1) - if k8s_env not in ["kind", "gcp"]: + if k8s_env not in ["kind", "gcp", "aws"]: print("Invalid k8s_env: {}".format(k8s_env)) exit(-1) if k8s_cluster not in ["single", "multi"]: @@ -191,10 +203,10 @@ def beat( k8s_expose(beat=beat, mode=mode, k8s_cluster=k8s_cluster) -beat(beat="heartbeat", - mode="debug", - # mode="run", - arch="arm64", - k8s_env="kind", +beat(beat="metricbeat", + # mode="debug", + mode="run", + arch="amd64", + k8s_env="aws", k8s_cluster="single", ) diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/cgroup.clone_children b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/cgroup.clone_children new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/cgroup.clone_children @@ -0,0 +1 @@ +0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/cgroup.sane_behavior b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/cgroup.sane_behavior new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/cgroup.sane_behavior @@ -0,0 +1 @@ +0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release @@ -0,0 +1 @@ +0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks new file mode 100644 index 000000000000..2ab15755dfe0 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks @@ -0,0 +1 @@ +11668 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/notify_on_release new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/notify_on_release @@ -0,0 +1 @@ +0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/tasks new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/notify_on_release new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/notify_on_release @@ -0,0 +1 @@ +0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/release_agent b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/release_agent new file mode 100644 index 000000000000..8b137891791f --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/release_agent @@ -0,0 +1 @@ + diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/tasks new file mode 100644 index 000000000000..27537f94a4b3 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/tasks @@ -0,0 +1,158 @@ +1 +2 +3 +5 +7 +8 +9 +10 +11 +13 +14 +15 +16 +18 +19 +20 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +40 +41 +42 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +123 +124 +151 +152 +155 +156 +157 +158 +171 +202 +272 +322 +323 +388 +519 +574 +575 +576 +620 +648 +659 +734 +748 +750 +752 +753 +754 +755 +756 +771 +772 +773 +777 +778 +795 +797 +798 +799 +809 +816 +840 +885 +886 +887 +909 +911 +912 +969 +975 +976 +977 +978 +979 +989 +1056 +1154 +1161 +1293 +1294 +1296 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/cgroup.clone_children b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/cgroup.clone_children new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/cgroup.clone_children @@ -0,0 +1 @@ +0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/cgroup.sane_behavior b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/cgroup.sane_behavior new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/cgroup.sane_behavior @@ -0,0 +1 @@ +0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release @@ -0,0 +1 @@ +0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks new file mode 100644 index 000000000000..16ae34357356 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks @@ -0,0 +1,37 @@ +985 +1006 +1007 +1008 +1009 +1010 +1011 +1012 +1013 +1014 +1015 +1016 +1017 +1018 +1019 +1020 +1021 +1048 +1049 +1052 +1053 +1054 +1055 +1057 +1058 +1059 +1060 +1061 +1062 +1063 +1064 +1065 +1066 +1067 +1068 +1069 +1070 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/notify_on_release new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/notify_on_release @@ -0,0 +1 @@ +0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/tasks new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/notify_on_release new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/notify_on_release @@ -0,0 +1 @@ +0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/release_agent b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/release_agent new file mode 100644 index 000000000000..8b137891791f --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/release_agent @@ -0,0 +1 @@ + diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/tasks new file mode 100644 index 000000000000..27537f94a4b3 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/tasks @@ -0,0 +1,158 @@ +1 +2 +3 +5 +7 +8 +9 +10 +11 +13 +14 +15 +16 +18 +19 +20 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +40 +41 +42 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +123 +124 +151 +152 +155 +156 +157 +158 +171 +202 +272 +322 +323 +388 +519 +574 +575 +576 +620 +648 +659 +734 +748 +750 +752 +753 +754 +755 +756 +771 +772 +773 +777 +778 +795 +797 +798 +799 +809 +816 +840 +885 +886 +887 +909 +911 +912 +969 +975 +976 +977 +978 +979 +989 +1056 +1154 +1161 +1293 +1294 +1296 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/cgroup.clone_children b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/cgroup.clone_children new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/cgroup.clone_children @@ -0,0 +1 @@ +0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/cgroup.sane_behavior b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/cgroup.sane_behavior new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/cgroup.sane_behavior @@ -0,0 +1 @@ +0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release @@ -0,0 +1 @@ +0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks new file mode 100644 index 000000000000..16ae34357356 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks @@ -0,0 +1,37 @@ +985 +1006 +1007 +1008 +1009 +1010 +1011 +1012 +1013 +1014 +1015 +1016 +1017 +1018 +1019 +1020 +1021 +1048 +1049 +1052 +1053 +1054 +1055 +1057 +1058 +1059 +1060 +1061 +1062 +1063 +1064 +1065 +1066 +1067 +1068 +1069 +1070 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/notify_on_release new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/notify_on_release @@ -0,0 +1 @@ +0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/tasks new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/notify_on_release new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/notify_on_release @@ -0,0 +1 @@ +0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/release_agent b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/release_agent new file mode 100644 index 000000000000..8b137891791f --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/release_agent @@ -0,0 +1 @@ + diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/tasks new file mode 100644 index 000000000000..27537f94a4b3 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/tasks @@ -0,0 +1,158 @@ +1 +2 +3 +5 +7 +8 +9 +10 +11 +13 +14 +15 +16 +18 +19 +20 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +40 +41 +42 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +123 +124 +151 +152 +155 +156 +157 +158 +171 +202 +272 +322 +323 +388 +519 +574 +575 +576 +620 +648 +659 +734 +748 +750 +752 +753 +754 +755 +756 +771 +772 +773 +777 +778 +795 +797 +798 +799 +809 +816 +840 +885 +886 +887 +909 +911 +912 +969 +975 +976 +977 +978 +979 +989 +1056 +1154 +1161 +1293 +1294 +1296 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/cgroup.sane_behavior b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/cgroup.sane_behavior new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/cgroup.sane_behavior @@ -0,0 +1 @@ +0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release @@ -0,0 +1 @@ +0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks new file mode 100644 index 000000000000..16ae34357356 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks @@ -0,0 +1,37 @@ +985 +1006 +1007 +1008 +1009 +1010 +1011 +1012 +1013 +1014 +1015 +1016 +1017 +1018 +1019 +1020 +1021 +1048 +1049 +1052 +1053 +1054 +1055 +1057 +1058 +1059 +1060 +1061 +1062 +1063 +1064 +1065 +1066 +1067 +1068 +1069 +1070 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/notify_on_release new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/notify_on_release @@ -0,0 +1 @@ +0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/tasks new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/notify_on_release new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/notify_on_release @@ -0,0 +1 @@ +0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/release_agent b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/release_agent new file mode 100644 index 000000000000..8b137891791f --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/release_agent @@ -0,0 +1 @@ + diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/tasks new file mode 100644 index 000000000000..27537f94a4b3 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/tasks @@ -0,0 +1,158 @@ +1 +2 +3 +5 +7 +8 +9 +10 +11 +13 +14 +15 +16 +18 +19 +20 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +40 +41 +42 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +123 +124 +151 +152 +155 +156 +157 +158 +171 +202 +272 +322 +323 +388 +519 +574 +575 +576 +620 +648 +659 +734 +748 +750 +752 +753 +754 +755 +756 +771 +772 +773 +777 +778 +795 +797 +798 +799 +809 +816 +840 +885 +886 +887 +909 +911 +912 +969 +975 +976 +977 +978 +979 +989 +1056 +1154 +1161 +1293 +1294 +1296 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/cgroup.clone_children b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/cgroup.clone_children new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/cgroup.clone_children @@ -0,0 +1 @@ +0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/cgroup.event_control b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/cgroup.event_control new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/cgroup.sane_behavior b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/cgroup.sane_behavior new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/cgroup.sane_behavior @@ -0,0 +1 @@ +0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release @@ -0,0 +1 @@ +0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks new file mode 100644 index 000000000000..16ae34357356 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks @@ -0,0 +1,37 @@ +985 +1006 +1007 +1008 +1009 +1010 +1011 +1012 +1013 +1014 +1015 +1016 +1017 +1018 +1019 +1020 +1021 +1048 +1049 +1052 +1053 +1054 +1055 +1057 +1058 +1059 +1060 +1061 +1062 +1063 +1064 +1065 +1066 +1067 +1068 +1069 +1070 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/notify_on_release new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/notify_on_release @@ -0,0 +1 @@ +0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/tasks new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/memory.force_empty b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/memory.force_empty new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/memory.move_charge_at_immigrate b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/memory.move_charge_at_immigrate new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/memory.move_charge_at_immigrate @@ -0,0 +1 @@ +0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/memory.use_hierarchy b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/memory.use_hierarchy new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/memory.use_hierarchy @@ -0,0 +1 @@ +0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/notify_on_release new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/notify_on_release @@ -0,0 +1 @@ +0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/release_agent b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/release_agent new file mode 100644 index 000000000000..8b137891791f --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/release_agent @@ -0,0 +1 @@ + diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/tasks new file mode 100644 index 000000000000..27537f94a4b3 --- /dev/null +++ b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/tasks @@ -0,0 +1,158 @@ +1 +2 +3 +5 +7 +8 +9 +10 +11 +13 +14 +15 +16 +18 +19 +20 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +40 +41 +42 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +123 +124 +151 +152 +155 +156 +157 +158 +171 +202 +272 +322 +323 +388 +519 +574 +575 +576 +620 +648 +659 +734 +748 +750 +752 +753 +754 +755 +756 +771 +772 +773 +777 +778 +795 +797 +798 +799 +809 +816 +840 +885 +886 +887 +909 +911 +912 +969 +975 +976 +977 +978 +979 +989 +1056 +1154 +1161 +1293 +1294 +1296 diff --git a/libbeat/processors/add_cloud_metadata/generic_fetcher.go b/libbeat/processors/add_cloud_metadata/generic_fetcher.go index bc34d6bcc628..9e41422319ef 100644 --- a/libbeat/processors/add_cloud_metadata/generic_fetcher.go +++ b/libbeat/processors/add_cloud_metadata/generic_fetcher.go @@ -19,6 +19,7 @@ package add_cloud_metadata import ( "context" + "fmt" "net/http" cfg "github.com/elastic/elastic-agent-libs/config" @@ -48,8 +49,7 @@ func (g *genericFetcher) fetchMetadata(ctx context.Context, client http.Client) if res.err != nil { return res } - // Apply schema. - res.metadata = g.conv(res.metadata) + fmt.Printf("res: %s", res) res.metadata.Put("cloud.provider", g.provider) return res diff --git a/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go b/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go index b3504effddf4..c10f8adabfc2 100644 --- a/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go +++ b/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go @@ -32,7 +32,7 @@ import ( conf "github.com/elastic/elastic-agent-libs/config" ) -//TODO: adjust tests and delete consts: +// TODO: adjust tests and delete consts: const ( ec2InstanceIdentityURI = "/2014-02-25/dynamic/instance-identity/document" ec2InstanceIMDSv2TokenValueHeader = "X-aws-ec2-metadata-token" @@ -75,18 +75,20 @@ func fetchRawProviderMetadata( // LoadDefaultConfig loads the Ec2 role credentials awsConfig, err := awscfg.LoadDefaultConfig(context.TODO(), awscfg.WithHTTPClient(&client)) if err != nil { - logger.Warnf("error when loading AWS default configuration: %s.", err) + logger.Debugf("error loading AWS default configuration: %s.", err) + return } awsClient := imds.NewFromConfig(awsConfig) instanceIdentity, err := awsClient.GetInstanceIdentityDocument(context.TODO(), &imds.GetInstanceIdentityDocumentInput{}) if err != nil { - logger.Warnf("error when fetching EC2 Identity Document: %s.", err) + logger.Warnf("error fetching EC2 Identity Document: %s.", err) } // Region must be set to be able to get EC2 Tags - awsConfig.Region = instanceIdentity.Region + awsRegion := instanceIdentity.InstanceIdentityDocument.Region + awsConfig.Region = awsRegion svc := ec2.NewFromConfig(awsConfig) input := &ec2.DescribeTagsInput{ @@ -108,13 +110,13 @@ func fetchRawProviderMetadata( tagsResult, err := svc.DescribeTags(context.TODO(), input) if err != nil { - logger.Warnf("error when fetching EC2 Tags: %s.", err) + logger.Warnf("error fetching EC2 Tags: %s.", err) } result.metadata.Put("cloud.orchestrator.cluster.name", tagsResult.Tags[0].Value) result.metadata.Put("cloud.instance.id", instanceIdentity.InstanceIdentityDocument.InstanceID) result.metadata.Put("cloud.machine.type", instanceIdentity.InstanceIdentityDocument.InstanceType) - result.metadata.Put("cloud.region", instanceIdentity.InstanceIdentityDocument.Region) + result.metadata.Put("cloud.region", awsRegion) result.metadata.Put("cloud.availability_zone", instanceIdentity.InstanceIdentityDocument.AvailabilityZone) result.metadata.Put("cloud.account.id", instanceIdentity.InstanceIdentityDocument.AccountID) result.metadata.Put("cloud.image.id", instanceIdentity.InstanceIdentityDocument.ImageID) From 176992664c387ca1e9c9a8acff3aa222d07f1a86 Mon Sep 17 00:00:00 2001 From: Tetiana Kravchenko Date: Mon, 10 Apr 2023 13:52:15 +0200 Subject: [PATCH 12/24] clean up Signed-off-by: Tetiana Kravchenko --- .../sys/fs/cgroup/blkio/cgroup.clone_children | 1 - .../sys/fs/cgroup/blkio/cgroup.sane_behavior | 1 - .../notify_on_release | 1 - .../tasks | 1 - .../fs/cgroup/blkio/docker/notify_on_release | 1 - .../docker/sys/fs/cgroup/blkio/docker/tasks | 0 .../sys/fs/cgroup/blkio/notify_on_release | 1 - .../docker/sys/fs/cgroup/blkio/release_agent | 1 - .../testdata/docker/sys/fs/cgroup/blkio/tasks | 158 ------------------ .../sys/fs/cgroup/cpu/cgroup.clone_children | 1 - .../sys/fs/cgroup/cpu/cgroup.sane_behavior | 1 - .../notify_on_release | 1 - .../tasks | 37 ---- .../fs/cgroup/cpu/docker/notify_on_release | 1 - .../docker/sys/fs/cgroup/cpu/docker/tasks | 0 .../sys/fs/cgroup/cpu/notify_on_release | 1 - .../docker/sys/fs/cgroup/cpu/release_agent | 1 - .../testdata/docker/sys/fs/cgroup/cpu/tasks | 158 ------------------ .../fs/cgroup/cpuacct/cgroup.clone_children | 1 - .../fs/cgroup/cpuacct/cgroup.sane_behavior | 1 - .../notify_on_release | 1 - .../tasks | 37 ---- .../cgroup/cpuacct/docker/notify_on_release | 1 - .../docker/sys/fs/cgroup/cpuacct/docker/tasks | 0 .../sys/fs/cgroup/cpuacct/notify_on_release | 1 - .../sys/fs/cgroup/cpuacct/release_agent | 1 - .../docker/sys/fs/cgroup/cpuacct/tasks | 158 ------------------ .../sys/fs/cgroup/cpuset/cgroup.sane_behavior | 1 - .../notify_on_release | 1 - .../tasks | 37 ---- .../fs/cgroup/cpuset/docker/notify_on_release | 1 - .../docker/sys/fs/cgroup/cpuset/docker/tasks | 0 .../sys/fs/cgroup/cpuset/notify_on_release | 1 - .../docker/sys/fs/cgroup/cpuset/release_agent | 1 - .../docker/sys/fs/cgroup/cpuset/tasks | 158 ------------------ .../fs/cgroup/memory/cgroup.clone_children | 1 - .../sys/fs/cgroup/memory/cgroup.event_control | 0 .../sys/fs/cgroup/memory/cgroup.sane_behavior | 1 - .../notify_on_release | 1 - .../tasks | 37 ---- .../fs/cgroup/memory/docker/notify_on_release | 1 - .../docker/sys/fs/cgroup/memory/docker/tasks | 0 .../sys/fs/cgroup/memory/memory.force_empty | 0 .../memory/memory.move_charge_at_immigrate | 1 - .../sys/fs/cgroup/memory/memory.use_hierarchy | 1 - .../sys/fs/cgroup/memory/notify_on_release | 1 - .../docker/sys/fs/cgroup/memory/release_agent | 1 - .../docker/sys/fs/cgroup/memory/tasks | 158 ------------------ 48 files changed, 970 deletions(-) delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/cgroup.clone_children delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/cgroup.sane_behavior delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/notify_on_release delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/tasks delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/notify_on_release delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/release_agent delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/tasks delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/cgroup.clone_children delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/cgroup.sane_behavior delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/notify_on_release delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/tasks delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/notify_on_release delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/release_agent delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/tasks delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/cgroup.clone_children delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/cgroup.sane_behavior delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/notify_on_release delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/tasks delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/notify_on_release delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/release_agent delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/tasks delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/cgroup.sane_behavior delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/notify_on_release delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/tasks delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/notify_on_release delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/release_agent delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/tasks delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/cgroup.clone_children delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/cgroup.event_control delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/cgroup.sane_behavior delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/notify_on_release delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/tasks delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/memory.force_empty delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/memory.move_charge_at_immigrate delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/memory.use_hierarchy delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/notify_on_release delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/release_agent delete mode 100644 libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/tasks diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/cgroup.clone_children b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/cgroup.clone_children deleted file mode 100644 index 573541ac9702..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/cgroup.clone_children +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/cgroup.sane_behavior b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/cgroup.sane_behavior deleted file mode 100644 index 573541ac9702..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/cgroup.sane_behavior +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release deleted file mode 100644 index 573541ac9702..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks deleted file mode 100644 index 2ab15755dfe0..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks +++ /dev/null @@ -1 +0,0 @@ -11668 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/notify_on_release deleted file mode 100644 index 573541ac9702..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/notify_on_release +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/docker/tasks deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/notify_on_release deleted file mode 100644 index 573541ac9702..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/notify_on_release +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/release_agent b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/release_agent deleted file mode 100644 index 8b137891791f..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/release_agent +++ /dev/null @@ -1 +0,0 @@ - diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/tasks deleted file mode 100644 index 27537f94a4b3..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/blkio/tasks +++ /dev/null @@ -1,158 +0,0 @@ -1 -2 -3 -5 -7 -8 -9 -10 -11 -13 -14 -15 -16 -18 -19 -20 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -40 -41 -42 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -123 -124 -151 -152 -155 -156 -157 -158 -171 -202 -272 -322 -323 -388 -519 -574 -575 -576 -620 -648 -659 -734 -748 -750 -752 -753 -754 -755 -756 -771 -772 -773 -777 -778 -795 -797 -798 -799 -809 -816 -840 -885 -886 -887 -909 -911 -912 -969 -975 -976 -977 -978 -979 -989 -1056 -1154 -1161 -1293 -1294 -1296 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/cgroup.clone_children b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/cgroup.clone_children deleted file mode 100644 index 573541ac9702..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/cgroup.clone_children +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/cgroup.sane_behavior b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/cgroup.sane_behavior deleted file mode 100644 index 573541ac9702..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/cgroup.sane_behavior +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release deleted file mode 100644 index 573541ac9702..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks deleted file mode 100644 index 16ae34357356..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks +++ /dev/null @@ -1,37 +0,0 @@ -985 -1006 -1007 -1008 -1009 -1010 -1011 -1012 -1013 -1014 -1015 -1016 -1017 -1018 -1019 -1020 -1021 -1048 -1049 -1052 -1053 -1054 -1055 -1057 -1058 -1059 -1060 -1061 -1062 -1063 -1064 -1065 -1066 -1067 -1068 -1069 -1070 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/notify_on_release deleted file mode 100644 index 573541ac9702..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/notify_on_release +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/docker/tasks deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/notify_on_release deleted file mode 100644 index 573541ac9702..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/notify_on_release +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/release_agent b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/release_agent deleted file mode 100644 index 8b137891791f..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/release_agent +++ /dev/null @@ -1 +0,0 @@ - diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/tasks deleted file mode 100644 index 27537f94a4b3..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpu/tasks +++ /dev/null @@ -1,158 +0,0 @@ -1 -2 -3 -5 -7 -8 -9 -10 -11 -13 -14 -15 -16 -18 -19 -20 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -40 -41 -42 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -123 -124 -151 -152 -155 -156 -157 -158 -171 -202 -272 -322 -323 -388 -519 -574 -575 -576 -620 -648 -659 -734 -748 -750 -752 -753 -754 -755 -756 -771 -772 -773 -777 -778 -795 -797 -798 -799 -809 -816 -840 -885 -886 -887 -909 -911 -912 -969 -975 -976 -977 -978 -979 -989 -1056 -1154 -1161 -1293 -1294 -1296 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/cgroup.clone_children b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/cgroup.clone_children deleted file mode 100644 index 573541ac9702..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/cgroup.clone_children +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/cgroup.sane_behavior b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/cgroup.sane_behavior deleted file mode 100644 index 573541ac9702..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/cgroup.sane_behavior +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release deleted file mode 100644 index 573541ac9702..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks deleted file mode 100644 index 16ae34357356..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks +++ /dev/null @@ -1,37 +0,0 @@ -985 -1006 -1007 -1008 -1009 -1010 -1011 -1012 -1013 -1014 -1015 -1016 -1017 -1018 -1019 -1020 -1021 -1048 -1049 -1052 -1053 -1054 -1055 -1057 -1058 -1059 -1060 -1061 -1062 -1063 -1064 -1065 -1066 -1067 -1068 -1069 -1070 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/notify_on_release deleted file mode 100644 index 573541ac9702..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/notify_on_release +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/docker/tasks deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/notify_on_release deleted file mode 100644 index 573541ac9702..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/notify_on_release +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/release_agent b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/release_agent deleted file mode 100644 index 8b137891791f..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/release_agent +++ /dev/null @@ -1 +0,0 @@ - diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/tasks deleted file mode 100644 index 27537f94a4b3..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuacct/tasks +++ /dev/null @@ -1,158 +0,0 @@ -1 -2 -3 -5 -7 -8 -9 -10 -11 -13 -14 -15 -16 -18 -19 -20 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -40 -41 -42 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -123 -124 -151 -152 -155 -156 -157 -158 -171 -202 -272 -322 -323 -388 -519 -574 -575 -576 -620 -648 -659 -734 -748 -750 -752 -753 -754 -755 -756 -771 -772 -773 -777 -778 -795 -797 -798 -799 -809 -816 -840 -885 -886 -887 -909 -911 -912 -969 -975 -976 -977 -978 -979 -989 -1056 -1154 -1161 -1293 -1294 -1296 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/cgroup.sane_behavior b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/cgroup.sane_behavior deleted file mode 100644 index 573541ac9702..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/cgroup.sane_behavior +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release deleted file mode 100644 index 573541ac9702..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks deleted file mode 100644 index 16ae34357356..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks +++ /dev/null @@ -1,37 +0,0 @@ -985 -1006 -1007 -1008 -1009 -1010 -1011 -1012 -1013 -1014 -1015 -1016 -1017 -1018 -1019 -1020 -1021 -1048 -1049 -1052 -1053 -1054 -1055 -1057 -1058 -1059 -1060 -1061 -1062 -1063 -1064 -1065 -1066 -1067 -1068 -1069 -1070 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/notify_on_release deleted file mode 100644 index 573541ac9702..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/notify_on_release +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/docker/tasks deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/notify_on_release deleted file mode 100644 index 573541ac9702..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/notify_on_release +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/release_agent b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/release_agent deleted file mode 100644 index 8b137891791f..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/release_agent +++ /dev/null @@ -1 +0,0 @@ - diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/tasks deleted file mode 100644 index 27537f94a4b3..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/cpuset/tasks +++ /dev/null @@ -1,158 +0,0 @@ -1 -2 -3 -5 -7 -8 -9 -10 -11 -13 -14 -15 -16 -18 -19 -20 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -40 -41 -42 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -123 -124 -151 -152 -155 -156 -157 -158 -171 -202 -272 -322 -323 -388 -519 -574 -575 -576 -620 -648 -659 -734 -748 -750 -752 -753 -754 -755 -756 -771 -772 -773 -777 -778 -795 -797 -798 -799 -809 -816 -840 -885 -886 -887 -909 -911 -912 -969 -975 -976 -977 -978 -979 -989 -1056 -1154 -1161 -1293 -1294 -1296 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/cgroup.clone_children b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/cgroup.clone_children deleted file mode 100644 index 573541ac9702..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/cgroup.clone_children +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/cgroup.event_control b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/cgroup.event_control deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/cgroup.sane_behavior b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/cgroup.sane_behavior deleted file mode 100644 index 573541ac9702..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/cgroup.sane_behavior +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release deleted file mode 100644 index 573541ac9702..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/notify_on_release +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks deleted file mode 100644 index 16ae34357356..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/b29faf21b7eff959f64b4192c34d5d67a707fe8561e9eaa608cb27693fba4242/tasks +++ /dev/null @@ -1,37 +0,0 @@ -985 -1006 -1007 -1008 -1009 -1010 -1011 -1012 -1013 -1014 -1015 -1016 -1017 -1018 -1019 -1020 -1021 -1048 -1049 -1052 -1053 -1054 -1055 -1057 -1058 -1059 -1060 -1061 -1062 -1063 -1064 -1065 -1066 -1067 -1068 -1069 -1070 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/notify_on_release deleted file mode 100644 index 573541ac9702..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/notify_on_release +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/docker/tasks deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/memory.force_empty b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/memory.force_empty deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/memory.move_charge_at_immigrate b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/memory.move_charge_at_immigrate deleted file mode 100644 index 573541ac9702..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/memory.move_charge_at_immigrate +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/memory.use_hierarchy b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/memory.use_hierarchy deleted file mode 100644 index 573541ac9702..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/memory.use_hierarchy +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/notify_on_release b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/notify_on_release deleted file mode 100644 index 573541ac9702..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/notify_on_release +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/release_agent b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/release_agent deleted file mode 100644 index 8b137891791f..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/release_agent +++ /dev/null @@ -1 +0,0 @@ - diff --git a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/tasks b/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/tasks deleted file mode 100644 index 27537f94a4b3..000000000000 --- a/libbeat/metric/system/cgroup/testdata/docker/sys/fs/cgroup/memory/tasks +++ /dev/null @@ -1,158 +0,0 @@ -1 -2 -3 -5 -7 -8 -9 -10 -11 -13 -14 -15 -16 -18 -19 -20 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -40 -41 -42 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -123 -124 -151 -152 -155 -156 -157 -158 -171 -202 -272 -322 -323 -388 -519 -574 -575 -576 -620 -648 -659 -734 -748 -750 -752 -753 -754 -755 -756 -771 -772 -773 -777 -778 -795 -797 -798 -799 -809 -816 -840 -885 -886 -887 -909 -911 -912 -969 -975 -976 -977 -978 -979 -989 -1056 -1154 -1161 -1293 -1294 -1296 From 64439f3a6341fc251387b113f974ed128b79db3a Mon Sep 17 00:00:00 2001 From: Tetiana Kravchenko Date: Tue, 18 Apr 2023 17:56:56 +0200 Subject: [PATCH 13/24] move tagDescribe to different func Signed-off-by: Tetiana Kravchenko --- .../add_cloud_metadata/provider_aws_ec2.go | 59 +-- .../provider_aws_ec2_test.go | 384 +++++++++++------- 2 files changed, 266 insertions(+), 177 deletions(-) diff --git a/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go b/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go index c10f8adabfc2..cd269f6fbdb5 100644 --- a/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go +++ b/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go @@ -19,6 +19,7 @@ package add_cloud_metadata import ( "context" + "fmt" "net/http" awssdk "github.com/aws/aws-sdk-go-v2/aws" @@ -32,15 +33,6 @@ import ( conf "github.com/elastic/elastic-agent-libs/config" ) -// TODO: adjust tests and delete consts: -const ( - ec2InstanceIdentityURI = "/2014-02-25/dynamic/instance-identity/document" - ec2InstanceIMDSv2TokenValueHeader = "X-aws-ec2-metadata-token" - ec2InstanceIMDSv2TokenTTLHeader = "X-aws-ec2-metadata-token-ttl-seconds" - ec2InstanceIMDSv2TokenTTLValue = "21600" - ec2InstanceIMDSv2TokenURI = "/latest/api/token" -) - // AWS EC2 Metadata Service var ec2MetadataFetcher = provider{ Name: "aws-ec2", @@ -67,12 +59,8 @@ func fetchRawProviderMetadata( result *result, ) { logger := logp.NewLogger("add_cloud_metadata") - // config := defaultConfig() - // if err := c.Unpack(&config); err != nil { - // logger.Warnf("error when load config for getting IMDSv2 token: %s. No token in the metadata request will be used.", err) - // } - // LoadDefaultConfig loads the Ec2 role credentials + // LoadDefaultConfig loads the EC2 role credentials awsConfig, err := awscfg.LoadDefaultConfig(context.TODO(), awscfg.WithHTTPClient(&client)) if err != nil { logger.Debugf("error loading AWS default configuration: %s.", err) @@ -86,23 +74,48 @@ func fetchRawProviderMetadata( logger.Warnf("error fetching EC2 Identity Document: %s.", err) } - // Region must be set to be able to get EC2 Tags + // AWS Region must be set to be able to get EC2 Tags awsRegion := instanceIdentity.InstanceIdentityDocument.Region awsConfig.Region = awsRegion + clusterName, err := fetchEC2ClusterNameTag(awsConfig, instanceIdentity.InstanceIdentityDocument.InstanceID) + if err != nil { + logger.Debugf("error fetching cluster name metadata: %s.", err) + } + + accountID := instanceIdentity.InstanceIdentityDocument.AccountID + + // for AWS cluster ID is used cluster ARN: arn:partition:service:region:account-id:resource-type/resource-id, example: + // arn:aws:eks:us-east-2:627286350134:cluster/cluster-name + if *clusterName != "" { + clusterARN := fmt.Sprintf("arn:aws:eks:%s:%s:cluster/%s", awsRegion, accountID, *clusterName) + + result.metadata.Put("cloud.orchestrator.cluster.name", clusterName) + result.metadata.Put("cloud.orchestrator.cluster.id", clusterARN) + } + + result.metadata.Put("cloud.instance.id", instanceIdentity.InstanceIdentityDocument.InstanceID) + result.metadata.Put("cloud.machine.type", instanceIdentity.InstanceIdentityDocument.InstanceType) + result.metadata.Put("cloud.region", awsRegion) + result.metadata.Put("cloud.availability_zone", instanceIdentity.InstanceIdentityDocument.AvailabilityZone) + result.metadata.Put("cloud.account.id", accountID) + result.metadata.Put("cloud.image.id", instanceIdentity.InstanceIdentityDocument.ImageID) +} + +func fetchEC2ClusterNameTag(awsConfig awssdk.Config, instanceID string) (*string, error) { svc := ec2.NewFromConfig(awsConfig) input := &ec2.DescribeTagsInput{ Filters: []types.Filter{ { Name: awssdk.String("resource-id"), Values: []string{ - *awssdk.String(instanceIdentity.InstanceIdentityDocument.InstanceID), + instanceID, }, }, { Name: awssdk.String("key"), Values: []string{ - *awssdk.String("eks:cluster-name"), + "eks:cluster-name", }, }, }, @@ -110,15 +123,7 @@ func fetchRawProviderMetadata( tagsResult, err := svc.DescribeTags(context.TODO(), input) if err != nil { - logger.Warnf("error fetching EC2 Tags: %s.", err) + return nil, fmt.Errorf("error fetching EC2 Tags: %s", err) } - - result.metadata.Put("cloud.orchestrator.cluster.name", tagsResult.Tags[0].Value) - result.metadata.Put("cloud.instance.id", instanceIdentity.InstanceIdentityDocument.InstanceID) - result.metadata.Put("cloud.machine.type", instanceIdentity.InstanceIdentityDocument.InstanceType) - result.metadata.Put("cloud.region", awsRegion) - result.metadata.Put("cloud.availability_zone", instanceIdentity.InstanceIdentityDocument.AvailabilityZone) - result.metadata.Put("cloud.account.id", instanceIdentity.InstanceIdentityDocument.AccountID) - result.metadata.Put("cloud.image.id", instanceIdentity.InstanceIdentityDocument.ImageID) - + return tagsResult.Tags[0].Value, nil } diff --git a/libbeat/processors/add_cloud_metadata/provider_aws_ec2_test.go b/libbeat/processors/add_cloud_metadata/provider_aws_ec2_test.go index b167917a97b0..5a88494fee24 100644 --- a/libbeat/processors/add_cloud_metadata/provider_aws_ec2_test.go +++ b/libbeat/processors/add_cloud_metadata/provider_aws_ec2_test.go @@ -18,21 +18,42 @@ package add_cloud_metadata import ( - "fmt" + "context" "net/http" "net/http/httptest" "os" "testing" + "github.com/aws/aws-sdk-go-v2/feature/ec2/imds" + "github.com/aws/aws-sdk-go-v2/service/ec2" "github.com/stretchr/testify/assert" "github.com/elastic/beats/v7/libbeat/beat" + "github.com/elastic/beats/v7/x-pack/metricbeat/module/aws" conf "github.com/elastic/elastic-agent-libs/config" "github.com/elastic/elastic-agent-libs/logp" "github.com/elastic/elastic-agent-libs/mapstr" ) -func createEC2MockAPI(responseMap map[string]string) *httptest.Server { +type MockIMDSClient struct { + imds.Client + GetInstanceIdentityDocumentFunc func(ctx context.Context, params *imds.GetInstanceIdentityDocumentInput, optFns ...func(*imds.Options)) (*imds.GetInstanceIdentityDocumentOutput, error) +} + +type MockEC2Client struct { + ec2.Client + DescribeTagsFunc func(ctx context.Context, params *ec2.DescribeTagsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeTagsOutput, error) +} + +func (m *MockIMDSClient) GetInstanceIdentityDocument(ctx context.Context, params *imds.GetInstanceIdentityDocumentInput, optFns ...func(*imds.Options)) (*imds.GetInstanceIdentityDocumentOutput, error) { + return m.GetInstanceIdentityDocumentFunc(ctx, params, optFns...) +} + +func (e *MockEC2Client) DescribeTags(ctx context.Context, params *ec2.DescribeTagsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeTagsOutput, error) { + return e.DescribeTagsFunc(ctx, params, optFns...) +} + +func createIMDSMockAPI(responseMap map[string]string) *httptest.Server { h := func(w http.ResponseWriter, r *http.Request) { if res, ok := responseMap[r.RequestURI]; ok { w.Write([]byte(res)) @@ -62,48 +83,59 @@ func TestRetrieveAWSMetadataEC2(t *testing.T) { instanceIDDoc1 = "i-11111111" imageIDDoc1 = "ami-abcd1234" instanceTypeDoc1 = "t2.medium" + clusterNameDoc1 = "test" instanceIDDoc2 = "i-22222222" - templateDoc = `{ - "accountId" : "%s", - "region" : "%s", - "availabilityZone" : "%s", - "instanceId" : "%s", - "imageId" : "%s", - "instanceType" : "%s", - "devpayProductCodes" : null, - "privateIp" : "10.0.0.1", - "version" : "2010-08-31", - "billingProducts" : null, - "pendingTime" : "2016-09-20T15:43:02Z", - "architecture" : "x86_64", - "kernelId" : null, - "ramdiskId" : null - }` - ) + // templateDoc = `{ + // "accountId" : "%s", + // "region" : "%s", + // "availabilityZone" : "%s", + // "instanceId" : "%s", + // "imageId" : "%s", + // "instanceType" : "%s", + // "devpayProductCodes" : null, + // "privateIp" : "10.0.0.1", + // "version" : "2010-08-31", + // "billingProducts" : null, + // "pendingTime" : "2016-09-20T15:43:02Z", + // "architecture" : "x86_64", + // "kernelId" : null, + // "ramdiskId" : null + // }` + // ) - sampleEC2Doc1 := fmt.Sprintf( - templateDoc, - accountIDDoc1, - regionDoc1, - availabilityZoneDoc1, - instanceIDDoc1, - imageIDDoc1, - instanceTypeDoc1, + // sampleEC2Doc1 := fmt.Sprintf( + // templateDoc, + // accountIDDoc1, + // regionDoc1, + // availabilityZoneDoc1, + // instanceIDDoc1, + // imageIDDoc1, + // instanceTypeDoc1, ) - var testCases = []struct { - testName string - ec2ResponseMap map[string]string - processorOverwrite bool - previousEvent mapstr.M - - expectedEvent mapstr.M + var tests = []struct { + testName string + mockGetInstanceIdentityDocumentFunc func(ctx context.Context, params *imds.GetInstanceIdentityDocumentInput, optFns ...func(*imds.Options)) (*imds.GetInstanceIdentityDocumentOutput, error) + processorOverwrite bool + previousEvent mapstr.M + expectedEvent mapstr.M }{ { - testName: "all fields from processor", - ec2ResponseMap: map[string]string{ec2InstanceIdentityURI: sampleEC2Doc1}, + testName: "valid instance identity document", + mockGetInstanceIdentityDocumentFunc: func(ctx context.Context, params *imds.GetInstanceIdentityDocumentInput, optFns ...func(*imds.Options)) (*imds.GetInstanceIdentityDocumentOutput, error) { + return &imds.GetInstanceIdentityDocumentOutput{ + InstanceIdentityDocument: imds.InstanceIdentityDocument{ + AvailabilityZone: availabilityZoneDoc1, + Region: regionDoc1, + InstanceID: instanceIDDoc1, + InstanceType: instanceTypeDoc1, + AccountID: accountIDDoc1, + ImageID: imageIDDoc1, + }, + }, nil + }, processorOverwrite: false, previousEvent: mapstr.M{}, expectedEvent: mapstr.M{ @@ -118,142 +150,194 @@ func TestRetrieveAWSMetadataEC2(t *testing.T) { "service": mapstr.M{ "name": "EC2", }, + // "orchestrator": mapstr.M{ + // "cluster": mapstr.M{ + // "name": clusterNameDoc1, + // "id": fmt.Sprintf("arn:aws:eks:%s:%s:cluster/%s", regionDoc1, accountIDDoc1, clusterNameDoc1), + // }, + // }, }, }, }, + } - { - testName: "instanceId pre-informed, no overwrite", - ec2ResponseMap: map[string]string{ec2InstanceIdentityURI: sampleEC2Doc1}, - processorOverwrite: false, - previousEvent: mapstr.M{ - "cloud": mapstr.M{ - "instance": mapstr.M{"id": instanceIDDoc2}, - }, - }, - expectedEvent: mapstr.M{ - "cloud": mapstr.M{ - "instance": mapstr.M{"id": instanceIDDoc2}, - }, - }, - }, + // var testCases = []struct { + // testName string + // ec2ResponseMap map[string]string + // processorOverwrite bool + // previousEvent mapstr.M - { - // NOTE: In this case, add_cloud_metadata will overwrite cloud fields because - // it won't detect cloud.provider as a cloud field. This is not the behavior we - // expect and will find a better solution later in issue 11697. - testName: "only cloud.provider pre-informed, no overwrite", - ec2ResponseMap: map[string]string{ec2InstanceIdentityURI: sampleEC2Doc1}, - processorOverwrite: false, - previousEvent: mapstr.M{ - "cloud.provider": "aws", - }, - expectedEvent: mapstr.M{ - "cloud.provider": "aws", - "cloud": mapstr.M{ - "provider": "aws", - "account": mapstr.M{"id": accountIDDoc1}, - "instance": mapstr.M{"id": instanceIDDoc1}, - "machine": mapstr.M{"type": instanceTypeDoc1}, - "image": mapstr.M{"id": imageIDDoc1}, - "region": regionDoc1, - "availability_zone": availabilityZoneDoc1, - "service": mapstr.M{ - "name": "EC2", - }, - }, - }, - }, + // expectedEvent mapstr.M + // }{ + // // { + // // testName: "all fields from processor", + // // ec2ResponseMap: map[string]string{ec2InstanceIdentityURI: sampleEC2Doc1}, + // // processorOverwrite: false, + // // previousEvent: mapstr.M{}, + // // expectedEvent: mapstr.M{ + // // "cloud": mapstr.M{ + // // "provider": "aws", + // // "account": mapstr.M{"id": accountIDDoc1}, + // // "instance": mapstr.M{"id": instanceIDDoc1}, + // // "machine": mapstr.M{"type": instanceTypeDoc1}, + // // "image": mapstr.M{"id": imageIDDoc1}, + // // "region": regionDoc1, + // // "availability_zone": availabilityZoneDoc1, + // // "service": mapstr.M{ + // // "name": "EC2", + // // }, + // // "orchestrator": mapstr.M{ + // // "cluster": mapstr.M{ + // // "name": clusterNameDoc1, + // // "id": fmt.Sprintf("arn:aws:eks:%s:%s:cluster/%s", regionDoc1, accountIDDoc1, clusterNameDoc1), + // // }, + // // }, + // // }, + // // }, + // // }, - { - testName: "all fields from processor, overwrite", - ec2ResponseMap: map[string]string{ec2InstanceIdentityURI: sampleEC2Doc1}, - processorOverwrite: true, - previousEvent: mapstr.M{}, - expectedEvent: mapstr.M{ - "cloud": mapstr.M{ - "provider": "aws", - "account": mapstr.M{"id": accountIDDoc1}, - "instance": mapstr.M{"id": instanceIDDoc1}, - "machine": mapstr.M{"type": instanceTypeDoc1}, - "image": mapstr.M{"id": imageIDDoc1}, - "region": regionDoc1, - "availability_zone": availabilityZoneDoc1, - "service": mapstr.M{ - "name": "EC2", - }, - }, - }, - }, + // // { + // // testName: "instanceId pre-informed, no overwrite", + // // ec2ResponseMap: map[string]string{ec2InstanceIdentityURI: sampleEC2Doc1}, + // // processorOverwrite: false, + // // previousEvent: mapstr.M{ + // // "cloud": mapstr.M{ + // // "instance": mapstr.M{"id": instanceIDDoc2}, + // // }, + // // }, + // // expectedEvent: mapstr.M{ + // // "cloud": mapstr.M{ + // // "instance": mapstr.M{"id": instanceIDDoc2}, + // // }, + // // }, + // // }, - { - testName: "instanceId pre-informed, overwrite", - ec2ResponseMap: map[string]string{ec2InstanceIdentityURI: sampleEC2Doc1}, - processorOverwrite: true, - previousEvent: mapstr.M{ - "cloud": mapstr.M{ - "instance": mapstr.M{"id": instanceIDDoc2}, - }, - }, - expectedEvent: mapstr.M{ - "cloud": mapstr.M{ - "provider": "aws", - "account": mapstr.M{"id": accountIDDoc1}, - "instance": mapstr.M{"id": instanceIDDoc1}, - "machine": mapstr.M{"type": instanceTypeDoc1}, - "image": mapstr.M{"id": imageIDDoc1}, - "region": regionDoc1, - "availability_zone": availabilityZoneDoc1, - "service": mapstr.M{ - "name": "EC2", - }, - }, - }, - }, + // // { + // // // NOTE: In this case, add_cloud_metadata will overwrite cloud fields because + // // // it won't detect cloud.provider as a cloud field. This is not the behavior we + // // // expect and will find a better solution later in issue 11697. + // // testName: "only cloud.provider pre-informed, no overwrite", + // // ec2ResponseMap: map[string]string{ec2InstanceIdentityURI: sampleEC2Doc1}, + // // processorOverwrite: false, + // // previousEvent: mapstr.M{ + // // "cloud.provider": "aws", + // // }, + // // expectedEvent: mapstr.M{ + // // "cloud.provider": "aws", + // // "cloud": mapstr.M{ + // // "provider": "aws", + // // "account": mapstr.M{"id": accountIDDoc1}, + // // "instance": mapstr.M{"id": instanceIDDoc1}, + // // "machine": mapstr.M{"type": instanceTypeDoc1}, + // // "image": mapstr.M{"id": imageIDDoc1}, + // // "region": regionDoc1, + // // "availability_zone": availabilityZoneDoc1, + // // "service": mapstr.M{ + // // "name": "EC2", + // // }, + // // }, + // // }, + // // }, - { - testName: "only cloud.provider pre-informed, overwrite", - ec2ResponseMap: map[string]string{ec2InstanceIdentityURI: sampleEC2Doc1}, - processorOverwrite: false, - previousEvent: mapstr.M{ - "cloud.provider": "aws", - }, - expectedEvent: mapstr.M{ - "cloud.provider": "aws", - "cloud": mapstr.M{ - "provider": "aws", - "account": mapstr.M{"id": accountIDDoc1}, - "instance": mapstr.M{"id": instanceIDDoc1}, - "machine": mapstr.M{"type": instanceTypeDoc1}, - "image": mapstr.M{"id": imageIDDoc1}, - "region": regionDoc1, - "availability_zone": availabilityZoneDoc1, - "service": mapstr.M{ - "name": "EC2", - }, - }, - }, - }, - } + // // { + // // testName: "all fields from processor, overwrite", + // // ec2ResponseMap: map[string]string{ec2InstanceIdentityURI: sampleEC2Doc1}, + // // processorOverwrite: true, + // // previousEvent: mapstr.M{}, + // // expectedEvent: mapstr.M{ + // // "cloud": mapstr.M{ + // // "provider": "aws", + // // "account": mapstr.M{"id": accountIDDoc1}, + // // "instance": mapstr.M{"id": instanceIDDoc1}, + // // "machine": mapstr.M{"type": instanceTypeDoc1}, + // // "image": mapstr.M{"id": imageIDDoc1}, + // // "region": regionDoc1, + // // "availability_zone": availabilityZoneDoc1, + // // "service": mapstr.M{ + // // "name": "EC2", + // // }, + // // }, + // // }, + // // }, + + // // { + // // testName: "instanceId pre-informed, overwrite", + // // ec2ResponseMap: map[string]string{ec2InstanceIdentityURI: sampleEC2Doc1}, + // // processorOverwrite: true, + // // previousEvent: mapstr.M{ + // // "cloud": mapstr.M{ + // // "instance": mapstr.M{"id": instanceIDDoc2}, + // // }, + // // }, + // // expectedEvent: mapstr.M{ + // // "cloud": mapstr.M{ + // // "provider": "aws", + // // "account": mapstr.M{"id": accountIDDoc1}, + // // "instance": mapstr.M{"id": instanceIDDoc1}, + // // "machine": mapstr.M{"type": instanceTypeDoc1}, + // // "image": mapstr.M{"id": imageIDDoc1}, + // // "region": regionDoc1, + // // "availability_zone": availabilityZoneDoc1, + // // "service": mapstr.M{ + // // "name": "EC2", + // // }, + // // }, + // // }, + // // }, + + // // { + // // testName: "only cloud.provider pre-informed, overwrite", + // // ec2ResponseMap: map[string]string{ec2InstanceIdentityURI: sampleEC2Doc1}, + // // processorOverwrite: false, + // // previousEvent: mapstr.M{ + // // "cloud.provider": "aws", + // // }, + // // expectedEvent: mapstr.M{ + // // "cloud.provider": "aws", + // // "cloud": mapstr.M{ + // // "provider": "aws", + // // "account": mapstr.M{"id": accountIDDoc1}, + // // "instance": mapstr.M{"id": instanceIDDoc1}, + // // "machine": mapstr.M{"type": instanceTypeDoc1}, + // // "image": mapstr.M{"id": imageIDDoc1}, + // // "region": regionDoc1, + // // "availability_zone": availabilityZoneDoc1, + // // "service": mapstr.M{ + // // "name": "EC2", + // // }, + // // }, + // // }, + // // }, + // } - for _, tc := range testCases { + for _, tc := range tests { t.Run(tc.testName, func(t *testing.T) { - server := createEC2MockAPI(tc.ec2ResponseMap) - defer server.Close() + + mockClient := &MockIMDSClient{ + GetInstanceIdentityDocumentFunc: tc.mockGetInstanceIdentityDocumentFunc, + } + + oldNewFromConfig := imds.NewFromConfig + imds.NewFromConfig = func(cfg aws.Config, optFns ...func(*imds.Options)) *imds.Client { + return (*imds.Client)(mockClient) + } + defer func() { imds.NewFromConfig = oldNewFromConfig }() config, err := conf.NewConfigFrom(map[string]interface{}{ - "host": server.Listener.Addr().String(), "overwrite": tc.processorOverwrite, }) if err != nil { t.Fatalf("error creating config from map: %s", err.Error()) } - cmp, err := New(config) if err != nil { t.Fatalf("error creating new metadata processor: %s", err.Error()) } + // client := http.Client{} + // res := result{provider: "ec2", metadata: mapstr.M{}} + // fetchRawProviderMetadata(context.Background(), client, &res) + actual, err := cmp.Run(&beat.Event{Fields: tc.previousEvent}) if err != nil { t.Fatalf("error running processor: %s", err.Error()) From bbd928c33634e1342b37383a03ced6dd7d3c2758 Mon Sep 17 00:00:00 2001 From: Tetiana Kravchenko Date: Mon, 24 Apr 2023 09:38:51 +0200 Subject: [PATCH 14/24] add tests for add_cloud_metadata Signed-off-by: Tetiana Kravchenko --- .../add_cloud_metadata/generic_fetcher.go | 5 +- .../add_cloud_metadata/provider_aws_ec2.go | 52 ++-- .../provider_aws_ec2_test.go | 227 ++++++++---------- 3 files changed, 140 insertions(+), 144 deletions(-) diff --git a/libbeat/processors/add_cloud_metadata/generic_fetcher.go b/libbeat/processors/add_cloud_metadata/generic_fetcher.go index 9e41422319ef..4467c1e49030 100644 --- a/libbeat/processors/add_cloud_metadata/generic_fetcher.go +++ b/libbeat/processors/add_cloud_metadata/generic_fetcher.go @@ -19,7 +19,6 @@ package add_cloud_metadata import ( "context" - "fmt" "net/http" cfg "github.com/elastic/elastic-agent-libs/config" @@ -28,7 +27,7 @@ import ( type genericFetcher struct { provider string - conv schemaConv + schema schemaConv fetchRawProviderMetadata func(context.Context, http.Client, *result) } @@ -49,7 +48,7 @@ func (g *genericFetcher) fetchMetadata(ctx context.Context, client http.Client) if res.err != nil { return res } - fmt.Printf("res: %s", res) + res.metadata = g.schema(res.metadata) res.metadata.Put("cloud.provider", g.provider) return res diff --git a/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go b/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go index cd269f6fbdb5..e92b08e89228 100644 --- a/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go +++ b/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go @@ -33,6 +33,22 @@ import ( conf "github.com/elastic/elastic-agent-libs/config" ) +type IMDSClient interface { + GetInstanceIdentityDocument(ctx context.Context, params *imds.GetInstanceIdentityDocumentInput, optFns ...func(*imds.Options)) (*imds.GetInstanceIdentityDocumentOutput, error) +} + +var NewIMDSClient func(cfg awssdk.Config) IMDSClient = func(cfg awssdk.Config) IMDSClient { + return imds.NewFromConfig(cfg) +} + +type EC2Client interface { + DescribeTags(ctx context.Context, params *ec2.DescribeTagsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeTagsOutput, error) +} + +var NewEC2Client func(cfg awssdk.Config) EC2Client = func(cfg awssdk.Config) EC2Client { + return ec2.NewFromConfig(cfg) +} + // AWS EC2 Metadata Service var ec2MetadataFetcher = provider{ Name: "aws-ec2", @@ -66,8 +82,7 @@ func fetchRawProviderMetadata( logger.Debugf("error loading AWS default configuration: %s.", err) return } - - awsClient := imds.NewFromConfig(awsConfig) + awsClient := NewIMDSClient(awsConfig) instanceIdentity, err := awsClient.GetInstanceIdentityDocument(context.TODO(), &imds.GetInstanceIdentityDocumentInput{}) if err != nil { @@ -85,25 +100,25 @@ func fetchRawProviderMetadata( accountID := instanceIdentity.InstanceIdentityDocument.AccountID + result.metadata.Put("instance.id", instanceIdentity.InstanceIdentityDocument.InstanceID) + result.metadata.Put("machine.type", instanceIdentity.InstanceIdentityDocument.InstanceType) + result.metadata.Put("region", awsRegion) + result.metadata.Put("availability_zone", instanceIdentity.InstanceIdentityDocument.AvailabilityZone) + result.metadata.Put("account.id", accountID) + result.metadata.Put("image.id", instanceIdentity.InstanceIdentityDocument.ImageID) + // for AWS cluster ID is used cluster ARN: arn:partition:service:region:account-id:resource-type/resource-id, example: // arn:aws:eks:us-east-2:627286350134:cluster/cluster-name - if *clusterName != "" { - clusterARN := fmt.Sprintf("arn:aws:eks:%s:%s:cluster/%s", awsRegion, accountID, *clusterName) + if clusterName != "" { + clusterARN := fmt.Sprintf("arn:aws:eks:%s:%s:cluster/%v", awsRegion, accountID, clusterName) - result.metadata.Put("cloud.orchestrator.cluster.name", clusterName) - result.metadata.Put("cloud.orchestrator.cluster.id", clusterARN) + result.metadata.Put("orchestrator.cluster.name", clusterName) + result.metadata.Put("orchestrator.cluster.id", clusterARN) } - - result.metadata.Put("cloud.instance.id", instanceIdentity.InstanceIdentityDocument.InstanceID) - result.metadata.Put("cloud.machine.type", instanceIdentity.InstanceIdentityDocument.InstanceType) - result.metadata.Put("cloud.region", awsRegion) - result.metadata.Put("cloud.availability_zone", instanceIdentity.InstanceIdentityDocument.AvailabilityZone) - result.metadata.Put("cloud.account.id", accountID) - result.metadata.Put("cloud.image.id", instanceIdentity.InstanceIdentityDocument.ImageID) } -func fetchEC2ClusterNameTag(awsConfig awssdk.Config, instanceID string) (*string, error) { - svc := ec2.NewFromConfig(awsConfig) +func fetchEC2ClusterNameTag(awsConfig awssdk.Config, instanceID string) (string, error) { + svc := NewEC2Client(awsConfig) input := &ec2.DescribeTagsInput{ Filters: []types.Filter{ { @@ -123,7 +138,10 @@ func fetchEC2ClusterNameTag(awsConfig awssdk.Config, instanceID string) (*string tagsResult, err := svc.DescribeTags(context.TODO(), input) if err != nil { - return nil, fmt.Errorf("error fetching EC2 Tags: %s", err) + return "", fmt.Errorf("error fetching EC2 Tags: %s", err) + } + if len(tagsResult.Tags) > 0 { + return *tagsResult.Tags[0].Value, nil } - return tagsResult.Tags[0].Value, nil + return "", nil } diff --git a/libbeat/processors/add_cloud_metadata/provider_aws_ec2_test.go b/libbeat/processors/add_cloud_metadata/provider_aws_ec2_test.go index 5a88494fee24..426909de2255 100644 --- a/libbeat/processors/add_cloud_metadata/provider_aws_ec2_test.go +++ b/libbeat/processors/add_cloud_metadata/provider_aws_ec2_test.go @@ -19,56 +19,42 @@ package add_cloud_metadata import ( "context" - "net/http" - "net/http/httptest" + "fmt" "os" "testing" + awssdk "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/feature/ec2/imds" "github.com/aws/aws-sdk-go-v2/service/ec2" + "github.com/aws/aws-sdk-go-v2/service/ec2/types" "github.com/stretchr/testify/assert" "github.com/elastic/beats/v7/libbeat/beat" - "github.com/elastic/beats/v7/x-pack/metricbeat/module/aws" conf "github.com/elastic/elastic-agent-libs/config" "github.com/elastic/elastic-agent-libs/logp" "github.com/elastic/elastic-agent-libs/mapstr" ) type MockIMDSClient struct { - imds.Client GetInstanceIdentityDocumentFunc func(ctx context.Context, params *imds.GetInstanceIdentityDocumentInput, optFns ...func(*imds.Options)) (*imds.GetInstanceIdentityDocumentOutput, error) } -type MockEC2Client struct { - ec2.Client - DescribeTagsFunc func(ctx context.Context, params *ec2.DescribeTagsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeTagsOutput, error) -} - func (m *MockIMDSClient) GetInstanceIdentityDocument(ctx context.Context, params *imds.GetInstanceIdentityDocumentInput, optFns ...func(*imds.Options)) (*imds.GetInstanceIdentityDocumentOutput, error) { return m.GetInstanceIdentityDocumentFunc(ctx, params, optFns...) } -func (e *MockEC2Client) DescribeTags(ctx context.Context, params *ec2.DescribeTagsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeTagsOutput, error) { - return e.DescribeTagsFunc(ctx, params, optFns...) +type MockEC2Client struct { + DescribeTagsFunc func(ctx context.Context, params *ec2.DescribeTagsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeTagsOutput, error) } -func createIMDSMockAPI(responseMap map[string]string) *httptest.Server { - h := func(w http.ResponseWriter, r *http.Request) { - if res, ok := responseMap[r.RequestURI]; ok { - w.Write([]byte(res)) - return - } - http.Error(w, "not found", http.StatusNotFound) - } - return httptest.NewServer(http.HandlerFunc(h)) +func (e *MockEC2Client) DescribeTags(ctx context.Context, params *ec2.DescribeTagsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeTagsOutput, error) { + return e.DescribeTagsFunc(ctx, params, optFns...) } func TestMain(m *testing.M) { logp.TestingSetup() code := m.Run() os.Exit(code) - } func TestRetrieveAWSMetadataEC2(t *testing.T) { @@ -80,51 +66,28 @@ func TestRetrieveAWSMetadataEC2(t *testing.T) { accountIDDoc1 = "111111111111111" regionDoc1 = "us-east-1" availabilityZoneDoc1 = "us-east-1c" - instanceIDDoc1 = "i-11111111" imageIDDoc1 = "ami-abcd1234" instanceTypeDoc1 = "t2.medium" - clusterNameDoc1 = "test" - - instanceIDDoc2 = "i-22222222" - - // templateDoc = `{ - // "accountId" : "%s", - // "region" : "%s", - // "availabilityZone" : "%s", - // "instanceId" : "%s", - // "imageId" : "%s", - // "instanceType" : "%s", - // "devpayProductCodes" : null, - // "privateIp" : "10.0.0.1", - // "version" : "2010-08-31", - // "billingProducts" : null, - // "pendingTime" : "2016-09-20T15:43:02Z", - // "architecture" : "x86_64", - // "kernelId" : null, - // "ramdiskId" : null - // }` - // ) - - // sampleEC2Doc1 := fmt.Sprintf( - // templateDoc, - // accountIDDoc1, - // regionDoc1, - // availabilityZoneDoc1, - // instanceIDDoc1, - // imageIDDoc1, - // instanceTypeDoc1, + instanceIDDoc2 = "i-22222222" + ) + var ( + clusterNameKey string = "eks:cluster-name" + clusterNameValue string = "test" + instanceIDKey string = "resource-id" + instanceIDDoc1 string = "i-11111111" ) var tests = []struct { - testName string - mockGetInstanceIdentityDocumentFunc func(ctx context.Context, params *imds.GetInstanceIdentityDocumentInput, optFns ...func(*imds.Options)) (*imds.GetInstanceIdentityDocumentOutput, error) - processorOverwrite bool - previousEvent mapstr.M - expectedEvent mapstr.M + testName string + mockGetInstanceIdentity func(ctx context.Context, params *imds.GetInstanceIdentityDocumentInput, optFns ...func(*imds.Options)) (*imds.GetInstanceIdentityDocumentOutput, error) + mockEc2Tags func(ctx context.Context, params *ec2.DescribeTagsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeTagsOutput, error) + processorOverwrite bool + previousEvent mapstr.M + expectedEvent mapstr.M }{ { - testName: "valid instance identity document", - mockGetInstanceIdentityDocumentFunc: func(ctx context.Context, params *imds.GetInstanceIdentityDocumentInput, optFns ...func(*imds.Options)) (*imds.GetInstanceIdentityDocumentOutput, error) { + testName: "valid instance identity document, no cluster tags", + mockGetInstanceIdentity: func(ctx context.Context, params *imds.GetInstanceIdentityDocumentInput, optFns ...func(*imds.Options)) (*imds.GetInstanceIdentityDocumentOutput, error) { return &imds.GetInstanceIdentityDocumentOutput{ InstanceIdentityDocument: imds.InstanceIdentityDocument{ AvailabilityZone: availabilityZoneDoc1, @@ -136,6 +99,11 @@ func TestRetrieveAWSMetadataEC2(t *testing.T) { }, }, nil }, + mockEc2Tags: func(ctx context.Context, params *ec2.DescribeTagsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeTagsOutput, error) { + return &ec2.DescribeTagsOutput{ + Tags: []types.TagDescription{}, + }, nil + }, processorOverwrite: false, previousEvent: mapstr.M{}, expectedEvent: mapstr.M{ @@ -147,70 +115,74 @@ func TestRetrieveAWSMetadataEC2(t *testing.T) { "image": mapstr.M{"id": imageIDDoc1}, "region": regionDoc1, "availability_zone": availabilityZoneDoc1, - "service": mapstr.M{ - "name": "EC2", + "service": mapstr.M{"name": "EC2"}, + }, + }, + }, + { + testName: "all fields from processor", + mockGetInstanceIdentity: func(ctx context.Context, params *imds.GetInstanceIdentityDocumentInput, optFns ...func(*imds.Options)) (*imds.GetInstanceIdentityDocumentOutput, error) { + return &imds.GetInstanceIdentityDocumentOutput{ + InstanceIdentityDocument: imds.InstanceIdentityDocument{ + AvailabilityZone: availabilityZoneDoc1, + Region: regionDoc1, + InstanceID: instanceIDDoc1, + InstanceType: instanceTypeDoc1, + AccountID: accountIDDoc1, + ImageID: imageIDDoc1, + }, + }, nil + }, + mockEc2Tags: func(ctx context.Context, params *ec2.DescribeTagsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeTagsOutput, error) { + return &ec2.DescribeTagsOutput{ + Tags: []types.TagDescription{ + { + Key: &clusterNameKey, + Value: &clusterNameValue, + }, { + Key: &instanceIDKey, + Value: &instanceIDDoc1, + }, + }, + }, nil + }, + processorOverwrite: false, + previousEvent: mapstr.M{}, + expectedEvent: mapstr.M{ + "cloud": mapstr.M{ + "provider": "aws", + "account": mapstr.M{"id": accountIDDoc1}, + "instance": mapstr.M{"id": instanceIDDoc1}, + "machine": mapstr.M{"type": instanceTypeDoc1}, + "image": mapstr.M{"id": imageIDDoc1}, + "region": regionDoc1, + "availability_zone": availabilityZoneDoc1, + "service": mapstr.M{"name": "EC2"}, + "orchestrator": mapstr.M{ + "cluster": mapstr.M{ + "name": clusterNameValue, + "id": fmt.Sprintf("arn:aws:eks:%s:%s:cluster/%s", regionDoc1, accountIDDoc1, clusterNameValue), + }, }, - // "orchestrator": mapstr.M{ - // "cluster": mapstr.M{ - // "name": clusterNameDoc1, - // "id": fmt.Sprintf("arn:aws:eks:%s:%s:cluster/%s", regionDoc1, accountIDDoc1, clusterNameDoc1), - // }, - // }, }, }, }, } - - // var testCases = []struct { - // testName string - // ec2ResponseMap map[string]string - // processorOverwrite bool - // previousEvent mapstr.M - - // expectedEvent mapstr.M - // }{ - // // { - // // testName: "all fields from processor", - // // ec2ResponseMap: map[string]string{ec2InstanceIdentityURI: sampleEC2Doc1}, - // // processorOverwrite: false, - // // previousEvent: mapstr.M{}, - // // expectedEvent: mapstr.M{ - // // "cloud": mapstr.M{ - // // "provider": "aws", - // // "account": mapstr.M{"id": accountIDDoc1}, - // // "instance": mapstr.M{"id": instanceIDDoc1}, - // // "machine": mapstr.M{"type": instanceTypeDoc1}, - // // "image": mapstr.M{"id": imageIDDoc1}, - // // "region": regionDoc1, - // // "availability_zone": availabilityZoneDoc1, - // // "service": mapstr.M{ - // // "name": "EC2", - // // }, - // // "orchestrator": mapstr.M{ - // // "cluster": mapstr.M{ - // // "name": clusterNameDoc1, - // // "id": fmt.Sprintf("arn:aws:eks:%s:%s:cluster/%s", regionDoc1, accountIDDoc1, clusterNameDoc1), - // // }, - // // }, - // // }, - // // }, - // // }, - - // // { - // // testName: "instanceId pre-informed, no overwrite", - // // ec2ResponseMap: map[string]string{ec2InstanceIdentityURI: sampleEC2Doc1}, - // // processorOverwrite: false, - // // previousEvent: mapstr.M{ - // // "cloud": mapstr.M{ - // // "instance": mapstr.M{"id": instanceIDDoc2}, - // // }, - // // }, - // // expectedEvent: mapstr.M{ - // // "cloud": mapstr.M{ - // // "instance": mapstr.M{"id": instanceIDDoc2}, - // // }, - // // }, - // // }, + // { + // testName: "instanceId pre-informed, no overwrite", + // ec2ResponseMap: map[string]string{ec2InstanceIdentityURI: sampleEC2Doc1}, + // processorOverwrite: false, + // previousEvent: mapstr.M{ + // "cloud": mapstr.M{ + // "instance": mapstr.M{"id": instanceIDDoc2}, + // }, + // }, + // expectedEvent: mapstr.M{ + // "cloud": mapstr.M{ + // "instance": mapstr.M{"id": instanceIDDoc2}, + // }, + // }, + // }, // // { // // // NOTE: In this case, add_cloud_metadata will overwrite cloud fields because @@ -313,15 +285,19 @@ func TestRetrieveAWSMetadataEC2(t *testing.T) { for _, tc := range tests { t.Run(tc.testName, func(t *testing.T) { - mockClient := &MockIMDSClient{ - GetInstanceIdentityDocumentFunc: tc.mockGetInstanceIdentityDocumentFunc, + NewIMDSClient = func(cfg awssdk.Config) IMDSClient { + return &MockIMDSClient{ + GetInstanceIdentityDocumentFunc: tc.mockGetInstanceIdentity, + } } + defer func() { NewIMDSClient = func(cfg awssdk.Config) IMDSClient { return imds.NewFromConfig(cfg) } }() - oldNewFromConfig := imds.NewFromConfig - imds.NewFromConfig = func(cfg aws.Config, optFns ...func(*imds.Options)) *imds.Client { - return (*imds.Client)(mockClient) + NewEC2Client = func(cfg awssdk.Config) EC2Client { + return &MockEC2Client{ + DescribeTagsFunc: tc.mockEc2Tags, + } } - defer func() { imds.NewFromConfig = oldNewFromConfig }() + defer func() { NewEC2Client = func(cfg awssdk.Config) EC2Client { return ec2.NewFromConfig(cfg) } }() config, err := conf.NewConfigFrom(map[string]interface{}{ "overwrite": tc.processorOverwrite, @@ -338,6 +314,9 @@ func TestRetrieveAWSMetadataEC2(t *testing.T) { // res := result{provider: "ec2", metadata: mapstr.M{}} // fetchRawProviderMetadata(context.Background(), client, &res) + // awsConfig := awssdk.Config{} + // , err := fetchIdentityDocument(awsConfig) + actual, err := cmp.Run(&beat.Event{Fields: tc.previousEvent}) if err != nil { t.Fatalf("error running processor: %s", err.Error()) From b193f5c2262b31ae54252d40745596a8b26a6cfd Mon Sep 17 00:00:00 2001 From: Tetiana Kravchenko Date: Mon, 24 Apr 2023 10:06:12 +0200 Subject: [PATCH 15/24] Tiltfile: fix docker_registry, use more generic value Signed-off-by: Tetiana Kravchenko --- dev-tools/kubernetes/Tiltfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev-tools/kubernetes/Tiltfile b/dev-tools/kubernetes/Tiltfile index 13b7e204c92e..cd4fc3b79672 100644 --- a/dev-tools/kubernetes/Tiltfile +++ b/dev-tools/kubernetes/Tiltfile @@ -52,7 +52,7 @@ def build( # aws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin XXXXX.dkr.ecr.us-east-2.amazonaws.com/metricbeat-debug # # More info at https://docs.aws.amazon.com/AmazonECR/latest/userguide/docker-push-ecr-image.html - docker_registry = "627286350134.dkr.ecr.us-east-2.amazonaws.com".format( + docker_registry = "XXXXX.dkr.ecr.us-east-2.amazonaws.com".format( docker_image) default_registry(docker_registry) From add49568962c2b5badf8a6443c9e0ba0ae8d482a Mon Sep 17 00:00:00 2001 From: Tetiana Kravchenko Date: Mon, 24 Apr 2023 10:36:33 +0200 Subject: [PATCH 16/24] add notice file Signed-off-by: Tetiana Kravchenko --- NOTICE.txt | 424 ++++++++++++++++++++++++++--------------------------- go.mod | 2 +- 2 files changed, 213 insertions(+), 213 deletions(-) diff --git a/NOTICE.txt b/NOTICE.txt index fa7b5ee0a980..6c529546b4b8 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -3471,6 +3471,218 @@ Contents of probable licence file $GOMODCACHE/github.com/aws/aws-sdk-go-v2/crede limitations under the License. +-------------------------------------------------------------------------------- +Dependency : github.com/aws/aws-sdk-go-v2/feature/ec2/imds +Version: v1.12.7 +Licence type (autodetected): Apache-2.0 +-------------------------------------------------------------------------------- + +Contents of probable licence file $GOMODCACHE/github.com/aws/aws-sdk-go-v2/feature/ec2/imds@v1.12.7/LICENSE.txt: + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + -------------------------------------------------------------------------------- Dependency : github.com/aws/aws-sdk-go-v2/feature/s3/manager Version: v1.11.17 @@ -29272,218 +29484,6 @@ Contents of probable licence file $GOMODCACHE/github.com/aws/aws-sdk-go-v2/aws/p limitations under the License. --------------------------------------------------------------------------------- -Dependency : github.com/aws/aws-sdk-go-v2/feature/ec2/imds -Version: v1.12.7 -Licence type (autodetected): Apache-2.0 --------------------------------------------------------------------------------- - -Contents of probable licence file $GOMODCACHE/github.com/aws/aws-sdk-go-v2/feature/ec2/imds@v1.12.7/LICENSE.txt: - - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - -------------------------------------------------------------------------------- Dependency : github.com/aws/aws-sdk-go-v2/internal/configsources Version: v1.1.13 diff --git a/go.mod b/go.mod index 30202c3165e6..9ee3eb7a3879 100644 --- a/go.mod +++ b/go.mod @@ -187,6 +187,7 @@ require ( cloud.google.com/go v0.105.0 github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.4.1 github.com/Azure/go-autorest/autorest/adal v0.9.14 + github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.7 github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.17 github.com/aws/aws-sdk-go-v2/service/cloudformation v1.20.4 github.com/aws/aws-sdk-go-v2/service/kinesis v1.15.8 @@ -235,7 +236,6 @@ require ( github.com/armon/go-radix v1.0.0 // indirect github.com/aws/aws-sdk-go v1.38.60 // indirect github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.3 // indirect - github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.7 // indirect github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.13 // indirect github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.7 // indirect github.com/aws/aws-sdk-go-v2/internal/ini v1.3.14 // indirect From 1b865c9ee820b88153e3ce56dbc655981f48cdf7 Mon Sep 17 00:00:00 2001 From: Tetiana Kravchenko Date: Wed, 26 Apr 2023 15:36:35 +0200 Subject: [PATCH 17/24] fix tests - add former test cases; fix linter issues Signed-off-by: Tetiana Kravchenko --- .../add_cloud_metadata/generic_fetcher.go | 2 +- .../add_cloud_metadata/provider_aws_ec2.go | 18 +- .../provider_aws_ec2_test.go | 303 ++++++++++-------- 3 files changed, 184 insertions(+), 139 deletions(-) diff --git a/libbeat/processors/add_cloud_metadata/generic_fetcher.go b/libbeat/processors/add_cloud_metadata/generic_fetcher.go index 4467c1e49030..9a1fa95fb88a 100644 --- a/libbeat/processors/add_cloud_metadata/generic_fetcher.go +++ b/libbeat/processors/add_cloud_metadata/generic_fetcher.go @@ -49,7 +49,7 @@ func (g *genericFetcher) fetchMetadata(ctx context.Context, client http.Client) return res } res.metadata = g.schema(res.metadata) - res.metadata.Put("cloud.provider", g.provider) + _, _ = res.metadata.Put("cloud.provider", g.provider) return res } diff --git a/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go b/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go index e92b08e89228..dc7b0ef22d46 100644 --- a/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go +++ b/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go @@ -100,20 +100,20 @@ func fetchRawProviderMetadata( accountID := instanceIdentity.InstanceIdentityDocument.AccountID - result.metadata.Put("instance.id", instanceIdentity.InstanceIdentityDocument.InstanceID) - result.metadata.Put("machine.type", instanceIdentity.InstanceIdentityDocument.InstanceType) - result.metadata.Put("region", awsRegion) - result.metadata.Put("availability_zone", instanceIdentity.InstanceIdentityDocument.AvailabilityZone) - result.metadata.Put("account.id", accountID) - result.metadata.Put("image.id", instanceIdentity.InstanceIdentityDocument.ImageID) + _, _ = result.metadata.Put("instance.id", instanceIdentity.InstanceIdentityDocument.InstanceID) + _, _ = result.metadata.Put("machine.type", instanceIdentity.InstanceIdentityDocument.InstanceType) + _, _ = result.metadata.Put("region", awsRegion) + _, _ = result.metadata.Put("availability_zone", instanceIdentity.InstanceIdentityDocument.AvailabilityZone) + _, _ = result.metadata.Put("account.id", accountID) + _, _ = result.metadata.Put("image.id", instanceIdentity.InstanceIdentityDocument.ImageID) // for AWS cluster ID is used cluster ARN: arn:partition:service:region:account-id:resource-type/resource-id, example: // arn:aws:eks:us-east-2:627286350134:cluster/cluster-name if clusterName != "" { clusterARN := fmt.Sprintf("arn:aws:eks:%s:%s:cluster/%v", awsRegion, accountID, clusterName) - result.metadata.Put("orchestrator.cluster.name", clusterName) - result.metadata.Put("orchestrator.cluster.id", clusterARN) + _, _ = result.metadata.Put("orchestrator.cluster.name", clusterName) + _, _ = result.metadata.Put("orchestrator.cluster.id", clusterARN) } } @@ -138,7 +138,7 @@ func fetchEC2ClusterNameTag(awsConfig awssdk.Config, instanceID string) (string, tagsResult, err := svc.DescribeTags(context.TODO(), input) if err != nil { - return "", fmt.Errorf("error fetching EC2 Tags: %s", err) + return "", fmt.Errorf("error fetching EC2 Tags: %w", err) } if len(tagsResult.Tags) > 0 { return *tagsResult.Tags[0].Value, nil diff --git a/libbeat/processors/add_cloud_metadata/provider_aws_ec2_test.go b/libbeat/processors/add_cloud_metadata/provider_aws_ec2_test.go index 426909de2255..e283b205c203 100644 --- a/libbeat/processors/add_cloud_metadata/provider_aws_ec2_test.go +++ b/libbeat/processors/add_cloud_metadata/provider_aws_ec2_test.go @@ -52,14 +52,13 @@ func (e *MockEC2Client) DescribeTags(ctx context.Context, params *ec2.DescribeTa } func TestMain(m *testing.M) { - logp.TestingSetup() + _ = logp.TestingSetup() code := m.Run() os.Exit(code) } func TestRetrieveAWSMetadataEC2(t *testing.T) { - - const ( + var ( // not the best way to use a response template // but this should serve until we need to test // documents containing very different values @@ -69,12 +68,10 @@ func TestRetrieveAWSMetadataEC2(t *testing.T) { imageIDDoc1 = "ami-abcd1234" instanceTypeDoc1 = "t2.medium" instanceIDDoc2 = "i-22222222" - ) - var ( - clusterNameKey string = "eks:cluster-name" - clusterNameValue string = "test" - instanceIDKey string = "resource-id" - instanceIDDoc1 string = "i-11111111" + clusterNameKey = "eks:cluster-name" + clusterNameValue = "test" + instanceIDKey = "resource-id" + instanceIDDoc1 = "i-11111111" ) var tests = []struct { @@ -167,120 +164,175 @@ func TestRetrieveAWSMetadataEC2(t *testing.T) { }, }, }, + { + testName: "instanceId pre-informed, no overwrite", + mockGetInstanceIdentity: func(ctx context.Context, params *imds.GetInstanceIdentityDocumentInput, optFns ...func(*imds.Options)) (*imds.GetInstanceIdentityDocumentOutput, error) { + return &imds.GetInstanceIdentityDocumentOutput{ + InstanceIdentityDocument: imds.InstanceIdentityDocument{ + AvailabilityZone: availabilityZoneDoc1, + Region: regionDoc1, + InstanceID: instanceIDDoc1, + InstanceType: instanceTypeDoc1, + AccountID: accountIDDoc1, + ImageID: imageIDDoc1, + }, + }, nil + }, + mockEc2Tags: func(ctx context.Context, params *ec2.DescribeTagsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeTagsOutput, error) { + return &ec2.DescribeTagsOutput{ + Tags: []types.TagDescription{ + { + Key: &clusterNameKey, + Value: &clusterNameValue, + }, { + Key: &instanceIDKey, + Value: &instanceIDDoc1, + }, + }, + }, nil + }, + processorOverwrite: false, + previousEvent: mapstr.M{ + "cloud": mapstr.M{ + "instance": mapstr.M{"id": instanceIDDoc2}, + }, + }, + expectedEvent: mapstr.M{ + "cloud": mapstr.M{ + "instance": mapstr.M{"id": instanceIDDoc2}, + }, + }, + }, + { + // NOTE: In this case, add_cloud_metadata will overwrite cloud fields because + // it won't detect cloud.provider as a cloud field. This is not the behavior we + // expect and will find a better solution later in issue 11697. + testName: "only cloud.provider pre-informed, no overwrite", + mockGetInstanceIdentity: func(ctx context.Context, params *imds.GetInstanceIdentityDocumentInput, optFns ...func(*imds.Options)) (*imds.GetInstanceIdentityDocumentOutput, error) { + return &imds.GetInstanceIdentityDocumentOutput{ + InstanceIdentityDocument: imds.InstanceIdentityDocument{ + AvailabilityZone: availabilityZoneDoc1, + Region: regionDoc1, + InstanceID: instanceIDDoc1, + InstanceType: instanceTypeDoc1, + AccountID: accountIDDoc1, + ImageID: imageIDDoc1, + }, + }, nil + }, + mockEc2Tags: func(ctx context.Context, params *ec2.DescribeTagsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeTagsOutput, error) { + return &ec2.DescribeTagsOutput{ + Tags: []types.TagDescription{ + { + Key: &clusterNameKey, + Value: &clusterNameValue, + }, { + Key: &instanceIDKey, + Value: &instanceIDDoc1, + }, + }, + }, nil + }, + processorOverwrite: false, + previousEvent: mapstr.M{ + "cloud.provider": "aws", + }, + expectedEvent: mapstr.M{ + "cloud.provider": "aws", + "cloud": mapstr.M{ + "provider": "aws", + "account": mapstr.M{"id": accountIDDoc1}, + "instance": mapstr.M{"id": instanceIDDoc1}, + "machine": mapstr.M{"type": instanceTypeDoc1}, + "image": mapstr.M{"id": imageIDDoc1}, + "region": regionDoc1, + "availability_zone": availabilityZoneDoc1, + "service": mapstr.M{"name": "EC2"}, + "orchestrator": mapstr.M{ + "cluster": mapstr.M{ + "name": clusterNameValue, + "id": fmt.Sprintf("arn:aws:eks:%s:%s:cluster/%s", regionDoc1, accountIDDoc1, clusterNameValue), + }, + }, + }, + }, + }, + { + testName: "instanceId pre-informed, overwrite", + mockGetInstanceIdentity: func(ctx context.Context, params *imds.GetInstanceIdentityDocumentInput, optFns ...func(*imds.Options)) (*imds.GetInstanceIdentityDocumentOutput, error) { + return &imds.GetInstanceIdentityDocumentOutput{ + InstanceIdentityDocument: imds.InstanceIdentityDocument{ + AvailabilityZone: availabilityZoneDoc1, + Region: regionDoc1, + InstanceID: instanceIDDoc1, + InstanceType: instanceTypeDoc1, + AccountID: accountIDDoc1, + ImageID: imageIDDoc1, + }, + }, nil + }, + mockEc2Tags: func(ctx context.Context, params *ec2.DescribeTagsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeTagsOutput, error) { + return &ec2.DescribeTagsOutput{ + Tags: []types.TagDescription{}, + }, nil + }, + processorOverwrite: true, + previousEvent: mapstr.M{ + "cloud": mapstr.M{ + "instance": mapstr.M{"id": instanceIDDoc2}, + }, + }, + expectedEvent: mapstr.M{ + "cloud": mapstr.M{ + "provider": "aws", + "account": mapstr.M{"id": accountIDDoc1}, + "instance": mapstr.M{"id": instanceIDDoc1}, + "machine": mapstr.M{"type": instanceTypeDoc1}, + "image": mapstr.M{"id": imageIDDoc1}, + "region": regionDoc1, + "availability_zone": availabilityZoneDoc1, + "service": mapstr.M{"name": "EC2"}, + }, + }, + }, + { + testName: "only cloud.provider pre-informed, overwrite", + mockGetInstanceIdentity: func(ctx context.Context, params *imds.GetInstanceIdentityDocumentInput, optFns ...func(*imds.Options)) (*imds.GetInstanceIdentityDocumentOutput, error) { + return &imds.GetInstanceIdentityDocumentOutput{ + InstanceIdentityDocument: imds.InstanceIdentityDocument{ + AvailabilityZone: availabilityZoneDoc1, + Region: regionDoc1, + InstanceID: instanceIDDoc1, + InstanceType: instanceTypeDoc1, + AccountID: accountIDDoc1, + ImageID: imageIDDoc1, + }, + }, nil + }, + mockEc2Tags: func(ctx context.Context, params *ec2.DescribeTagsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeTagsOutput, error) { + return &ec2.DescribeTagsOutput{ + Tags: []types.TagDescription{}, + }, nil + }, + processorOverwrite: false, + previousEvent: mapstr.M{ + "cloud.provider": "aws", + }, + expectedEvent: mapstr.M{ + "cloud.provider": "aws", + "cloud": mapstr.M{ + "provider": "aws", + "account": mapstr.M{"id": accountIDDoc1}, + "instance": mapstr.M{"id": instanceIDDoc1}, + "machine": mapstr.M{"type": instanceTypeDoc1}, + "image": mapstr.M{"id": imageIDDoc1}, + "region": regionDoc1, + "availability_zone": availabilityZoneDoc1, + "service": mapstr.M{"name": "EC2"}, + }, + }, + }, } - // { - // testName: "instanceId pre-informed, no overwrite", - // ec2ResponseMap: map[string]string{ec2InstanceIdentityURI: sampleEC2Doc1}, - // processorOverwrite: false, - // previousEvent: mapstr.M{ - // "cloud": mapstr.M{ - // "instance": mapstr.M{"id": instanceIDDoc2}, - // }, - // }, - // expectedEvent: mapstr.M{ - // "cloud": mapstr.M{ - // "instance": mapstr.M{"id": instanceIDDoc2}, - // }, - // }, - // }, - - // // { - // // // NOTE: In this case, add_cloud_metadata will overwrite cloud fields because - // // // it won't detect cloud.provider as a cloud field. This is not the behavior we - // // // expect and will find a better solution later in issue 11697. - // // testName: "only cloud.provider pre-informed, no overwrite", - // // ec2ResponseMap: map[string]string{ec2InstanceIdentityURI: sampleEC2Doc1}, - // // processorOverwrite: false, - // // previousEvent: mapstr.M{ - // // "cloud.provider": "aws", - // // }, - // // expectedEvent: mapstr.M{ - // // "cloud.provider": "aws", - // // "cloud": mapstr.M{ - // // "provider": "aws", - // // "account": mapstr.M{"id": accountIDDoc1}, - // // "instance": mapstr.M{"id": instanceIDDoc1}, - // // "machine": mapstr.M{"type": instanceTypeDoc1}, - // // "image": mapstr.M{"id": imageIDDoc1}, - // // "region": regionDoc1, - // // "availability_zone": availabilityZoneDoc1, - // // "service": mapstr.M{ - // // "name": "EC2", - // // }, - // // }, - // // }, - // // }, - - // // { - // // testName: "all fields from processor, overwrite", - // // ec2ResponseMap: map[string]string{ec2InstanceIdentityURI: sampleEC2Doc1}, - // // processorOverwrite: true, - // // previousEvent: mapstr.M{}, - // // expectedEvent: mapstr.M{ - // // "cloud": mapstr.M{ - // // "provider": "aws", - // // "account": mapstr.M{"id": accountIDDoc1}, - // // "instance": mapstr.M{"id": instanceIDDoc1}, - // // "machine": mapstr.M{"type": instanceTypeDoc1}, - // // "image": mapstr.M{"id": imageIDDoc1}, - // // "region": regionDoc1, - // // "availability_zone": availabilityZoneDoc1, - // // "service": mapstr.M{ - // // "name": "EC2", - // // }, - // // }, - // // }, - // // }, - - // // { - // // testName: "instanceId pre-informed, overwrite", - // // ec2ResponseMap: map[string]string{ec2InstanceIdentityURI: sampleEC2Doc1}, - // // processorOverwrite: true, - // // previousEvent: mapstr.M{ - // // "cloud": mapstr.M{ - // // "instance": mapstr.M{"id": instanceIDDoc2}, - // // }, - // // }, - // // expectedEvent: mapstr.M{ - // // "cloud": mapstr.M{ - // // "provider": "aws", - // // "account": mapstr.M{"id": accountIDDoc1}, - // // "instance": mapstr.M{"id": instanceIDDoc1}, - // // "machine": mapstr.M{"type": instanceTypeDoc1}, - // // "image": mapstr.M{"id": imageIDDoc1}, - // // "region": regionDoc1, - // // "availability_zone": availabilityZoneDoc1, - // // "service": mapstr.M{ - // // "name": "EC2", - // // }, - // // }, - // // }, - // // }, - - // // { - // // testName: "only cloud.provider pre-informed, overwrite", - // // ec2ResponseMap: map[string]string{ec2InstanceIdentityURI: sampleEC2Doc1}, - // // processorOverwrite: false, - // // previousEvent: mapstr.M{ - // // "cloud.provider": "aws", - // // }, - // // expectedEvent: mapstr.M{ - // // "cloud.provider": "aws", - // // "cloud": mapstr.M{ - // // "provider": "aws", - // // "account": mapstr.M{"id": accountIDDoc1}, - // // "instance": mapstr.M{"id": instanceIDDoc1}, - // // "machine": mapstr.M{"type": instanceTypeDoc1}, - // // "image": mapstr.M{"id": imageIDDoc1}, - // // "region": regionDoc1, - // // "availability_zone": availabilityZoneDoc1, - // // "service": mapstr.M{ - // // "name": "EC2", - // // }, - // // }, - // // }, - // // }, - // } for _, tc := range tests { t.Run(tc.testName, func(t *testing.T) { @@ -310,13 +362,6 @@ func TestRetrieveAWSMetadataEC2(t *testing.T) { t.Fatalf("error creating new metadata processor: %s", err.Error()) } - // client := http.Client{} - // res := result{provider: "ec2", metadata: mapstr.M{}} - // fetchRawProviderMetadata(context.Background(), client, &res) - - // awsConfig := awssdk.Config{} - // , err := fetchIdentityDocument(awsConfig) - actual, err := cmp.Run(&beat.Event{Fields: tc.previousEvent}) if err != nil { t.Fatalf("error running processor: %s", err.Error()) From b6c28bd719f3825ae7ebac9e448822ce11fafa36 Mon Sep 17 00:00:00 2001 From: Tetiana Kravchenko Date: Wed, 26 Apr 2023 17:35:30 +0200 Subject: [PATCH 18/24] handle correctly result.err Signed-off-by: Tetiana Kravchenko --- libbeat/processors/add_cloud_metadata/provider_aws_ec2.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go b/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go index dc7b0ef22d46..8e7fc3babb10 100644 --- a/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go +++ b/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go @@ -27,6 +27,8 @@ import ( "github.com/aws/aws-sdk-go-v2/feature/ec2/imds" "github.com/aws/aws-sdk-go-v2/service/ec2" "github.com/aws/aws-sdk-go-v2/service/ec2/types" + "github.com/pkg/errors" + "github.com/elastic/elastic-agent-libs/logp" "github.com/elastic/elastic-agent-libs/mapstr" @@ -80,13 +82,16 @@ func fetchRawProviderMetadata( awsConfig, err := awscfg.LoadDefaultConfig(context.TODO(), awscfg.WithHTTPClient(&client)) if err != nil { logger.Debugf("error loading AWS default configuration: %s.", err) + result.err = errors.Wrapf(err, "failed loading AWS default configuration") return } awsClient := NewIMDSClient(awsConfig) instanceIdentity, err := awsClient.GetInstanceIdentityDocument(context.TODO(), &imds.GetInstanceIdentityDocumentInput{}) if err != nil { - logger.Warnf("error fetching EC2 Identity Document: %s.", err) + logger.Debugf("error fetching EC2 Identity Document: %s.", err) + result.err = errors.Wrapf(err, "failed fetching EC2 Identity Document.") + return } // AWS Region must be set to be able to get EC2 Tags From 0241f2270f774f17f9a345d393bfba28219550d8 Mon Sep 17 00:00:00 2001 From: Tetiana Kravchenko Date: Thu, 27 Apr 2023 17:49:28 +0200 Subject: [PATCH 19/24] address reviews Signed-off-by: Tetiana Kravchenko --- libbeat/processors/add_cloud_metadata/provider_aws_ec2.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go b/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go index 8e7fc3babb10..63bbf8537b00 100644 --- a/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go +++ b/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go @@ -27,7 +27,6 @@ import ( "github.com/aws/aws-sdk-go-v2/feature/ec2/imds" "github.com/aws/aws-sdk-go-v2/service/ec2" "github.com/aws/aws-sdk-go-v2/service/ec2/types" - "github.com/pkg/errors" "github.com/elastic/elastic-agent-libs/logp" "github.com/elastic/elastic-agent-libs/mapstr" @@ -82,7 +81,7 @@ func fetchRawProviderMetadata( awsConfig, err := awscfg.LoadDefaultConfig(context.TODO(), awscfg.WithHTTPClient(&client)) if err != nil { logger.Debugf("error loading AWS default configuration: %s.", err) - result.err = errors.Wrapf(err, "failed loading AWS default configuration") + result.err = fmt.Errorf("failed loading AWS default configuration: %w", err) return } awsClient := NewIMDSClient(awsConfig) @@ -90,7 +89,7 @@ func fetchRawProviderMetadata( instanceIdentity, err := awsClient.GetInstanceIdentityDocument(context.TODO(), &imds.GetInstanceIdentityDocumentInput{}) if err != nil { logger.Debugf("error fetching EC2 Identity Document: %s.", err) - result.err = errors.Wrapf(err, "failed fetching EC2 Identity Document.") + result.err = fmt.Errorf("failed fetching EC2 Identity Document: %w", err) return } @@ -100,7 +99,7 @@ func fetchRawProviderMetadata( clusterName, err := fetchEC2ClusterNameTag(awsConfig, instanceIdentity.InstanceIdentityDocument.InstanceID) if err != nil { - logger.Debugf("error fetching cluster name metadata: %s.", err) + logger.Warnf("error fetching cluster name metadata: %s.", err) } accountID := instanceIdentity.InstanceIdentityDocument.AccountID From 1b23f6189c070e1a66fe19956b45699668c3c39e Mon Sep 17 00:00:00 2001 From: Tetiana Kravchenko Date: Wed, 3 May 2023 14:48:33 +0200 Subject: [PATCH 20/24] Update dev-tools/kubernetes/Tiltfile Co-authored-by: kaiyan-sheng --- dev-tools/kubernetes/Tiltfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev-tools/kubernetes/Tiltfile b/dev-tools/kubernetes/Tiltfile index cd4fc3b79672..0a373ceb05fa 100644 --- a/dev-tools/kubernetes/Tiltfile +++ b/dev-tools/kubernetes/Tiltfile @@ -48,7 +48,7 @@ def build( print("Docker registry: {}".format(docker_registry)) if k8s_env == "aws": - # In order to push to AWS you need ti run: + # In order to push to AWS you need to run: # aws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin XXXXX.dkr.ecr.us-east-2.amazonaws.com/metricbeat-debug # # More info at https://docs.aws.amazon.com/AmazonECR/latest/userguide/docker-push-ecr-image.html From 79070e6ec78a77b72227fc0b7877934227beeccd Mon Sep 17 00:00:00 2001 From: Tetiana Kravchenko Date: Sun, 14 May 2023 15:25:39 +0200 Subject: [PATCH 21/24] fix the types.TagDescription struct Signed-off-by: Tetiana Kravchenko --- .../add_cloud_metadata/provider_aws_ec2.go | 4 ++-- .../provider_aws_ec2_test.go | 18 ++++++++---------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go b/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go index 63bbf8537b00..524ccf94d8d8 100644 --- a/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go +++ b/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go @@ -116,8 +116,8 @@ func fetchRawProviderMetadata( if clusterName != "" { clusterARN := fmt.Sprintf("arn:aws:eks:%s:%s:cluster/%v", awsRegion, accountID, clusterName) - _, _ = result.metadata.Put("orchestrator.cluster.name", clusterName) _, _ = result.metadata.Put("orchestrator.cluster.id", clusterARN) + _, _ = result.metadata.Put("orchestrator.cluster.name", clusterName) } } @@ -144,7 +144,7 @@ func fetchEC2ClusterNameTag(awsConfig awssdk.Config, instanceID string) (string, if err != nil { return "", fmt.Errorf("error fetching EC2 Tags: %w", err) } - if len(tagsResult.Tags) > 0 { + if len(tagsResult.Tags) == 1 { return *tagsResult.Tags[0].Value, nil } return "", nil diff --git a/libbeat/processors/add_cloud_metadata/provider_aws_ec2_test.go b/libbeat/processors/add_cloud_metadata/provider_aws_ec2_test.go index e283b205c203..d60e559ad7aa 100644 --- a/libbeat/processors/add_cloud_metadata/provider_aws_ec2_test.go +++ b/libbeat/processors/add_cloud_metadata/provider_aws_ec2_test.go @@ -134,11 +134,10 @@ func TestRetrieveAWSMetadataEC2(t *testing.T) { return &ec2.DescribeTagsOutput{ Tags: []types.TagDescription{ { - Key: &clusterNameKey, - Value: &clusterNameValue, - }, { - Key: &instanceIDKey, - Value: &instanceIDDoc1, + Key: &clusterNameKey, + ResourceId: &instanceIDDoc1, + ResourceType: "instance", + Value: &clusterNameValue, }, }, }, nil @@ -182,11 +181,10 @@ func TestRetrieveAWSMetadataEC2(t *testing.T) { return &ec2.DescribeTagsOutput{ Tags: []types.TagDescription{ { - Key: &clusterNameKey, - Value: &clusterNameValue, - }, { - Key: &instanceIDKey, - Value: &instanceIDDoc1, + Key: &clusterNameKey, + ResourceId: &instanceIDDoc1, + ResourceType: "instance", + Value: &clusterNameValue, }, }, }, nil From 87a3dd746e3cfd898dafb9b4a9c5939f42f51a7a Mon Sep 17 00:00:00 2001 From: Tetiana Kravchenko Date: Sun, 14 May 2023 15:32:50 +0200 Subject: [PATCH 22/24] remove not used variable; fix types.TagDescription struct Signed-off-by: Tetiana Kravchenko --- .../add_cloud_metadata/provider_aws_ec2_test.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/libbeat/processors/add_cloud_metadata/provider_aws_ec2_test.go b/libbeat/processors/add_cloud_metadata/provider_aws_ec2_test.go index d60e559ad7aa..a66ac00546c3 100644 --- a/libbeat/processors/add_cloud_metadata/provider_aws_ec2_test.go +++ b/libbeat/processors/add_cloud_metadata/provider_aws_ec2_test.go @@ -70,7 +70,6 @@ func TestRetrieveAWSMetadataEC2(t *testing.T) { instanceIDDoc2 = "i-22222222" clusterNameKey = "eks:cluster-name" clusterNameValue = "test" - instanceIDKey = "resource-id" instanceIDDoc1 = "i-11111111" ) @@ -222,11 +221,10 @@ func TestRetrieveAWSMetadataEC2(t *testing.T) { return &ec2.DescribeTagsOutput{ Tags: []types.TagDescription{ { - Key: &clusterNameKey, - Value: &clusterNameValue, - }, { - Key: &instanceIDKey, - Value: &instanceIDDoc1, + Key: &clusterNameKey, + ResourceId: &instanceIDDoc1, + ResourceType: "instance", + Value: &clusterNameValue, }, }, }, nil From f4ae2cf4c04816a8830bef4ec09fd1e6f6926b78 Mon Sep 17 00:00:00 2001 From: Tetiana Kravchenko Date: Mon, 15 May 2023 14:01:56 +0200 Subject: [PATCH 23/24] add a changelog record Signed-off-by: Tetiana Kravchenko --- CHANGELOG.next.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index d7d4137bb2fc..73c70f9758cb 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -10,7 +10,6 @@ https://github.com/elastic/beats/compare/v8.2.0\...main[Check the HEAD diff] *Affecting all Beats* - *Auditbeat* @@ -207,6 +206,7 @@ automatic splitting at root level, if root level element is an array. {pull}3415 - Added append Processor which will append concrete values or values from a field to target. {issue}29934[29934] {pull}33364[33364] - Allow users to enable features via configuration, starting with the FQDN reporting feature. {issue}1070[1070] {pull}34456[34456] +- Added `orchestrator.cluster.id` and `orchestrator.cluster.name` fields to the add_cloud_metadata processor, AWS cloud provider. {pull}35182[35182] *Auditbeat* From 19ab15410b8407f67940ae1c79ada52060f93c9b Mon Sep 17 00:00:00 2001 From: Tetiana Kravchenko Date: Tue, 30 May 2023 12:43:55 +0200 Subject: [PATCH 24/24] change Debugf to Warnf Signed-off-by: Tetiana Kravchenko --- libbeat/processors/add_cloud_metadata/provider_aws_ec2.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go b/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go index 524ccf94d8d8..9918654728e3 100644 --- a/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go +++ b/libbeat/processors/add_cloud_metadata/provider_aws_ec2.go @@ -80,7 +80,7 @@ func fetchRawProviderMetadata( // LoadDefaultConfig loads the EC2 role credentials awsConfig, err := awscfg.LoadDefaultConfig(context.TODO(), awscfg.WithHTTPClient(&client)) if err != nil { - logger.Debugf("error loading AWS default configuration: %s.", err) + logger.Warnf("error loading AWS default configuration: %s.", err) result.err = fmt.Errorf("failed loading AWS default configuration: %w", err) return } @@ -88,7 +88,7 @@ func fetchRawProviderMetadata( instanceIdentity, err := awsClient.GetInstanceIdentityDocument(context.TODO(), &imds.GetInstanceIdentityDocumentInput{}) if err != nil { - logger.Debugf("error fetching EC2 Identity Document: %s.", err) + logger.Warnf("error fetching EC2 Identity Document: %s.", err) result.err = fmt.Errorf("failed fetching EC2 Identity Document: %w", err) return }