Email if a cron job succeeds on Cronitor - cron

Is it possible to add a setting on Cronitor that sends an email once a cron job succeeds. Right now I only get email if a cron job fails.
This is what i have at the moment :
Alert preferences Failure tolerance Duration alerts
Alert notes
(X) Send alerts any time there is a problem
() Only send alerts if my job has consistently not run when expected...
I tried to email/contact support but now answer from Cronitor yet.

I'm one of the creators of Cronitor. I'm really sorry we somehow missed your support inquiry.
The answer is that, yes, this is possible but you cannot set this up without an API call. After the initial setup is complete (and the new alert rule is added) you can continue managing the monitor from the dashboard.
If you email support#cronitor.io again with specifics I can help you with adding this rule via the API.

Related

What's wrong with my usage of Azure Alerts?

OK, so I simply want to create an alert, for when my URL is unreachable.
As a test, I followed the steps found here to create an availability test for https://www.google.com, and as success criteria, I put 500 as my HTTP response; it was felt that this will trigger an alert.
The action group that I created is an MS Teams group; this is working, I know this because it is used by different alerts. Then, I created a new Alert, with the Condition of my newly created availability test, then I waited.
I expected to get an alert upon failure of my test. I can see that the test is failing, but there is no alert. What might I [not be grasping/be doing wrong]?
Turns out I must have mistyped something. All I know is that doing it from scratch (for the 3rd time) fixed it.

In Azure, how to suppress E-Mail-Alerts correctly?

I've established an email alert inside azure. This alert listens to the response times of a specific azue function. If the average response time exceeds a threshold (e.g. 300ms), then the alert will be triggered and an email will be sent. If the average response time falls below the threshold a couple of minutes later, then a second email will be sent ("alert resolved")
Furthermore I established a suppress condition which suppresses the alert at night.
I've noticed that the second resolve-mail will still be sent at night (when the suppress condition is active). The first trigger-mail will not be send at night anymore.
I want that the second resolve-email will also be really suppressed at night. Does anybody have an idea?
The ideal way to suppress notifications for your alerts would be to use the Action Rules feature, which is currently in preview.
The best part about action rules is that you can define them at any scope: at the subscription, resource group, or individual resource level, with other available filters. While all actions and notifications on the selected scope and filters will be suppressed for the time period configured, alerts will continue to monitor.
As an example, the following action rule is configured to suppress alert notifications from 7 PM - 7AM every day.
Please give it a try and see if it fits your need. More about this here. Hope this helps!

Scheduling an email with the Gmail API

I found a similar question from 2016, however at that time Gmail itself did not support scheduled sending of emails.
Now that you can schedule messages to send later directly from Gmail, I was wondering if there was a way to do it with their API.
Interestingly, scheduled emails appear as message objects when calling messages.list, but they do not contain any labels.
Any help would be appreciated! And if it's not possible at the moment, it would be awesome to get a reply from someone at Google about when this will become possible (I believe they officially endorse the gmail-api tag to StackOverflow)
I don't think a time-based trigger will work--even if you write the code to store email send data and then build something that regularly checks whether it's time for an email to be sent. See Google's documentation on triggers, and you'll notice that time-based triggers aren't available for Gmail scripts.
Unfortunately, there is no Gmail API endpoint for scheduling the sending of emails directly.
One workaround would be to write a script in Google Apps Script (https://script.google.com) which handles the composing of the email you wish to send, as well as a function to send the mail via the API. You can then use the built-in 'Apps Script Project Triggers' feature to trigger the function to run on a schedule; for example on action/event or at a specific/repeated time.
Button for adding trigger to Apps Script

How to invoke Azure Scheduled Job by a webrequest

How do i invoke a Microsoft Azure Scheduled Job from my serverside code?
I have a running Scheduled Job, that calls an endpoint, to send out some emails and sync some data.
I have a system, where users can send emails out to lists of emails. So instead of the user waiting xx minutes for a response from the web server, after it is done sending out emails, I would like to just call my Scheduled Job, so that the user can initiate the email sendout, but doesnt have to wait for it to finish. Sort of "Fire and forget" for the user.
How do i go around to do this? I haven't been able to find any info on how to achieve it.
Thanks in advance.
Update:
I found this documentation right after posting:
https://learn.microsoft.com/en-us/rest/api/scheduler/jobs/run
POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Scheduler/jobCollections/{jobCollectionName}/jobs/{jobName}/run?api-version=2016-03-01
I am however not able to find info on how to authenticate against this endpoint. But it seems like its definetly possible to do.
I'll leave the question/answer be, in case it can help anyone.
It turned out that using the azure endpoint for a Post call to invoke the scheduled job, was a good solution.
After setting the resource group and jobcollection up correctly, I got it working.
https://learn.microsoft.com/en-us/rest/api/scheduler/jobs/run
POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Scheduler/jobCollections/{jobCollectionName}/jobs/{jobName}/run?api-version=2016-03-01

Check whether cronjob has ran or not

I have one python script running in crontab, I want to check if it is running successfully or not? if not then send mail or another kind of notification. How do I notify based on Cron logs?
Things I already Tried:
All the Exception in python file I have already handled
Need: Notify user if Cron job is not running successfully?
In order to notify weather cron job running or not, you can set email id in cpanel 'cron jobs' page. so you will receive email once file get executed.
There are monitoring services specifically for cronjobs, doing exactly what you're asking for. I'm partial to WDT.io and here're the detailed instructions: https://cookbook.wdt.io/cron.html.

Resources