Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[libbeat] Change aws_elb autodiscover provider field name to aws.elb.* #16402

Merged
merged 2 commits into from
Feb 21, 2020
Merged

[libbeat] Change aws_elb autodiscover provider field name to aws.elb.* #16402

merged 2 commits into from
Feb 21, 2020

Conversation

kaiyan-sheng
Copy link
Contributor

@kaiyan-sheng kaiyan-sheng commented Feb 18, 2020

What does this PR do?

This PR is to change aws_elb autodiscover provider fields from elb_listener.* to aws.elb.*. For example, the output event will look like below from unit test:

map[aws:{"elb":{"availability_zones":["strVal"],"created":"2020-02-18T13:58:30.569437-07:00","host":"fake.example.net","ip_address_type":"dualstack","listener_arn":"listen_arn","load_balancer_arn":"lb_arn","port":1234,"protocol":"HTTPS","scheme":"internet-facing","security_groups":["foo-security-group"],"ssl_policy":"strVal","state":{"code":"active","reason":"strVal"},"type":"application","vpc_id":"strVal"}} cloud:{"availability_zone":["strVal"],"provider":"aws","region":"strV"} host:fake.example.net id:listen_arn meta:{"aws":{"elb":{"availability_zones":["strVal"],"created":"2020-02-18T13:58:30.569437-07:00","host":"fake.example.net","ip_address_type":"dualstack","listener_arn":"listen_arn","load_balancer_arn":"lb_arn","port":1234,"protocol":"HTTPS","scheme":"internet-facing","security_groups":["foo-security-group"],"ssl_policy":"strVal","state":{"code":"active","reason":"strVal"},"type":"application","vpc_id":"strVal"}},"cloud":{"availability_zone":["strVal"],"provider":"aws","region":"strV"}} port:1234 provider:39021adf-6e56-4c6a-8a3c-b12bf9317c06 start:true]

meta represents what will end up as metadata in the output of modules that get launched. This PR also updated aws_elb provider to have all the meta fields into autodiscover template by adding it to the root of the event. Please see #14823 (comment) for more details.

Why is it important?

With this change, fields from aws_elb and aws_ec2 autodiscover providers will match.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works

Related issues

@kaiyan-sheng kaiyan-sheng self-assigned this Feb 18, 2020
@kaiyan-sheng kaiyan-sheng added autodiscovery needs_backport PR is waiting to be backported to other branches. Team:Platforms Label for the Integrations - Platforms team labels Feb 18, 2020
"aws": common.MapStr{
"elb": lbl.toMap(),
},
"cloud": lbl.toCloudMap(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the move out of meta and why now in both places?

Copy link
Contributor Author

@kaiyan-sheng kaiyan-sheng Feb 19, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I forgot to add some explanation in PR description for this. This is to update aws_elb provider to have all the meta fields into autodiscover template by adding it to the root of the event. Please see #14823 (comment) for more details. Thanks!

"aws": common.MapStr{
"elb": lbl.toMap(),
},
"cloud": lbl.toCloudMap(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

Copy link
Contributor

@blakerouse blakerouse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, thanks for the explanation. Looks good!

Copy link
Contributor

@andrewvc andrewvc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, if I understand this patch correctly we're replacing aws_elb with aws.elb in the output documents but not changing the provider name from aws_elb is that correct?

Is it correct that YAML configs should not be affected by this, but the event schema is. Is that correct?

In other words, am I right in my understanding that docs like https://github.com/elastic/beats/blob/master/heartbeat/docs/aws-credentials-examples.asciidoc won't need to change?

@kaiyan-sheng
Copy link
Contributor Author

kaiyan-sheng commented Feb 20, 2020

@andrewvc Thanks for reviewing! Please see my answer in line.

So, if I understand this patch correctly we're replacing aws_elb with aws.elb in the output documents but not changing the provider name from aws_elb is that correct?

We are changing the output event field from elb_listener.* to aws.elb.*. For example elb_listener.load_balancer_arn to aws.elb.load_balancer_arn. Yes, the autodiscover provider name stays the same to be aws_elb.

Is it correct that YAML configs should not be affected by this, but the event schema is. Is that correct?
In other words, am I right in my understanding that docs like https://github.com/elastic/beats/blob/master/heartbeat/docs/aws-credentials-examples.asciidoc won't need to change?

Yes and no 😄 https://github.com/elastic/beats/blob/master/heartbeat/docs/aws-credentials-examples.asciidoc won't need to change when user is using data.host and/or data. port as a part of the autodiscover template. But if originally, user has a config includes elb meta data fields like meta.elb_listener.listener_arn(probably a bad example that doesn't make sense for heartbeat):

heartbeat.autodiscover:
  providers:
  - type: aws_elb
    period: 1m
    regions: ["us-east-1"]
    credential_profile_name: test-hb
    templates:
    - type: tcp
      hosts: ["${meta.elb_listener.listener_arn}"]
      schedule: "@every 5s"
      timeout: 1s

Then, with this change, user needs to change the config to use data.aws.elb.* instead:

heartbeat.autodiscover:
  providers:
  - type: aws_elb
    period: 1m
    regions: ["us-east-1"]
    credential_profile_name: test-hb
    templates:
    - type: tcp
      hosts: ["${data.aws.elb.listener_arn}"]
      schedule: "@every 5s"
      timeout: 1s

Copy link
Contributor

@andrewvc andrewvc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kaiyan-sheng kaiyan-sheng merged commit f9fe104 into elastic:master Feb 21, 2020
@kaiyan-sheng kaiyan-sheng deleted the aws_elb_autodiscover branch February 21, 2020 02:31
@kaiyan-sheng kaiyan-sheng added v7.7.0 and removed needs_backport PR is waiting to be backported to other branches. labels Feb 21, 2020
kaiyan-sheng added a commit that referenced this pull request Feb 24, 2020
#16402) (#16477)

* Change aws_elb autodiscover provider field name to aws.elb.*

* add changelog

(cherry picked from commit f9fe104)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autodiscovery Team:Platforms Label for the Integrations - Platforms team v7.7.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change aws_elb autodiscover provider meta field prefix to aws.elb
4 participants