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

Configure appsignals processor on EKS with cluster name #980

Merged
merged 2 commits into from
Dec 21, 2023

Conversation

bjrara
Copy link
Collaborator

@bjrara bjrara commented Dec 4, 2023

Description of the issue

Currently, the awsappsignals processor reads cluster name from resource attributes which is extracted from EC2 tag kubernetes.io/cluster/my-cluster by resourcedetection processor. Most of time, it's working because EKS adds the tag to nodes during provisioning. However, according to Amazon EKS VPC and subnet requirements and considerations, this tag is not a hard dependency for EKS, thus if the customer removes the tag accidentally (or on purpose), our metrics will fail to be generated with correct EKS cluster name dimension, and cause false alarming or missin graphs if the metrics are used in dashboards or alarms/SLOs.

Description of changes

  1. Make the cluster name as a mandatory field to bootstrap awsappsignals processor on EKS;
  2. Change the field resolvers from string array to object array;
  3. Refactor the package layout of awsappsignals;

License

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Tests

  1. Unit tests.
  2. Manual E2E tests on EKS and EC2.

Requirements

Before commit the code, please do the following steps.

  1. Run make fmt and make fmt-sh
  2. Run make lint

@bjrara bjrara requested a review from a team as a code owner December 4, 2023 23:23
@bjrara
Copy link
Collaborator Author

bjrara commented Dec 4, 2023

@mxiamxia @pxaws

mxiamxia
mxiamxia previously approved these changes Dec 4, 2023
Copy link
Contributor

@mxiamxia mxiamxia left a comment

Choose a reason for hiding this comment

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

LGTM! thanks!

mxiamxia
mxiamxia previously approved these changes Dec 5, 2023
@bjrara
Copy link
Collaborator Author

bjrara commented Dec 8, 2023

@lisguo @sky333999 Can you help review?

mxiamxia
mxiamxia previously approved these changes Dec 11, 2023
JayPolanco
JayPolanco previously approved these changes Dec 14, 2023
@codecov-commenter
Copy link

codecov-commenter commented Dec 14, 2023

Codecov Report

Attention: 42 lines in your changes are missing coverage. Please review.

Comparison is base (96d4763) 57.58% compared to head (e870ec6) 63.02%.
Report is 470 commits behind head on main.

Files Patch % Lines
cfg/aws/credentials.go 0.00% 22 Missing ⚠️
cfg/aws/shared_config.go 62.50% 15 Missing ⚠️
cfg/envconfig/envconfig.go 50.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #980      +/-   ##
==========================================
+ Coverage   57.58%   63.02%   +5.43%     
==========================================
  Files         370      360      -10     
  Lines       17548    18202     +654     
==========================================
+ Hits        10105    11471    +1366     
+ Misses       6848     6142     -706     
+ Partials      595      589       -6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

func newHostedInAttributeResolver(attributeMap map[string]string) *hostedInAttributeResolver {
func newHostedInAttributeResolver(name string, attributeMap map[string]string) *hostedInAttributeResolver {
if name == "" {
name = "Generic"
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we instead use the PlatformGeneric const here as well instead of a string or do we want this to intentionally be Generic and not generic?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We use Generic following the examples provided by CloudWatch metrics: https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added const PlatformGeneric.

sky333999
sky333999 previously approved these changes Dec 18, 2023
@bjrara bjrara force-pushed the main branch 2 times, most recently from b121450 to 583ff41 Compare December 18, 2023 23:08
sky333999
sky333999 previously approved these changes Dec 18, 2023
lisguo
lisguo previously approved these changes Dec 19, 2023
// TODO: change default config when other resolvers are supported
Resolvers: []string{"eks"},
return &appsignalsconfig.Config{
Resolvers: []appsignalsconfig.Resolver{},
Copy link
Contributor

Choose a reason for hiding this comment

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

is there a use case when we have a default resolver? What happens then?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I would never expect the default resolver to be initied for real use case. In case it happens, it will fail the config validation with unknown resolver error.

if common.IsAppSignalsKubernetes() {
cfg.Resolvers = []string{"eks"}
if !hostedInConfigured {
hostedIn = util.GetClusterNameFromEc2Tagger()
Copy link
Contributor

Choose a reason for hiding this comment

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

nice, I didn't even know we had this function

@bjrara bjrara dismissed stale reviews from lisguo and sky333999 via 9c8e255 December 19, 2023 20:36
@bjrara bjrara force-pushed the main branch 2 times, most recently from 9c8e255 to f424a1b Compare December 19, 2023 20:39
@lisguo
Copy link
Contributor

lisguo commented Dec 20, 2023

Seems like there are some unit test failures

 Error: plugins/processors/awsappsignals/config/config_test.go:14:49: not enough arguments in call to NewGenericResolver
	have ()
	want (string)

@bjrara
Copy link
Collaborator Author

bjrara commented Dec 20, 2023

The test failed for some irrelevant issue

2023/12/20 18:18:06 E! [cloudwatchlogs.test] Stop requested after 0 retries to G/S failed for PutLogEvents, request dropped.
--- FAIL: TestLongMessageGetsTruncated (0.02s)
    pusher_test.go:187: PutLogEvents called with incorrect number of message, expecting 1, but 0 received
FAIL
coverage: 39.1% of statements
FAIL	github.com/aws/amazon-cloudwatch-agent/plugins/outputs/cloudwatchlogs	3.131s

@JayPolanco JayPolanco merged commit f2e1251 into aws:main Dec 21, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants