I need to get an email alert to my email when a specific file in GCP bucket is arrived/available. Which functionality/tool i can use in GCP.
Asked
Active
Viewed 545 times
2 Answers
1
You can look at the following approach:
- Use Cloud Functions and specifically the Google Cloud Storage Trigger with the default event
google.storage.object.finalize
. Check out sample code here. - In the function code, you can pass on relevant file details and use a 3rd party email service like SendGrid, etc to send an email. Check out instructions/code here to send out email: https://cloud.google.com/security-command-center/docs/how-to-enable-real-time-notifications

Romin
- 8,708
- 2
- 24
- 28
-
Thanks Romin..will check if we can get SendGrid – Ram Jun 30 '22 at 16:46
-
Check out this documentation on instructions to send out email via SendGrid. You can take parts of the sample code shown here for your purpose. https://cloud.google.com/security-command-center/docs/how-to-enable-real-time-notifications – Romin Jul 01 '22 at 02:17
0
@Romin solution will work, you can also have a look to Eventarc and Cloud Run.
However, you can use a hack fully managed by Google Cloud.
Firstly, activate the Cloud Storage Audit Logs (be careful, if you have a lot of activity, it can generate a lot of logs and be costly).
Then, create a log based metrics on the audit logs that mentionned the file creation and with the filter on the file path (you can use the =~ operator for regex filtering)
Finally, create an alert on that metrics, and send an email when the alert is triggered

guillaume blaquiere
- 66,369
- 2
- 47
- 76
-
Hi Guillaume, Can we use Monitoring Alert on customized scripts output files either shell or python which checks the file in storage bucket or we use monitoring alerts only for audit logs – Ram Jun 30 '22 at 16:46
-
No no, it's a ack to let the system generate an automatic alert on a alert config. You can't configure or customize things, it's a raw and automatic email. – guillaume blaquiere Jun 30 '22 at 20:09