9.0.0 • Published 3 years ago
aft-logging-awskinesis v9.0.0
AFT-Logging-AWSKinesis
an Automated Functional Testing (AFT) library providing logging to an AWS Kinesis Firehose endpoint for any TestResult objects logged via the aft-core.LogManager
Installation
> npm i aft-logging-awskinesis
Configuration
to send values to AWS Kinesis Firehose endpoints you must specify the AWS Credentials, the AWS Region Endpoint and the AWS Kinesis Delivery Stream. These take the following form in your aftconfig.json:
{
"logmanager": {
"level": "none",
"plugins": [{
"name": "kinesis-logging-plugin",
"searchDirectory": "../",
"options": {
"enabled": true,
"level": "info",
"accessKeyId": "your-aws-access-key-id",
"secretAccessKey": "your-aws-secret-access-key",
"sessionToken": "your-aws-session-token",
"region": "us-west-1",
"deliveryStream": "your-frehose-delivery-stream",
"batch": false,
"batchSize": 1
}
}]
}
}- name - a
stringcontainingkinesis-logging-plugininstructing thepluginloaderto load this plugin - searchDirectory - an optional
stringcontaining the root directory to begin searching for this plugin when first attempting to load it (defaults to current working directory) - options - an optional
objectcontaining options for the plugin when it is first loaded. accepted values are as follows:- enabled - an optional
booleanindicating if this plugin should be used or not (defaults totrue) - level - an optional
LogLevelto be used by this plugin (defaults to value set inLogManager) - accessKeyId - a
stringcontaining your AWS IAM user's Access Key ID. if not specified the value will attempt to be read from environment variables, EC2 metadata, shared ini file, ECS credentials and process credentials in that order - secretAccessKey - a
stringcontaining your AWS IAM user's Secret Access Key. if not specified the value will attempt to be read likeaccessKeyId - sessionToken - a
stringcontaining your AWS IAM user's Session Token. only required if you are using a temporary session. if not specified the value will attempt to be read likeaccessKeyId - region - a
stringcontaining the AWS region where the Kinesis Firehose stream is located. values likeeu-west-1orus-west-2are expected. - deliveryStream - a
stringcontaining the name of the Kinesis Firehose stream to send through. If using Elasticsearch as your back-end storage, this would be the Elasticsearch index to use. - batch - an optional
booleanindicating whether logs should be batched before forwarding to Kinesis Firehose (defaults totrue) - batchSize - an optional
numberrepresenting the number of log records to batch before sending (defaults to 10)
- enabled - an optional
NOTE: the AWS Credentials are first attempted to be read from AFT Configuration and if no value is specified then the following are checked:
- Environment Variables: AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN
- EC2 Metadata: also known as instance profile credentials
- Shared Ini File: read from the host system
- ECS Credentials: similar to the EC2 Metadata, but on ECS
- Process Credentials: any credentials set on the current process
- Options: read from passed in
KinesisLoggingPluginOptions
Format of log records
the log record that is sent to your AWS Kinesis Firehose endpoint will have the following format:
message logs
{
"logName": "if used with a Verifier this will be the 'description' or 'Test IDs' or a GUID",
"message": "this is the actual message being logged",
"level": "warn",
"version": "3.0.0",
"buildName": "Jenkins or Team City Job Name",
"buildNumber": "Jenkins or Team City Job Number",
"machineInfo": {
"ip": "234.9.10.11",
"name": "CETH-ARG-WIN10",
"user": "SYSTEM"
}
}- logName - the
logNamepassed to this plugin when loaded from theLogManager - message - the
stringbeing logged by some component - level - a
stringvalue from one of theaft-core.LoggingLevelvalues based on the level of the message being logged - version - the current version of the
KinesisLoggingPlugin - buildName - a
stringretrieved from theBuildInfoManager.getBuildNamefunction - buildNumber - a
stringretrieved from theBuildInfoManager.getBuildNumberfunction - machineInfo - an
aft-core.MachineInfoDataobject containing the following:- ip - a
stringof the machine's IP address - name - a
stringof the machine's name - user - a
stringof the currently logged in user who executed the tests
- ip - a
TestResult logs
{
"logName": "if used with Verifier this will be the 'description' or 'Test IDs' or a GUID",
"result": {
"testId": "1234",
"resultMessage": "the final result was a SUCCESS!",
"status": "Passed",
"resultId": "dbbf6fce-14db-4bd2-ba31-e3fa68d719e4",
"created": 1655289028279,
"defects": [
{
"id": "3344",
"title": "a defect that has now been closed",
"description": "this defect used to affect this test, but now it doesn't :)",
"status": "closed"
}
],
"metadata": {}
},
"buildName": "Jenkins or Team City Job Name",
"buildNumber": "Jenkins or Team City Job Number",
"machineInfo": {
"ip": "234.9.10.11",
"name": "CETH-ARG-WIN10",
"user": "SYSTEM"
}
}- logName - the
logNamepassed to this plugin when loaded from theLogManager - result - an
TestResultobject containing the following:- testId - a
stringcontaining any unique ID for the test result being recorded - resultMessage - a
stringmessage of the final result - status - a
stringrepresenting theaft-core.TestStatusvalue - resultId - a
stringcontaining a unique identifier for theTestResult - created - a
numbercontaining the date and time theTestResultwas created as milliseconds since the epoch - defects - an array of
aft-core.Defectobjects - metadata - an
objectthat can contain additional data for theTestResult
- testId - a
- version - the current version of the
KinesisLoggingPlugin - buildName - a
stringretrieved from theBuildInfoManager.getBuildNamefunction - buildNumber - a
stringretrieved from theBuildInfoManager.getBuildNumberfunction - machineInfo - an
aft-core.MachineInfoDataobject containing the following:- ip - a
stringof the machine's IP address - name - a
stringof the machine's name - user - a
stringof the currently logged in user who executed the tests
- ip - a