Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[lambda][alert] adding support for sns as a source #119

Merged
merged 2 commits into from
Apr 25, 2017

Conversation

ryandeivert
Copy link
Contributor

to @airbnb/streamalert-maintainers
size: small

work in progress for #64

changes

  • Adding sns source support
  • Updating tests to include sns sources

@jacknagz
Copy link
Contributor

anotha commit
anothaone

@ryandeivert ryandeivert force-pushed the ryandeivert-sns-source-support branch from cdc205e to 4c9de29 Compare April 25, 2017 00:47
@@ -67,8 +67,8 @@ def validate_config(config):

# check sources attributes
elif config_key == 'sources':
if not set(settings.keys()).issubset(set(['kinesis', 's3'])):
raise ConfigError('Sources missing kinesis or s3 keys')
if not set(settings.keys()).issubset(set(['kinesis', 's3', 'sns'])):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of doing set([]) let's just do {}

@@ -130,11 +130,14 @@ def map_source(self, payload):
payload.service = 'kinesis'
elif 's3' in payload.raw_record:
payload.service = 's3'
elif 'Sns' in payload.raw_record:
payload.service = 'sns'

# map the entity name from a record
entity_mapper = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#simplify (discussed offline)

@ryandeivert ryandeivert force-pushed the ryandeivert-sns-source-support branch from 5803ad8 to 4c9de29 Compare April 25, 2017 17:56
Updating tests to include sns sources.
@ryandeivert ryandeivert force-pushed the ryandeivert-sns-source-support branch from 4c9de29 to b6cb86b Compare April 25, 2017 17:58
@@ -86,6 +88,12 @@ def s3_process(self, payload, classifier):
classifier.classify_record(payload, data)
self.process_alerts(payload)

def sns_process(self, payload, classifier):
"""Process SNS data for alerts"""
data = StreamPreParsers.pre_parse_sns(payload.raw_record)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this method looks almost the same as the kinesis pre parser, can we simplify?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made a small change, but it just mostly consolidates duplicate code into a method. The pre_parse.. methods pull data from different keys, so this is about as simple as this get (see pre_parsers.py for more context).

@ryandeivert ryandeivert force-pushed the ryandeivert-sns-source-support branch 2 times, most recently from df89c55 to d29a645 Compare April 25, 2017 18:31
@ryandeivert ryandeivert force-pushed the ryandeivert-sns-source-support branch from d29a645 to 57bfccc Compare April 25, 2017 18:34
@ryandeivert ryandeivert merged commit f607997 into master Apr 25, 2017
@ryandeivert ryandeivert deleted the ryandeivert-sns-source-support branch April 27, 2017 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants