Skip to content

Using data from SES for statistics

0

I want to make a system so that every month i can send my clients statistics for that month. i am talking about SES. The problem arises when you have multiple clients because i see no way of filtering the data. i tried doing configuration set and then redirecting them to S3 bucket but i am stuck on how to make that file useful. Can anyone help?

asked 10 months ago127 views

2 Answers
6

How about this:

  1. Tag Emails with Configuration Sets • Create a Configuration Set per client, or use a shared one with custom headers or message tags. • Use X-Client-ID or SES messageTags to identify which client each email belongs to.
  2. Stream Events to S3 • In your Configuration Set, set up an Event Destination to S3.
{
  "eventType": "Send",
  "mail": {
    "timestamp": "2025-09-01T12:00:00.000Z",
    "messageId": "abc123",
    "tags": {
      "ClientID": ["clientA"]
    }
  }
}
  1. Query the Data with Athena • Use Amazon Athena to query the S3 bucket directly. • Create a table that maps to your SES JSON structure.
SELECT 
  mail.tags.ClientID[1] AS client,
  COUNT(*) AS total_sent
FROM ses_events
WHERE eventType = 'Send'
  AND mail.timestamp BETWEEN date '2025-09-01' AND date '2025-09-30'
GROUP BY client

This gives you monthly stats per client. 4. Visualize or Export • Use Amazon QuickSight to build dashboards • Or export results to CSV and email them monthly

EXPERT

answered 10 months ago

  • So I have been trying to implement your answer, but I am stuck on the Athena part. I get the error "Queries of this type are not supported."

    SELECT
      mail.source AS sending_email,
      COUNT(*) AS total_events
    FROM `ses-analitics`.`ses_events_detailed`
    WHERE year = '2025' AND month = '09'
    GROUP BY mail.source
    ORDER BY total_events DESC
    

    I have tried to describe the table and every other thing, but when I want to use the data, I get that error. For example, I get the same error with this code.

    SELECT *
    FROM `ses-analitics`.`ses_events_detailed`
    LIMIT 10
    

    I tried searching for the solution, but no luck so far

0

So I have been trying to implement your answer, but I am stuck on the Athena part. I get the error "Queries of this type are not supported."

SELECT
  mail.source AS sending_email,
  COUNT(*) AS total_events
FROM `ses-analitics`.`ses_events_detailed`
WHERE year = '2025' AND month = '09'
GROUP BY mail.source
ORDER BY total_events DESC

I have tried to describe the table and every other thing, but when I want to use the data, I get that error. For example, I get the same error with this code.

SELECT *
FROM `ses-analitics`.`ses_events_detailed`
LIMIT 10

I tried searching for the solution, but no luck so far

answered 10 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.