1

On my AWS Lambda (Python) script, I have:

~     graypy_handler = graypy.GELFTcpHandler(settings.graylog_host, settings.graylog_port, localname=settings.graylog_app)
      env_filter = LogFilter(settings, aws_request_id)

      logging.basicConfig()
~     logger = logging.getLogger()
      logger.addHandler(graypy_handler)
      logger.addFilter(env_filter)
      logger.setLevel(logging.DEBUG)
      return logger

When I do a logger.info("test"), My lambda function would printout the output into Cloudwatch but the log wouldn't be sent externally.

Has anyone managed to send logs from lambda to an external resource like Elasticsearch/Graylog?

Running the same code locally, logs as intended.

David C
  • 3,659
  • 5
  • 34
  • 46

1 Answers1

0

In order for your Lambda function to log to an external service, it will need to have the correct security privileges. By default outbound network access is prohibited.

What those privileges and settings are will depend on where your logging service is deployed.

If it is an external service you will need to configure a VPC and ensure that you lambda and your logging service are both able to communicate via this network. Potentially via an IGW.

stang
  • 311
  • 3
  • 12