Install Lambda

Perform the following procedure to enable Lambda monitoring from AWS.

  1. Ensure Cloud Watch logs are enabled for your lambda function, In addition AWS creates a Log Group for every lambda function. Ensure that this log group has the same name as your lambda function. If they are not the same, you will not see some data on the SixthSense Lambda monitoring page.
  2. To capture the Lambda source invocation on your SixthSense Lambda monitoring page, you must add specific lines of code according to your runtime.

Python

import json
sixthsense_log = { "logName": "ss_lambda_event_log", "requestId": context.aws_request_id, "event": event}
print(json.dumps(sixthsense_log))

Node JS

var sixthsense_log = { "logName": "ss_lambda_event_log", "requestId": context.awsRequestId, "event": event}
console.log(JSON.stringify(sixthsense_log))

Ruby

require 'json'
sixthsense_log = { logName: "ss_lambda_event_log", requestId: context.aws_request_id, event: event}
puts "#{JSON.pretty_generate(sixthsense_log)}"

Java

Add a few dependencies as follows to your class path.

  • aws-lambda-java-core
  • aws-lambda-java-events
  • gson
  • Maven pom.xml example
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-core</artifactId>
<version>1.2.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.amazonaws/aws-lambda-java-events -->
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-events</artifactId>
<version>3.14.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.11.0</version>
</dependency>
  • Create a new Class
//package your.package
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.events.*;
import com.google.gson.Gson;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
public class SSLambda {
final Context context;
final Object input;
private static final String EVENT_SOURCE = "eventSource";
public SSLambda(Object input, Context cxt) {
this.context = cxt;
this.input = input;
}
void logEvent(String sourceKey) {
Gson gson = new Gson();
Map<String, Object> ssLog = new HashMap<>();
ssLog.put("requestId", context.getAwsRequestId());
ssLog.put("logName", "ss_lambda_event_log");
if (sourceKey != null && !sourceKey.isEmpty()) {
ssLog.put(EVENT_SOURCE, gson.fromJson(input.toString(), Map.class).get(sourceKey));
} else {
if (input instanceof LinkedHashMap) {
ssLog.put("event", input);
} else if (input instanceof APIGatewayProxyRequestEvent) {
ssLog.put(EVENT_SOURCE, "API-Gateway");
} else if (input instanceof S3Event) {
ssLog.put(EVENT_SOURCE, "S3");
} else if (input instanceof DynamodbEvent) {
ssLog.put(EVENT_SOURCE, "DynamoDB");
} else if (input instanceof SNSEvent) {
ssLog.put(EVENT_SOURCE, "SNS");
} else if (input instanceof SQSEvent) {
ssLog.put(EVENT_SOURCE, "SQS");
} else if (input instanceof KinesisEvent) {
ssLog.put(EVENT_SOURCE, "Kinesis");
}
}
context.getLogger().log(gson.toJson(ssLog));
}
}
  • Tweak your lambda handler class to invoke the SSLambda class log function.

Example:

public class MainFunction implements RequestHandler<Object, APIGatewayProxyResponseEvent> {
@Override
public APIGatewayProxyResponseEvent handleRequest(Object input,
Context context) {
//Start SixthSense Lambda log
SSLambda ssLambda = new SSLambda(input, context);
//Accepts a source key, if your lambda event object is a custom object and contains a source
//you can use that to capture your event source.
ssLambda.logEvent(null);
//End SixthSense Lambda log
APIGatewayProxyResponseEvent response = new APIGatewayProxyResponseEvent();
response.setStatusCode(200);
return response;
}
}

Installing Lambda

Ensure that you have configured AWS. For more information, see Installing AWS.

Once you have configured AWS, you must install Lambda.

  1. Login to the SixthSense portal.
  2. Click Integrations on the left pane.
  3. Click Configure in the Amazon Web Services card available.

If you have already configured services the AWS Configurations page similar to the following appears. If you have not configured services, see Adding a configuration

AWS lambda configuration
  1. Click the ellipse icon against a connection name.
  2. Select View services from the list.

A screen similar to the following appears with no services installed.

AWS lambda No Services
  1. Click Manual Install in the AWS Lambda card to install it manually or click Auto Install to automatically install the Lambda service.
note

Auto install monitors all functions.

  1. If you choose Manual Install, the following screen appears.
AWS RDS install
  1. Fill in the following fields.
FieldDescription
Pull Frequency(min)This frequency can be set to global for all AWS services at the tenant level. You can define AWS service specific pulling frequency. Global pulling frequency can be 5 mins. Note: If AWS service specific pulling frequency is configured, this will have higher precedence over Global pulling frequency.
Global toggle buttonDisabling Global will take the pull frequency set at the service level.
Enable MonitoringAllows you to monitor all the services.
TagsClick + to add multiple tags against each row. Rows are added to add more tags. For more information, see Tagging functions.
  1. Click Save.

You will see that Lambda is configured as in the following screen.

AWS RDS install

The connection is verified with the AWS credentials and you will see the AWS Lambda card under the Installed header.

Adding a configuration

  1. Navigate to the AWS configurations page.
  2. Click + Add configuration if you haven't added the AWS configuration.

Fill in the following fields.

Field nameDescription
Connection nameThe identifier or label assigned to a specific connection when connecting to a function.
Access key IDA unique identifier that is public and can be used to identify the IAM user.
Secret access keyA secret string that is used together with the Access Key ID to sign programmatic requests.
Pull frequency (min)Pull frequency is how often a system, application, or service requests or "pulls" data from another system or source. Can be at subscription or service level.
  1. Click Configure.

Tagging functions

Use tags for monitoring a particular or multiple functions. You can also have mutlitple tags for a function using the AND or OR conditions. Note that you can use only one of the conditions while adding multiple tags.

While adding tags enter the Key value for the function. The value could be the capability name followed by a string.

You must also enter the value that is required for picking the specified values from the function. You can use the logical AND/OR operators for the values you select.

note

Tags are available only for manual installation.

Editing a Lambda configuration.

  1. Login to the SixthSense portal.
  2. Click Integrations on the left pane.
  3. Click Configure in the Amazon Web Services card available.

The AWS Configurations page similar to the following appears.

AWS lambda configuration
  1. Click the    icon against a connection name.
  2. Select View services from the list.
  3. Select Edit configuration.
  4. Edit the required fields.
  5. Click Configure.