Skip to content

Commit

Permalink
Walkthrough (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
dpetzold authored Dec 6, 2021
1 parent b0bc32d commit ec7c8a3
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,59 @@ https://github.com/dpetzold/aws-log-parser/blob/master/examples/count-hosts.py

for a more complete example.

## Walkthrough

The avaliable `LogType`'s are:

* CloudFront
* CloudFrontRTMP
* ClassicLoadBalancer
* LoadBalancer

pass the appropriate `LogType` to `AwsLogParser`:


```python
>>> from aws_log_parser import AwsLogParser, LogType
>>> parser = AwsLogParser(log_type=LogType.CloudFront)
```

The general method to read files is `read_url`. It returns a generator of
dataclasses for the specified `LogType`. Currently the S3 and file
schemes are supported.

S3:

```python
>>> entries = parser.read_url("s3://aws-logs-test-data/cloudfront")
```

file:

```python
>>> entries = parser.read_url(f"file://{os.cwd()}/logs/cloudfront")
```

iterate through the log entries and do something:

```python
>>> for entry in entries:
>>> ...
```

If you need to set the AWS profile or region you can pass it to `AwsLogParser`:

```python
>>> parser = AwsLogParser(
>>> profile="myprofile",
>>> region="us-west-2",
>>> )
```

## Models

See https://github.com/dpetzold/aws-log-parser/blob/master/aws_log_parser/models.py

### CloudFront

```python
Expand Down

0 comments on commit ec7c8a3

Please sign in to comment.