Skip to content

failed to unmarshal events.CloudWatchAlarmSNSPayload with more than one - in in alarm name #424

Open
@ghdiska

Description

@ghdiska

Is your feature request related to a problem? Please describe.
I have an alert in cloudwatch that send event into a sns topic and trigger a lambda

In some cases the following instruction raise parsing error

var snsAlarmMessage events.CloudWatchAlarmSNSPayload
err := json.Unmarshal([]byte(message), &snsAlarmMessage)

i found there i a parsing problem when AlarmName is like "AlarmName": "Lag on Kafka consumer group "test.test-test-test-test" for topic "test"" with more than 1 -

  • "test.test-test-test-test" fails
  • "test.test-test" is ok

full example message : { "AlarmName": ""AlarmName": "Lag on Kafka consumer group "test.test-test-test-test" for topic "test"", "AlarmDescription": "Usage of CPU by eks autoscaling group", "AWSAccountId": "746534058873", "NewStateValue": "ALARM", "NewStateReason": "Threshold Crossed: 2 datapoints [7.0 (24/03/21 14:10:00), 7.8 (24/03/21 14:05:00)] were greater than or equal to the threshold (1.0).", "StateChangeTime": "2021-03-24T14:11:57.306+0000", "Region": "EU (Milan)", "AlarmArn": "arn:aws:cloudwatch:eu-south-1:746534058873:alarm:eks-asg-cpu-utilization-eks-6ebb16e6-ca97-467b-52b1-62c05eb16cdd", "OldStateValue": "INSUFFICIENT_DATA", "Trigger": { "MetricName": "CPUUtilization", "Namespace": "AWS/EC2", "StatisticType": "Statistic", "Statistic": "AVERAGE", "Unit": null, "Dimensions": [{ "value": "eks-6ebb16e6-ca97-467b-52b1-62c05eb16cdd", "name": "AutoScalingGroupName" } ], "Period": 60, "EvaluationPeriods": 5, "ComparisonOperator": "GreaterThanOrEqualToThreshold", "Threshold": 1.0, "TreatMissingData": "- TreatMissingData: missing", "EvaluateLowSampleCountPercentile": "" }}`

Describe the solution you'd like
expect that unmarshal is able to convert my json

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    bughelp wantedtype/eventsissue or feature request related to the events package

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions