Skip to content

Commit

Permalink
Merge pull request #4 from spreaker/fix_boto_multithread
Browse files Browse the repository at this point in the history
Initialize boto3 clients per region in the constructor
  • Loading branch information
Esteban Sanchez authored Jun 12, 2019
2 parents a4609e9 + ea53f42 commit f6d3640
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

### (2019-06-12)
- Fixed boto3 multithreading use

### 1.1.0 (2019-06-11)
- Release 1.1.0 with threads support to query all region in parallel

Expand Down
4 changes: 2 additions & 2 deletions prometheus_aws_guardduty_exporter/collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
class GuardDutyMetricsCollector():
def __init__(self, regions: List[str]):
self.regions = regions
self.botoConfig = botocore.client.Config(connect_timeout=2, read_timeout=10, retries={"max_attempts": 2})
self.pool = Pool(len(self.regions))
self.scrapeErrors = {region: 0 for region in regions}

Expand Down Expand Up @@ -39,7 +38,8 @@ def collect(self):
return [currentFindingsMetric, scrapeErrorsMetric]

def _collectMetricsByRegion(self, region):
client = boto3.client("guardduty", config=self.botoConfig, region_name=region)
botoConfig = botocore.client.Config(connect_timeout=2, read_timeout=10, retries={"max_attempts": 2})
client = boto3.client("guardduty", config=botoConfig, region_name=region)
regionStats = {"low": 0, "medium": 0, "high": 0}

try:
Expand Down

0 comments on commit f6d3640

Please sign in to comment.