AWS CloudWatch

How to start logging with AWS CloudWatch through LogDNA.

The LogDNA AWS CloudWatch integration relies on AWS Lambda to route your CloudWatch logs to LogDNA.

Configure the LogDNA AWS Lambda function

  1. Create a new Lambda function and select Author from scratch
  2. For the basic information:
  • Function Name: logdna_cloudwatch (you can choose what to name it)
  • Runtime: Node.js 10.x
  1. Click on the lambda function to edit the details
  • Code entry type: Upload a .ZIP file
  • Upload our LogDNA lambda function .ZIP file
  • Handler: index.handler
  • Runtime: Node.js 10.x
  • Environment variables:
    LOGDNA_HOSTNAME: Alternative Host Name (Optional)
    LOGDNA_TAGS: Comma-separated Tags (Optional)
    BASE_URL: Custom Ingestion URL (Optional)
  1. For Execution role, assign an IAM user with basic execution permissions by choosing an existing role and selecting a role that has permissions to upload logs to Amazon CloudWatch logs.

Configure your AWS CloudWatch Log Group

You have the option of connecting your AWS CloudWatch Log Groups within the Lambda function console or in your CloudWatch console.

In Lambda Function

  1. Add CloudWatch Logs as a Trigger and click it to Configure
  1. Select the CloudWatch Log Group to be sent to LogDNA
  2. Choose your own 'Filter name' and make sure 'Enable trigger' is checked.
  3. Repeat steps 1-3 to add multiple log groups.

Alternatively in CloudWatch

  1. Select the Log Group to be sent to LogDNA
  2. Select the action Stream to AWS Lambda
  3. Choose Destination: Select the Lambda function created above, i.e. logdna_cloudwatch
  4. Configure Log Format and Filters: Choose JSON as a log format
  5. Review your settings to Start Streaming

Validate and Test Your Lambda Function

In your Lambda function console, you can configure a test event to see if your lambda function was set up correctly

  1. Select Configure test events
  1. Create a new test event and select the Event template Hello World and name your test
  2. Replace the sample event data with this:
    "awslogs": {
        "data": "H4sIAAAAAAAAEzWQQW+DMAyF/wrKmaEkJCbhhjbWCzuBtMNUVSmkNBIQRMKqqep/X6Cb5Ivfs58++45G7ZzqdfMza5Sjt6IpTh9lXReHEsXI3ia9BJnQlHHIhMSEBnmw/WGx6xwcp8Z50M9uN2q/aDUGx2vn/5oYufXs2sXM3tjp3QxeLw7lX6hS47lTz6lTO9i1uynfXkOMe5lsp9Fxzyy/9eS3hTsyXYhOGVCaEsBSgsyEYBkGzrDMAIMQlAq+gQIQSjFhBFgqJOUMAog34WAfoFFOOM8kA0Y5SSH+f0SIb67GRaHq/baosn1UmUlHF7tErxvk5wa56b2Z+iRJ0OP4+AWj9ITzSgEAAA=="
  1. Hit Test
  2. If execution succeeds, you will see a message similar to this:

If you see errors, the most common one is not adding in the ingestion key in the environment variables


Execution result: failed

"errorMessage": "Missing LogDNA Ingestion Key"

  1. Log in to your LogDNA console to see the log line from your Lambda function test.

Updated 3 months ago

AWS CloudWatch

How to start logging with AWS CloudWatch through LogDNA.

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.