Skip to main content

Cloud Custodian - Cloud Watch Log S3 exporter

Project description

c7n-log-exporter: Cloud watch log exporter automation

A small serverless app to archive cloud logs across accounts to an archive bucket. It utilizes cloud log export to s3 feature for historical exports.

It also supports kinesis streams / firehose to move to realtime exports in the same format as the periodic historical exports.

Features

  • Log group filtering by regex
  • Incremental support based on previously synced dates
  • Incremental support based on last log group write time
  • Cross account via sts role assume
  • Lambda and CLI support.
  • Day based log segmentation (output keys look like $prefix/$account_id/$group/$year/$month/$day/$export_task_uuid/$stream/$log)

Assumptions

Cli usage

make install

You can run on a single account / log group via the export subcommand

c7n-log-exporter export --help

Config format

To ease usage when running across multiple accounts, a config file can be specified, as an example.

Using S3 Bucket as destination

destination:
  bucket: custodian-log-archive
  prefix: logs2

accounts:
  - name: custodian-demo
    role: "arn:aws:iam::111111111111:role/CloudCustodianRole"
    groups:
      - "/aws/lambda/*"
      - "vpc-flow-logs"

Using CloudWatch Destination as destination cross account

The Cloudwatch Destination needs setup in account and access policy set on CloudWatch Destination to to allow source account access to the Cloudwatch Destination

subscription:
  destination-arn: "arn:aws:logs:us-east-1:111111111111:destination:CustodianCWLogsDestination"
  destination-role: "arn:aws:iam::111111111111:role/CWLtoKinesisRole"
  name: "CustodianCWLogsDestination"

destination:
  bucket: custodian-log-archive
  prefix: logs2

accounts:
  - name: custodian-demo
    # https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CreateSubscriptionFilter-IAMrole.html
    subscription-role: "arn:aws:iam::111111111111:role/<role-name>"
    role: "arn:aws:iam::111111111111:role/CloudCustodianRole"
    groups:
      - "/aws/lambda/*"
      - "vpc-flow-logs"

Multiple accounts via cli

To run on the cli across multiple accounts, edit the config.yml to specify multiple accounts and log groups.

c7n-log-exporter run --config config.yml

Serverless Usage

Edit config.yml to specify the accounts, archive bucket, and log groups you want to use.

make install
make deploy

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

c7n_logexporter-0.4.26-py3-none-any.whl (14.0 kB view details)

Uploaded Python 3

File details

Details for the file c7n_logexporter-0.4.26-py3-none-any.whl.

File metadata

File hashes

Hashes for c7n_logexporter-0.4.26-py3-none-any.whl
Algorithm Hash digest
SHA256 f1eb7e00caa91f794c17fcaed7d16bc462d474efdfa759df315b31c2fa2fd20a
MD5 d9176a59da1038cad69587cf87406563
BLAKE2b-256 34d01400f70139bd315359794fea0f7015a39f84c0c869e464df57399912a43c

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page