Slide 51
Slide 51 text
import boto3
import gzip
cw_client = boto3.client('cloudwatch')
event_system = cw_client.meta.events
# Gzip handler
def gzip_request_body(request, **kwargs):
request.headers.add_header('Content-Encoding', 'gzip')
gzipped_body = gzip.compress(request.body)
request.data = gzipped_body
# registers the custom handler
event_system.register('before-sign.cloudwatch.PutMetricData',
gzip_request_body)
cw_client.put_metric_data(...)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import boto3
1
import gzip
2
3
cw_client = boto3.client('cloudwatch')
4
event_system = cw_client.meta.events
5
6
# Gzip handler
7
def gzip_request_body(request, **kwargs):
8
request.headers.add_header('Content-Encoding', 'gzip')
9
gzipped_body = gzip.compress(request.body)
10
request.data = gzipped_body
11
12
# registers the custom handler
13
event_system.register('before-sign.cloudwatch.PutMetricData',
14
gzip_request_body)
15
16
cw_client.put_metric_data(...)
17
import gzip
import boto3
1
2
3
cw_client = boto3.client('cloudwatch')
4
event_system = cw_client.meta.events
5
6
# Gzip handler
7
def gzip_request_body(request, **kwargs):
8
request.headers.add_header('Content-Encoding', 'gzip')
9
gzipped_body = gzip.compress(request.body)
10
request.data = gzipped_body
11
12
# registers the custom handler
13
event_system.register('before-sign.cloudwatch.PutMetricData',
14
gzip_request_body)
15
16
cw_client.put_metric_data(...)
17
cw_client = boto3.client('cloudwatch')
event_system = cw_client.meta.events
import boto3
1
import gzip
2
3
4
5
6
# Gzip handler
7
def gzip_request_body(request, **kwargs):
8
request.headers.add_header('Content-Encoding', 'gzip')
9
gzipped_body = gzip.compress(request.body)
10
request.data = gzipped_body
11
12
# registers the custom handler
13
event_system.register('before-sign.cloudwatch.PutMetricData',
14
gzip_request_body)
15
16
cw_client.put_metric_data(...)
17
# Gzip handler
def gzip_request_body(request, **kwargs):
request.headers.add_header('Content-Encoding', 'gzip')
gzipped_body = gzip.compress(request.body)
request.data = gzipped_body
import boto3
1
import gzip
2
3
cw_client = boto3.client('cloudwatch')
4
event_system = cw_client.meta.events
5
6
7
8
9
10
11
12
# registers the custom handler
13
event_system.register('before-sign.cloudwatch.PutMetricData',
14
gzip_request_body)
15
16
cw_client.put_metric_data(...)
17
request.headers.add_header('Content-Encoding', 'gzip')
import boto3
1
import gzip
2
3
cw_client = boto3.client('cloudwatch')
4
event_system = cw_client.meta.events
5
6
# Gzip handler
7
def gzip_request_body(request, **kwargs):
8
9
gzipped_body = gzip.compress(request.body)
10
request.data = gzipped_body
11
12
# registers the custom handler
13
event_system.register('before-sign.cloudwatch.PutMetricData',
14
gzip_request_body)
15
16
cw_client.put_metric_data(...)
17
gzipped_body = gzip.compress(request.body)
request.data = gzipped_body
import boto3
1
import gzip
2
3
cw_client = boto3.client('cloudwatch')
4
event_system = cw_client.meta.events
5
6
# Gzip handler
7
def gzip_request_body(request, **kwargs):
8
request.headers.add_header('Content-Encoding', 'gzip')
9
10
11
12
# registers the custom handler
13
event_system.register('before-sign.cloudwatch.PutMetricData',
14
gzip_request_body)
15
16
cw_client.put_metric_data(...)
17
# registers the custom handler
event_system.register('before-sign.cloudwatch.PutMetricData',
gzip_request_body)
import boto3
1
import gzip
2
3
cw_client = boto3.client('cloudwatch')
4
event_system = cw_client.meta.events
5
6
# Gzip handler
7
def gzip_request_body(request, **kwargs):
8
request.headers.add_header('Content-Encoding', 'gzip')
9
gzipped_body = gzip.compress(request.body)
10
request.data = gzipped_body
11
12
13
14
15
16
cw_client.put_metric_data(...)
17 cw_client.put_metric_data(...)
import boto3
1
import gzip
2
3
cw_client = boto3.client('cloudwatch')
4
event_system = cw_client.meta.events
5
6
# Gzip handler
7
def gzip_request_body(request, **kwargs):
8
request.headers.add_header('Content-Encoding', 'gzip')
9
gzipped_body = gzip.compress(request.body)
10
request.data = gzipped_body
11
12
# registers the custom handler
13
event_system.register('before-sign.cloudwatch.PutMetricData',
14
gzip_request_body)
15
16
17
import boto3
import gzip
cw_client = boto3.client('cloudwatch')
event_system = cw_client.meta.events
# Gzip handler
def gzip_request_body(request, **kwargs):
request.headers.add_header('Content-Encoding', 'gzip')
gzipped_body = gzip.compress(request.body)
request.data = gzipped_body
# registers the custom handler
event_system.register('before-sign.cloudwatch.PutMetricData',
gzip_request_body)
cw_client.put_metric_data(...)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
loige 23