Formatting data and viewing logs in AWS Chatbot - AWS Chatbot

Formatting data and viewing logs in AWS Chatbot

To ensure data from Amazon CloudWatch alarms is correctly formatted, attach the Lambda-Invoke Command Permissions and ReadOnly Commands Permissions IAM policies to the role in the AWS Chatbot console for users in the chat channel.

Run the cloudwatch describe-alarms command to show CloudWatch alarms in chart form as follows:

@aws cloudwatch describe-alarms

You can change the command to only include notifications in the alarm state, filtering out other notifications, by adding the following option:

@aws cloudwatch describe-alarms --state ALARM

To see alarms from a different AWS Region, include that Region in the command:

@aws cloudwatch describe-alarms --state ALARM --region us-east-1

You can also filter AWS CLI output by using the optional query parameter. A query uses JMESPath syntax to create an expression to filter your output to your specifications. For more information about filtering, see Filtering AWS CLI output in the AWS Command Line Interface User Guide. For more information about JMESPath syntax, see their website. The following example shows how to limit AWS CLI output for the cloudwatch describe-alarms command to just the alarm name, description, state, and reason attributes.

@AWS cloudwatch describe-alarms --query @.{MetricAlarms:MetricAlarms[*]. {AlarmName:AlarmName, AlarmDescription:AlarmDescription, StateValue:StateValue, StateReason:StateReason, Namespace:Namespace, MetricName:MetricName, Dimensions:Dimensions, ComparisonOperator:ComparisonOperator, Threshold:Threshold, Period:Period, EvaluationPeriods:EvaluationPeriods, Statistic:Statistic}} --region us-east-2