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

Adding custom namespace metrics support in cf yamls #216

Merged
merged 1 commit into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,17 @@ Parameters:
Type: String
Description: "Provide the Namespace with which Source need to be created."
Default: ''
CreateCustomMetricsSource:
Type: String
Description: "Select Yes if you would like to create the Metric Source."
Default: 'No'
AllowedValues:
- 'Yes'
- 'No'
CustomMetricsSourceNamespace:
Type: String
Description: "Provide the Namespace with which Source need to be created."
Default: ''

Mappings:
# Update the Namespaces mapping whenever CF starts supporting More Namespaces
Expand Down Expand Up @@ -155,6 +166,7 @@ Conditions:
install_third_cw_source: !Equals [!Ref CreateThirdMetricsSource, 'Yes']
install_fourth_cw_source: !Equals [!Ref CreateFourthMetricsSource, 'Yes']
install_fifth_cw_source: !Equals [!Ref CreateFifthMetricsSource, 'Yes']
install_custom_cw_source: !Equals [!Ref CreateCustomMetricsSource, 'Yes']

Resources:

Expand Down Expand Up @@ -260,5 +272,26 @@ Resources:
SumoAccessKey: !Ref SumoLogicAccessKey
SumoDeployment: !Ref SumoLogicDeployment
RoleArn: !Ref SumoLogicSourceRole
Fields:
account: !Ref AccountAlias

CustomCloudwatchMetricsSource:
Type: Custom::AWSSource
Condition: install_custom_cw_source
Properties:
ServiceToken: !Ref LambdaARN
Region: !Ref "AWS::Region"
RemoveOnDeleteStack: !Ref RemoveSumoLogicResourcesOnDeleteStack
SourceType: AwsCloudWatch
Namespaces: !Split [ "," , !Sub "${CustomMetricsSourceNamespace}" ]
SourceName: !Sub "${CloudWatchMetricsSourceName}-CustomMetrics"
ScanInterval: "300000"
SourceCategory: !Ref CloudWatchMetricSourceCategory
AWSTagFilters: !Ref MetricsSourceAWSTagFilters
CollectorId: !Ref SumoLogicCollectorId
SumoAccessID: !Ref SumoLogicAccessID
SumoAccessKey: !Ref SumoLogicAccessKey
SumoDeployment: !Ref SumoLogicDeployment
RoleArn: !Ref SumoLogicSourceRole
Fields:
account: !Ref AccountAlias
16 changes: 12 additions & 4 deletions aws-observability/apps/common/resources.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1087,6 +1087,7 @@ Resources:

def lambda_handler(event, context):
unique_namespaces = set(["AWS/AutoScaling"])
custom_namespace = set()

response_value = {}
for value in default:
Expand All @@ -1097,12 +1098,17 @@ Resources:
if namespaces:
namespace_list = namespaces.split(",")
for namespace in namespace_list:
name = namespace.split("/")[1]
response_value[name] = "Yes"
if name not in cw_metrics_specific:
unique_namespaces.add(namespace.replace(" ", ""))
if namespace.strip().startswith("AWS/"):
name = namespace.split("/")[1]
response_value[name] = "Yes"
if name not in cw_metrics_specific:
unique_namespaces.add(namespace.replace(" ", ""))
else:
custom_namespace.add(namespace.replace(" ", ""))

response_value["namespaces"] = ", ".join(unique_namespaces)
response_value["createCustom"] = "No" if len(custom_namespace) == 0 else "Yes"
response_value["customNamespaces"] = ", ".join(custom_namespace)
LOGGER.info("Response is {}".format(response_value))
cfnresponse.send(event, context, cfnresponse.SUCCESS, response_value, "NamespaceSplitting")
Handler: index.lambda_handler
Expand Down Expand Up @@ -1153,6 +1159,8 @@ Resources:
FourthMetricsSourceNamespace: "Lambda"
CreateFifthMetricsSource: !GetAtt Primerinvoke.RDS
FifthMetricsSourceNamespace: "RDS"
CreateCustomMetricsSource: !GetAtt Primerinvoke.createCustom
CustomMetricsSourceNamespace: !GetAtt Primerinvoke.customNamespaces

CloudWatchMetricsSecondStack:
Type: AWS::CloudFormation::Stack
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ Resources:
sumoOrgId:
!Ref Section1dSumoLogicOrganizationId
solutionName: 'AWSO'
solutionVersion: 'v2.10.0'
solutionVersion: 'v2.11.0'
deploymentSource: 'cloudFormation'
TelemetryEndpoint: "https://endpoint1.collection.us2.sumologic.com/receiver/v1/http/ZaVnC4dhaV1S68eao6UYB3LFtqQ7ur1xYlT1EHCfXdhvi6uPNc0aUXIpvq5i_aHewOp5xxxwnGZ5MmSWDR6qV5td4exMM4pZE4Tk6rqKvgextLx7I6IRpg=="
scanInterval: 60
Expand Down
Loading