GSuite Google mail reports through API - google-admin-sdk

I would like to access the GSuite reports to fetch the email logs periodically and be able to parse them locally to find anomalies . The only way I can do that right now is going through the Reports tab.
Is there any way I can accomplish this through an API ?
Thanks.

Related

Notification on first login to GCP bigquery

I am trying to explore if there is a way to trigger a user alert/popup or a notification to a user on the very first login into Bigquery, the objective is to show a popup/redirect to a page which has the standards/tutorials/best practices of how to use bigquery in the organization
Users do not login to BigQuery. Review how Google OAuth 2.0 works in Google Services and Google Cloud. If you want to display a popup, etc. then you will need to implement Google OAuth. You can display anything you want on your login page.
You will not be able to intercept the authorization process at BigQuery.

How can I transfer logs from Logs Viewer of GCP to Slack or email?

I have been exploring to transfer the JsonPayload message field from Logs viewer service (which are syslogs of a service) of GCP to a slack network, but owing to this I am not able to find any predefined services (like alerting policies to transfer Payload) available on Stackdriver. I have been able to create a counter or distribution user-metrics for logs but this will only provide me with some int64 value instead of a string value or the actual message body. Is there a way in GCP to actually send a payload of logs over slack or any email?
We had a similar issue where we wanted to be able to send certain events to slack and for fatal issues trigger an issue with our ops team via VictorOps.
Couldn't find anything out there to fit our needs so we just created our own slack / VictorOps Cloudfunction.
https://github.com/patiently/gcloud-slack-logger
In GCP, you can export logs to Pub/Sub, Cloud Storage, or BigQuery. There is no other way within GCP to export logs at the moment.
As of 2022, I found this can be done as follows:
In GCP Logs viewer (not legacy version) choose the create alert button.. One of the options here is a GCP notification channel, which supports slack. Some points here:
The slack channel can't be private as far as I can tell
Slack channel must be in your correct slack space. If your org has multiple slack spaces, make sure GCP is trying to connect to correct one.
Put in the log query criteria you want. THen go into Monitoring and you will see this in Alerting dropdown.

How to use Google cloud platform DLP API

Can anyone please tell me how to use Google Cloud DLP API and can I track my local system using these Google Cloud API like track info which is flow from Facebook, Gmail, Skype etc.?
Do you mean you want to track data flowing between those systems? I'm not aware of a way to inject yourself between them.
If you want to track what is being sent out on your local network and are looking for design ideas - one such idea could be to use a local proxy that you have configured to send all traffic through something like https://cloud.google.com/dlp/docs/reference/rpc/google.privacy.dlp.v2#inspectcontentrequest so that you can send up alerts if there is anything surprising.
Gmail also has a version of Cloud DLP built in for gsuite customers to automatically monitor/prevent employees from sending email with specific finding types.

Get real-time notifications from Gmail and Google calendar on slack with PubSub

I try to get real-time notifications on my slack channel from google calendar and gmail apis.
I already created a Pub-Sub account and I want to add a push subscription on my topic with a slack incoming webhook url but when I try to add it, I got :
The supplied HTTP URL is not registered in the subscription's parent project
I've tried the same thing and it seems that first, you need to verify ownership of your webhook domain.
You would do it here :
https://console.developers.google.com/apis/credentials/domainverification
if you would own the slack domain, which I don't think you do...and I don't either...unfortunately I haven't found a solution to circumvent this.
"You need to verify domain ownership to allow webhook notifications to be sent to your external domains. Google verifies that the user owns each of the listed domains via Search Console."
iv the same problem.
Try with this https://github.com/Spencer-Easton/Apps-Script-Gmail-Push-Notifications
or see : https://cloud.google.com/pubsub/docs/advanced#push_endpoints
The documentation explains, in the article "Cloud Pub/Sub > Documentation > Advanced Configuration", in the section "Register Endpoints", how to register endpoints not on App Engine or not on the same cloud project. You'll need to very that you own the domain and register it.

AWS SES - Logging SendEmail & SendRawEmail calls (SMTP)

We've changed our email service from Mandrill to Amazon SES. We are using it with SMTP.
In Mandrill we had access to some details such as:
raw content of the emails
delivery dates
is the email viewed by the recipient
are the links in the email clicked
But in SES Management Console > Sending Statistics page it shows only the numbers without any details for deliveries, bounces, complaints & rejects.
And I've looked into CloudTrail, CloudWatch & S3 combination with no luck. Also I'm not sure if this is still valid but this page says
All Amazon SES APIs except for the email-sending APIs (SendEmail and SendRawEmail) are supported.
So I can't seem to log these data with CloudTrail.
Can I log them via another method (maybe a third party tool?). How do other people log these? Or do they? Maybe it's not possible with SMTP but possible with only API?
Example scenario
We're using multiple IAM access keys (with multiple users) for SES. Let's say there is 50% increase in complaints. Doesn't AWS offer any tool to find the culprit access key?
I had found this thread when trying to get easy access to who Amazon SES sent emails to, at what time, etc. I found the tutorials at Amazon pretty helpful:
https://docs.aws.amazon.com/ses/latest/DeveloperGuide/event-publishing-tutorials.html
I actually tried all four of them. I couldn't figure out how to get the CloudWatch path to actually show who the email went to, but the other ones worked. I eventually settled on the Amazon Redshift path:
https://docs.aws.amazon.com/ses/latest/DeveloperGuide/event-publishing-redshift.html
It works well for me and provides an SQL query view into the "log" data. They do have a new Query tool, so you don't have to use JDBC/ODBC if you don't want to.
Hoping this will help someone else looking...
For raw content logging, you would have to proxy the SMTP requests through some service that logs everything and then sends it to SES, or just log everything in your code before making the call to SES.
For delivery rates you would have to setup SNS listeners to process SES bounce notifications.
For email viewed and links clicked you would have to build your own analytics service to add tracking to the emails you send, or find some third-party service that does that for you.
There is a reason SES is so much cheaper than other email services like Mandrill, it is because you don't get all the features that the other services provide. Honestly if you want things like click tracking analytics I would suggest you rethink moving away from Mandrill, or look at other email services like SendGrid. SES is more of a raw email sending service that doesn't provide any of those higher-level features you are looking for.