Use Power Automate to archive the SendGrid activity events
As you may know, the SendGrid will only save 30-days activity events. Sometimes we need to store the logs for a more long time for troubleshooting purposes or auditing purposes.
In this blog, I will share a step by step method to archive the SendGrid activity logs to Azure Log Analytics.
Prerequisites
To use Log Analytics, you need to be signed in to an Azure account. If you don't have an Azure account, create one for free.
SendGrid Account. If you don't have a SendGrid account, create one for free.
Licensed Flow Account. If you don't have one, start a trial.
Create the Flow
2. Create an Instant flow from blank.
3.Give the Flow a name, such as Archive Sendgrid Activities.
4. Select the "When an HTTP request is received" as the Trigger and Click Create.
4. Select the "When an HTTP request is received" as the Trigger and Click Create.
6. Select the method as POST and specify the relativePath as "Accounts{AccountName}".
7.Click New Step, input "Azure Log Analytics Data Collector", select Azure Log Analytics...
8. Select Send Data(preview).
9. Input the Connection Name, Workspace ID, Workspace key. You can get these data from the Azure Portal.
I want to support multiple SendGrid Accounts, so I choose the AccountName as the Custom Log Name. If you don't have the requirements, you can just hard code the Custom Log Name such SendGridActivies.
12. Click Save. After the Flow is saved, copy the HTTP Post Url from the Trigger. This is will be used in the following step.
1. Sign in to the SendGrid UI.
3. Click Event Webhook.
4. Paste the copied Url into the HTTP Post URL. And select the events you want to archive.
5. Click Test Your Integration, to send a sample event notification to the Flow.
7. Select Event Webhook Status as ENABLED. Then click Save.
That's all. Then you will be able to confirm the SendGrid activities from the Log Analytics.
Comments
Post a Comment