Metadata-Version: 2.1
Name: c7n_logexporter
Version: 0.4.44
Summary: Cloud Custodian - Cloud Watch Log S3 exporter
Home-page: https://cloudcustodian.io
License: Apache-2.0
Author: Cloud Custodian Project
Requires-Python: >=3.9.2,<4.0.0
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: System :: Distributed Computing
Classifier: Topic :: System :: Systems Administration
Requires-Dist: c7n (==0.9.45) ; python_full_version >= "3.9.2" and python_full_version < "4.0.0"
Requires-Dist: c7n (==0.9.45) ; python_full_version >= "3.9.2" and python_full_version < "4.0.0"
Requires-Dist: click (==8.1.8) ; python_full_version >= "3.9.2" and python_full_version < "4.0.0"
Requires-Dist: argcomplete (==3.6.2) ; python_full_version >= "3.9.2" and python_full_version < "4.0.0"
Requires-Dist: boto3 (==1.38.25) ; python_full_version >= "3.9.2" and python_full_version < "4.0.0"
Requires-Dist: cryptography (==44.0.3) ; python_full_version >= "3.9.2" and python_full_version < "4.0.0"
Requires-Dist: docutils (==0.18.1) ; python_full_version >= "3.9.2" and python_full_version < "4.0.0"
Requires-Dist: importlib-metadata (==8.6.1) ; python_full_version >= "3.9.2" and python_full_version < "4.0.0"
Requires-Dist: jsonschema (==4.24.0) ; python_full_version >= "3.9.2" and python_full_version < "4.0.0"
Requires-Dist: python-dateutil (==2.9.0.post0) ; python_full_version >= "3.9.2" and python_full_version < "4.0.0"
Requires-Dist: pyyaml (==6.0.2) ; python_full_version >= "3.9.2" and python_full_version < "4.0.0"
Requires-Dist: tabulate (==0.9.0) ; python_full_version >= "3.9.2" and python_full_version < "4.0.0"
Requires-Dist: urllib3 (==1.26.20) ; python_full_version >= "3.9.2" and python_full_version < "4.0.0"
Requires-Dist: colorama (==0.4.6) ; python_full_version >= "3.9.2" and python_full_version < "4.0.0" and platform_system == "Windows"
Requires-Dist: botocore (==1.38.25) ; python_full_version >= "3.9.2" and python_full_version < "4.0.0"
Requires-Dist: jmespath (==1.0.1) ; python_full_version >= "3.9.2" and python_full_version < "4.0.0"
Requires-Dist: s3transfer (==0.13.0) ; python_full_version >= "3.9.2" and python_full_version < "4.0.0"
Requires-Dist: cffi (==1.17.1) ; python_full_version >= "3.9.2" and python_full_version < "4.0.0" and platform_python_implementation != "PyPy"
Requires-Dist: zipp (==3.22.0) ; python_full_version >= "3.9.2" and python_full_version < "4.0.0"
Requires-Dist: attrs (==25.3.0) ; python_full_version >= "3.9.2" and python_full_version < "4.0.0"
Requires-Dist: jsonschema-specifications (==2025.4.1) ; python_full_version >= "3.9.2" and python_full_version < "4.0.0"
Requires-Dist: referencing (==0.36.2) ; python_full_version >= "3.9.2" and python_full_version < "4.0.0"
Requires-Dist: rpds-py (==0.25.1) ; python_full_version >= "3.9.2" and python_full_version < "4.0.0"
Requires-Dist: six (==1.17.0) ; python_full_version >= "3.9.2" and python_full_version < "4.0.0"
Requires-Dist: pycparser (==2.22) ; python_full_version >= "3.9.2" and python_full_version < "4.0.0" and platform_python_implementation != "PyPy"
Requires-Dist: typing-extensions (==4.13.2) ; python_full_version >= "3.9.2" and python_version < "3.13"
Project-URL: Documentation, https://cloudcustodian.io/docs/
Project-URL: Repository, https://github.com/cloud-custodian/cloud-custodian
Description-Content-Type: text/markdown

# 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

 - The archive bucket has already has appropriate bucket policy permissions.
   For details see:
   https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/S3ExportTasks.html#S3Permissions
 - Default periodicity for log group archival into s3 is daily.
 - Exporter is run with account credentials that have access to the archive s3 bucket.
 - Catch up archiving is not run in lambda (do a cli run first)


## 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
```


