11.6.2 Introduction (AWS CloudWatch linkage)
- Organization of this subsection
(1) Preparation
(a) CloudWatch Logs (Registering the application log on EC2 as a JP1 event)
-
Install and set up CloudWatch Logs agent on the target EC2 to forward the application logs you want to register as JP1 events to CloudWatch Logs.
For more information, see Amazon CloudWatch documentation.
■QuickStart: Install and configure CloudWatch Logs agent on a running EC2 Linux instance
-
Create a metric filter to parse the application logs that are forwarded to CloudWatch Logs.
For more information, see Amazon CloudWatch documentation.
■Quick Start: Using filters to create Metrics from Log Events
-
Create alarms to monitor the metric filters that you create.
For more information, see Amazon CloudWatch documentation.
■Quick-Start: Using alarms in Amazon CloudWatch
(b) Registering an CloudTrail trail as a JP1 event.
-
Configure settings to forward CloudTrail trails to JP1 when registering a trail recorded by CloudTrail as a trail event.
For more information, see AWS Cloud Trail documentation.
■Sending Events to CloudWatch Logs
-
Create a metric filter to analyze CloudTrail trail and an alarm to monitor the metric filter.
For more information, see Amazon CloudWatch documentation.
■Creating CloudWatch alarms for CloudTrail events: examples (English)
(2) Installation
(a) Layout of AWS CloudWatch linkage
Place AWS CloudWatch linkage tool.
-
Log in to the server running AWS CloudWatch linkage.
-
Copy the "sendevent_aws" directory to any directory.
-
Grant the required permissions to the directories and files that you copied in step 2.
Table 11‒79: Directory-structure of AWS CloudWatch linkage tool Item number
Directory structure
Description
Necessary authority
1
Sendevent_aws
AWS CloudWatch linkage tool directory
Write permission #1
2
Sendevent_aws.py
AWS CloudWatch linkage
Execute privilege #2
3
Logging.conf
Logging configuration file
Read privilege #3
4
Eventconf.csv
Event definition file
Read privilege #3
5
Eventignore.csv
Event exclusion file
Read privilege #3
- #1
-
Write privilege: Grant the privilege that can be written by the user executing AWS CloudWatch linkage tool.
- #2
-
Execution privilege: Grant the privilege that can be executed by the user who runs AWS CloudWatch linkage tool.
- #3
-
Read privilege: The permissions that can be read should be granted to the user who executes AWS CloudWatch linkage tool.
(3) Setup
(a) AWS CloudWatch linkage tool
This section describes how to set AWS CLI, JP1/Base for AWS CloudWatch collaboration tools.
- Setting item
-
-
AWS CLI install directory
-
JP1/Base install directory
-
AWS Access Key ID/ Secret Access Key
-
AWS region
-
Proxy Settings
-
-
Log in to the server running AWS CloudWatch linkage.
-
Open "sendevent_aws.py" in the "sendevent_aws" directory copied with "11.6.2(2)(a) Layout of AWS CloudWatch linkage" in a text editor.
-
Set the user variable in lines 18 to 25.
Table 11‒80: User-variable number of AWS CloudWatch linkage tool (sendevent_aws.py) Item number
Parameters
Required/
Optional
Description
1
AWS_CLI_DIR
Required
Specify AWS CLI install directory.
2
BASE_DIR
Required
Specify JP1/BASE install directory.
3
ACCESS_KEY
Optional
Sets the access key ID for AWS. However, it is not necessary to set if the access key ID is set in AWS CLI(aws configure). #1
4
SECRET_ACCESS_KEY
Optional
Sets the secret access key for AWS. However, it is not necessary to set it when the secret access key is set in AWS CLI(aws configure). #1
5
DEFAULT_REGION
Required
Sets AWS region.
6
HTTP_PROXY
Optional
If AWS CLI is accessed through a proxy, specify the proxy URL, username and password. #2
If not specified, HTTP_PROXY/HTTPS_PROXY set on OS is used.
7
HTTPS_PROXY
Optional
- #1
-
The specified account must have the following policy:
- DescribeAlarms
- DescribeAlarmHistory
- #2
-
Refer to Amazon Command Line Interface documentation for settings.
■Use HTTP Proxy-authentication the proxy
The following shows an example configuration.
19: ############################################################### 20: # User variable value (values are enclosed in double quotes) 21: ############################################################### 22: AWS_CLI_DIR = r"C:\Program Files\Amazon\AWSCLI\bin" 23: BASE_DIR = r"C:\Program Files (x86)\Hitachi\JP1Base" 24: ACCESS_KEY = "AAAAAAAAAA" 25: SECRET_ACCESS_KEY = "BBBBBBBBBB" 26: DEFAULT_REGION = "ap-northeast-1" 27: HTTP_PROXY = "http://username:password@proxy.example.com:1234" 28: HTTPS_PROXY = "http://username:password@proxy.example.com:1234" 29: ###############################################################
-
After setting the user variable value in step 2, save it with the following character code/line feed code.
Table 11‒81: Character code/line feed code of the AWS CloudWatch linkage tool (sendevent_aws.py) Item number
Item
Value
1
Character code
No UTF-8(BOM)
2
Line feed code
LF(\n) or CRLF (\r\n)
(b) Logging configuration file for AWS CloudWatch linkage tool (logging.conf)
This section describes how to set up logging for AWS CloudWatch linkage tool.
- Setting item
-
-
Log level
-
Log Files
-
Log rotation size
-
Number of log generations
-
-
Log in to the server running AWS CloudWatch linkage.
-
Open "logging.conf" under "sendevent_aws" copied in "11.6.2(2)(a) Layout of AWS CloudWatch linkage" in a text editor.
-
Modify the following lines:
11th line
11: level=INFO#1
17th line
17: args=('sendevent_aws.log', 'a', 2097152, 3, 'utf-8')#2#3#4- #1
-
Specifies the logging level. You can specify DEBUG,INFO, WARNING, ERROR, or CRITICAL.
- #2
-
Specify the log file path. You can specify an absolute or relative path.
- #3
-
Specifies the log rotation size in bytes.
- #4
-
Specifies the number of log generations.
For more information, see Python documentation.
■Environmental configuration file format
-
After setting the user variable value in step 2, save it with the following character code/line feed code.
Table 11‒82: Character code/line feed code of log configuration file (logging.conf) of the AWS CloudWatch linkage tool Item number
Item
Value
1
Character code
UTF-8
2
Line feed code
LF(\n) or CRLF (\r\n)
(c) Event definition file (eventconf.csv)
This section describes how to set up JP1 events for AWS CloudWatch linkage tool.
- Setting item
-
-
Conditions for registering JP1 events
-
JP1 event-information
-
-
Log in to the server running AWS CloudWatch linkage.
-
Open eventconf.csv under AWS CloudWatch linkage tool directory in the editor and configure the event-definition.
-
Write in one entry per line.
-
A line whose first character is "#" is a comment line and is ignored.
-
Write in CSV format.
-
JP1 event definition is searched from the top, and JP1 event with the condition that matches the condition is fired first.
The columns in CSV are listed in the following tables.
Table 11‒83: Each column in the event definition Column number
Setting value
Required/
Optional
Range of values
1
Specify the alarm that you want to register as a JP1 event.
Specify this option when you want to target the corresponding alarm.
Mandatory #1
Range supported by AWS alarm names
2
Specify the metric namespace for the alarm that you want to register as a JP1 event.
Specify if you want to target alarms in the namespace for that metric.
Required if you specify a metric name (column number: 3).
If an alarm name (column number: 1) is specified, it is ignored.
Mandatory #1
Scope supported by AWS metric namespace
3
Specifies the metric for the alarm that you want to register as a JP1 event.
Specify if you want to target alarms for that metric.
If an alarm name (column number: 1) is specified, it is ignored.
Mandatory #1
Scope supported by AWS metric names
4
Specifies the event ID of JP1 event to register. #2
Optional
Scope supported by jevsend command-argument-i
5
Specifies the message text of JP1 event that you want to register.
If omitted, stateReason of the alarm is used. #4
Optional
Scope supported by jevsend command-argument-m
6
Specifies the destination event server for JP1 events that you want to register. #2
Optional
Scope supported by jevsend command-argument-d
7
Specifies the source event server for JP1 event to register. #2
Optional
Scope supported by jevsend command-argument-s
8 or later
Specifies the extended properties of JP1 events that you want to register. #2#3
To specify multiple extended attributes, specify column numbers 7 or later.
Optional
The scope supported by jevsend command-argument-e.
In addition, even if the extended attribute value contains a space, it is not necessary to specify ["]. (["] is also recognized as an extended attribute value)
- #1
-
JP1 event-registration conditions (column-numbers: 1 to 3) must be specified in one of the following patterns.
- Alarm name (column number: 1)
- Metric namespace (column number: 2)
- Metric namespace (column number: 2) and metric name (column number: 3)
- #2
-
If omitted, this is the default behavior for the corresponding jevsend command-option.
- #3
-
In addition to the specified extended attributes, there are extended attributes that are added by AWS CloudWatch linkage tool. The following extended attributes are added:
Table 11‒84: Extended attributes added by the AWS CloudWatch linkage tool Item number
Attribute Name
Value
1
AWS_ALARM_TIMESTAMP
Date and time when the alarm occurred (UNIX period)
2
AWS_ALARM_DATETIME
Date and time when the alarm occurred (YYYY/mm/dd HH:MM:SS format)
- #4
-
If the message exceeds 1023 bytes, the message will be limited to 1023 bytes.
The following shows an example configuration.
#AlermName,NameSpace,MetricName,EventID,Message,Destination,Source,ExtAttr ALARM1,,,1111,message1,DEST_HOST,SRC_HOST,EXATTR1=value1,EXATTR2=value2,EXATTR3=value3,NAME_SPACE,,2222,message2,DEST_HOST,SRC_HOST,EXATTR1=aaa bbb,EXATTR2=value,NAME_SPACE,METRIC1,3333,message3,DEST_HOST,SRC_HOST,EXATTR1=value
-
-
After changing the setting in step 2, save it with the following character code/line feed code.
Table 11‒85: :Character codes and line feed codes for event definition files (eventconf.csv) Item number
Item
Value
1
Character code
UTF-8
2
Line feed code
LF(\n) or CRLF (\r\n)
(d) Event-Exclusion Files (eventignore.csv)
This section describes how to configure JP1 events that are excluded from AWS CloudWatch linkage.
- Setting item
-
-
JP1 Events exclusion conditions
-
-
Log in to AWS CloudWatch linkage tool-running server.
-
Open eventignore.csv under AWS CloudWatch linkage tool directory in the editor and configure the event-definition.
-
Write in one entry per line.
-
A line whose first character is "#" is a comment line and is ignored.
-
Write in CSV format.
-
JP1 event exclusion definitions are judged in order from the top, and if they match, they are excluded from JP1 event.
The columns in CSV are listed in the following tables.
Table 11‒86: Event exclusion definition columns Column number
Setting value
Required/
Optional
Range of values
1
Specify the alarm that you want to register as a JP1 event.
Specify this option when you want to target the corresponding alarm.
Mandatory #1
Range supported by AWS alarm names
2
Specify the metric namespace for the alarm that you want to register as a JP1 event.
Specify if you want to target alarms in the namespace for that metric.
Required if you specify a metric name (column number: 3).
If an alarm name (column number: 1) is specified, it is ignored.
Mandatory #1
Scope supported by AWS metric namespace
3
Specifies the metric for the alarm that you want to register as a JP1 event.
Specify if you want to target alarms for that metric.
If an alarm name (column number: 1) is specified, it is ignored.
Mandatory #1
Scope supported by AWS metric names
- #1
-
JP1 event-registration conditions (column-numbers: 1 to 3) must be specified in one of the following patterns.
- Alarm name (column number: 1)
- Metric namespace (column number: 2)
- Metric namespace (column number: 2) and metric name (column number: 3)
The following shows an example configuration.
#AlermName,NameSpace,MetricName ALARM1,,,NAME_SPACE,,NAME_SPACE,METRIC1
-
-
After changing the setting in step 2, save it with the following character code/line feed code.
Table 11‒87: Character encoding and line feed encoding for event-exclude files (eventignore.csv) Item number
Item
Value
1
Character code
UTF-8
2
Line feed code
LF(\n) or CRLF (\r\n)
(4) Uninstallation
(a) Uninstalling AWS CloudWatch linkage tool
The following describes how to uninstall AWS CloudWatch linkage tool.
-
Log in to the server running AWS CloudWatch linkage.
-
Deletes the "sendevent_aws" directory that was copied in "11.6.2(2)(a) Layout of AWS CloudWatch linkage".