Skip to content

Commit ec7c8a3

Browse files
authored
Walkthrough (#24)
1 parent b0bc32d commit ec7c8a3

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,59 @@ https://github.com/dpetzold/aws-log-parser/blob/master/examples/count-hosts.py
4141

4242
for a more complete example.
4343

44+
## Walkthrough
45+
46+
The avaliable `LogType`'s are:
47+
48+
* CloudFront
49+
* CloudFrontRTMP
50+
* ClassicLoadBalancer
51+
* LoadBalancer
52+
53+
pass the appropriate `LogType` to `AwsLogParser`:
54+
55+
56+
```python
57+
>>> from aws_log_parser import AwsLogParser, LogType
58+
>>> parser = AwsLogParser(log_type=LogType.CloudFront)
59+
```
60+
61+
The general method to read files is `read_url`. It returns a generator of
62+
dataclasses for the specified `LogType`. Currently the S3 and file
63+
schemes are supported.
64+
65+
S3:
66+
67+
```python
68+
>>> entries = parser.read_url("s3://aws-logs-test-data/cloudfront")
69+
```
70+
71+
file:
72+
73+
```python
74+
>>> entries = parser.read_url(f"file://{os.cwd()}/logs/cloudfront")
75+
```
76+
77+
iterate through the log entries and do something:
78+
79+
```python
80+
>>> for entry in entries:
81+
>>> ...
82+
```
83+
84+
If you need to set the AWS profile or region you can pass it to `AwsLogParser`:
85+
86+
```python
87+
>>> parser = AwsLogParser(
88+
>>> profile="myprofile",
89+
>>> region="us-west-2",
90+
>>> )
91+
```
92+
4493
## Models
4594

95+
See https://github.com/dpetzold/aws-log-parser/blob/master/aws_log_parser/models.py
96+
4697
### CloudFront
4798

4899
```python

0 commit comments

Comments
 (0)