SnowAlert icon indicating copy to clipboard operation
SnowAlert copied to clipboard

Can snowalert send attachments from s3 in email.

Open syedirfanahmedansari opened this issue 3 years ago • 15 comments

we have requirement where we want error files/csv files to be send as an attachment.

Can it be done using SES/SNS or simply SMTP handlers.

Please respond ASAP.

Thanks! Irfan.

syedirfanahmedansari avatar Jun 02 '21 19:06 syedirfanahmedansari

Could you clarify what you mean by "from S3"?

sfc-gh-afedorov avatar Jun 02 '21 20:06 sfc-gh-afedorov

Can snowalert access AWS S3 to send attachments.

syedirfanahmedansari avatar Jun 03 '21 17:06 syedirfanahmedansari

Snowflake can access S3 via PIPE's and External Functions which can access S3 via boto3, and SnowAlert runs on Snowflake, so yes, SnowAlert can access S3 to send attachments.

sfc-gh-afedorov avatar Jun 03 '21 17:06 sfc-gh-afedorov

Reviewing their code (ses.py smtp.py), I don't think any of the current handlers will reach out to S3 directly. It's probably best that way -- their role is to send emails, not read data from S3.

sfc-gh-afedorov avatar Jun 03 '21 18:06 sfc-gh-afedorov

i don't see any part in ses.py/smtp.py where they take attachments.

so this means the current handlers don't support file attachment from any where.

syedirfanahmedansari avatar Jun 03 '21 19:06 syedirfanahmedansari

Yes, per their docs, seems like you'd need to add attachment to the params and —

if attachment:
  att = MIMEApplication(attachment['content'])
  att.add_header('Content-Disposition', 'attachment', filename=attachment['filename'])
  message.attach(att)

to smtp.py for that to work.

We're moving over to using External Functions for handlers, tho, and will have news on that front soon.

Can update the ticket when that work is ready for public release.

sfc-gh-afedorov avatar Jun 03 '21 19:06 sfc-gh-afedorov

at our end snowalert runs on AWS ECR. if the attachment is to be added then that file needs to present in running machine. for attachment to work the file needs to present locally. My concern is how will it attach from outside. or how do i send the file to the docker instance.

syedirfanahmedansari avatar Jun 03 '21 19:06 syedirfanahmedansari

Can you send me a sample for using SES handler

syedirfanahmedansari avatar Jun 03 '21 19:06 syedirfanahmedansari

we don't have one for SES on hand (it's a third party contribution that my team doesn't use), but SMTP is documented here. all the handlers are the same interface, tho -- the "type" key specifies which Python module is loaded, and the rest of the keys are passed in as parameters to the "handle" method in that module.

sfc-gh-afedorov avatar Jun 03 '21 21:06 sfc-gh-afedorov

Can you please share a sample select for SMTP handler

syedirfanahmedansari avatar Jun 30 '21 15:06 syedirfanahmedansari

https://docs.snowalert.com/alerts/handlers/smtp

sfc-gh-afedorov avatar Jun 30 '21 16:06 sfc-gh-afedorov

Hi,

Can you please provide Steps to configure Snowalert on AWS using Cloud formation Template.

Thanks! Irfan.

syedirfanahmedansari avatar Jul 16 '21 14:07 syedirfanahmedansari

We have not deployed on cfn ourselves, but someone who has provided this code and these instructions. Does that help?

sfc-gh-afedorov avatar Jul 16 '21 16:07 sfc-gh-afedorov

Hi,

it seems we are getting duplicate alerts.

the way we are running is we have a view in snowflake to which the final Alert query is pointing and we have scheduled snow alert to run for every 5 minutes.

if any entry comes in two executions then the alerts are being published twice. how can we suppress the second alert.

syedirfanahmedansari avatar Aug 04 '21 15:08 syedirfanahmedansari

Alerts are deduplicated by object and description, so if those are identical and the alerts are within the look-back period, you should be good. Could you check whether e.g. you are including the current time in the description, perhap?

sfc-gh-afedorov avatar Aug 07 '21 03:08 sfc-gh-afedorov