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

Q&A: How to adjust log level? (and turn off DEBUG logs) #1062

Open
neoakris opened this issue Aug 14, 2024 · 1 comment
Open

Q&A: How to adjust log level? (and turn off DEBUG logs) #1062

neoakris opened this issue Aug 14, 2024 · 1 comment
Labels
docs Improvements or additions to documentation

Comments

@neoakris
Copy link

Describe the documentation issue

By default, I get tons of log messages like this, that I don't find useful / wish I could easily turn off.
DEBUG Core add-on kube-proxy is at version auto
I'm new to TypeScript and didn't see an easy way to disable the logging. After about a day of digging through the source code, following a trail of bread crumbs, reading upstream docs, and trial and error I learned a solution. I decided to document it in this issue ticket in case it helps anyone else out in the future.

https://tslog.js.org/#/?id=changing-settings-at-runtime
https://tslog.js.org/#/?id=default-log-level
^-- based on this
I eventually learned, I can put the following in my cdk-main.ts

import { userLog } from '@aws-quickstart/eks-blueprints/dist/utils';
userLog.settings.minLevel = 3; //3 = info, 2 = debug & info
//^-- for more info see https://tslog.js.org/#/?id=default-log-level

Links

This isn't documented anywhere on the docs, but maybe it should be, it could maybe go here?
https://aws-quickstart.github.io/cdk-eks-blueprints/core-concepts/

@neoakris neoakris added the docs Improvements or additions to documentation label Aug 14, 2024
@neoakris
Copy link
Author

Note:
upstream as in (import * as eks from 'aws-cdk-lib/aws-eks';)
Which cdk-eks-blueprints depends on uses it's own different log/warning methodology.
So the above userLog based solution only applies to eks-blueprints specific warning/debug messages.

Here's an example of how to disable other Warning messages that can come from upstream:
https://github.com/aws/aws-cdk/blob/v2.158.0/packages/aws-cdk-lib/aws-eks/lib/cluster.ts#L2171
^-- per this, upstream uses
Annotations.of(this).addWarningV2('@aws-cdk/aws-eks:clusterMustManuallyTagSubnet', 'Could not auto-tag ${type} subnet${subnetID} with "${tag}=1", please remember to do this manually');

I took care of such tags in IaC, and was annoyed by the false positive warnings, so I wanted to disable them.
Here's an example of how to disable it:
cdk.Annotations.of(this.stack).acknowledgeWarning('@aws-cdk/aws-eks:clusterMustManuallyTagSubnet');

^-- Note in my custom implementation:
I have a stack that looks up a pre-existing VPC
I then I build eks-blueprint clusters from a construct, that references the pre-existing VPC
My eks-blueprint construct is then stored in this.stack, so my example won't work perfectly for most.

Based on this
export class EksBlueprint extends cdk.Stack
since EksBlueprint is a cdk.Stack, it'd probably look more like this for other people.

cdk.Annotations.of(my_object_instance_of_type_EksBlueprint).acknowledgeWarning('@aws-cdk/aws-eks:clusterMustManuallyTagSubnet');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant