<p>There's no generic answer to this, but a ton of options.  Usually the right choice for you would be dependent on what monitoring and alerting stack you're already using.</p>

<p>For instance, if you are using Graphite, Prometheus, rrdtool, or any other round-robin database to record a metric when you're sending out emails, those all have APIs that allow you to query them across a time range to see what the values were.  And depending on what alerting system you're using (Nagios, Icinga, Sensu, etc.) there is probably already a plugin that allows you to easily interact with that particular metrics database.</p>

<p>From another perspective, if you're logging when you send emails, then a log system like ELK will allow you to search and see if any of those log lines are found.  Again, the various alerting systems will have plugins to most common log systems.  (There are also individual systems designed purely for those tools, like <a href="https://elastalert.readthedocs.io/en/latest/index.html" rel="nofollow noreferrer">ElastAlert</a> with its flatline type for ELK.)</p>

<p>Thirdly, you could approach it the way that you are, by checking in with customer.io's API on a regular basis.  But no, there is not one standard tool for doing this, but rather one (or at least one!) per alerting system.</p>

<p>Finally, you might consider doing <strong>synthetic checks</strong> instead of or in addition to your real-user monitoring.  This means having an automated test that performs actions that you expect to result in sending an email, and then checking to see that an email gets sent.</p>

CC BY-SA 4.0
2018-11-21T22:50:47.387Z
2018-11-21T22:50:47.387Z
Xiong Chiamiov
<p>My project is using customer.io to send emails in different flows.</p>
<p>Every now and then we have a bug, and one of those calls stops and email is not sent.</p>
<p>I want to get alerted when an email is not sent in the last 24 hours.
It would be great if the solution could give me alert on any spike but the mvp is 0 in the last 24 hours.</p>
<p>What is the best way to do it?</p>
<p>Currently, I am trying to use some process to poll customer.io REST API which provides exactly the information I need.</p>
<pre class="lang-json prettyprint-override"><code>[{
    &quot;campaign&quot;: &quot;Hello&quot;, 
    &quot;sent&quot;: 0 // This should trigger an alert. sent is for last 24 hours
}, { 
    &quot;campaign&quot;: &quot;World&quot;,
    &quot;sent&quot;: 1 // should not trigger an alert
}]
</code></pre>
<p>Then to do some ETL on this, and feed some data source (maybe cloudwatch, haven't decided yet), and then hook grafana to give me alerts on any spikes.</p>
<p>I am new to this field and am wondering if I am going the right way and if there's a better/easier way to tackle the problem.</p>
<p>== Update - I found out about Grafana SimpleJSON plugin but it expects me to be the owner of the backend. I am going to write some lambdas and use gateway (basically implement an ETL) and use SimpleJSON plugin from grafana to get things going.</p>

CC BY-SA 4.0
2018-11-07T21:00:09.587Z
I assume you could use jq to parse the output and count the failures, but IMHO the application sending the mail should handle the failure itself, retry, and alert after giving up trying a few times.
Tensibai
CC BY-SA 4.0
2018-11-07T21:08:39.517Z
@Tensibai - there's no failure. human error caused some code to stop triggering. there's no logs no nothing.. I want this to be reflected somewhere.
guy mograbi
CC BY-SA 4.0
2018-11-07T21:31:12.473Z
Then request the api to get this Json, then parse it with your language of choice, a 'cheap' solution is curl to get the Json then [jq](https://stedolan.github.io/jq/) to count the failures or filter the failed events depending on what you wish as output I think
Tensibai
CC BY-SA 4.0
2018-11-07T21:32:09.803Z
Just saw your update, this probably should go into a self answer instead of an edit
Tensibai
CC BY-SA 4.0
2018-11-07T23:43:00.013Z
@Tensibai - not sure. Is this the easiest/recommended way to monitor REST responses? I prefer to avoid code in general when monitoring. Since we are using standards, I expect there to be a tool. Otherwise what's the point?
guy mograbi
CC BY-SA 4.0
2018-11-08T09:07:29.403Z
Well, there's no recommended way, everyone has its solutions fitting their needs. I don't know of a generic 'fit them all' solution for monitoring rest APIs answers, as the monitoring is directly tied to the API's answer content, so there's a need to parse the answer somewhere in the chain.
Tensibai
CC BY-SA 4.0
2018-11-08T20:05:21.453Z
@Tensibai `as the monitoring is directly tied to the API's answer`  - so is DB data integrity, but there are tons of tools for that. I don't see a different between REST API and SQL Query for the DB.
guy mograbi
<monitoring>
How to monitor a REST call response?
guy mograbi
# How to monitor a REST call response?

(Asked by: username_0 on 2018-11-07)

My project is using customer.io to send emails in different flows.
Every now and then we have a bug, and one of those calls stops and email is not sent.
I want to get alerted when an email is not sent in the last 24 hours.
It would be great if the solution could give me alert on any spike but the mvp is 0 in the last 24 hours.
What is the best way to do it?
Currently, I am trying to use some process to poll customer.io REST API which provides exactly the information I need.
[{
    "campaign": "Hello", 
    "sent": 0 // This should trigger an alert. sent is for last 24 hours
}, { 
    "campaign": "World",
    "sent": 1 // should not trigger an alert
}]

Then to do some ETL on this, and feed some data source (maybe cloudwatch, haven't decided yet), and then hook grafana to give me alerts on any spikes.
I am new to this field and am wondering if I am going the right way and if there's a better/easier way to tackle the problem.
== Update - I found out about Grafana SimpleJSON plugin but it expects me to be the owner of the backend. I am going to write some lambdas and use gateway (basically implement an ETL) and use SimpleJSON plugin from grafana to get things going.

**Tags:** monitoring

> **Comments:**
> **username_1**: I assume you could use jq to parse the output and count the failures, but IMHO the application sending the mail should handle the failure itself, retry, and alert after giving up trying a few times.  
> **username_0**: @username_1 - there's no failure. human error caused some code to stop triggering. there's no logs no nothing.. I want this to be reflected somewhere.  
> **username_1**: Then request the api to get this Json, then parse it with your language of choice, a 'cheap' solution is curl to get the Json then [jq](https://stedolan.github.io/jq/) to count the failures or filter the failed events depending on what you wish as output I think  
> **username_1**: Just saw your update, this probably should go into a self answer instead of an edit  
> **username_0**: @username_1 - not sure. Is this the easiest/recommended way to monitor REST responses? I prefer to avoid code in general when monitoring. Since we are using standards, I expect there to be a tool. Otherwise what's the point?  
> **username_1**: Well, there's no recommended way, everyone has its solutions fitting their needs. I don't know of a generic 'fit them all' solution for monitoring rest APIs answers, as the monitoring is directly tied to the API's answer content, so there's a need to parse the answer somewhere in the chain.  
> **username_0**: @username_1 `as the monitoring is directly tied to the API's answer`  - so is DB data integrity, but there are tons of tools for that. I don't see a different between REST API and SQL Query for the DB.  

---

## 1 answers

### Answer by username_2 on 2018-11-21. Score: 1

There's no generic answer to this, but a ton of options. Usually the right choice for you would be dependent on what monitoring and alerting stack you're already using.

For instance, if you are using Graphite, Prometheus, rrdtool, or any other round-robin database to record a metric when you're sending out emails, those all have APIs that allow you to query them across a time range to see what the values were. And depending on what alerting system you're using (Nagios, Icinga, Sensu, etc.) there is probably already a plugin that allows you to easily interact with that particular metrics database.

From another perspective, if you're logging when you send emails, then a log system like ELK will allow you to search and see if any of those log lines are found. Again, the various alerting systems will have plugins to most common log systems. (There are also individual systems designed purely for those tools, like [ElastAlert](https://elastalert.readthedocs.io/en/latest/index.html) with its flatline type for ELK.)

Thirdly, you could approach it the way that you are, by checking in with customer.io's API on a regular basis. But no, there is not one standard tool for doing this, but rather one (or at least one!) per alerting system.

Finally, you might consider doing **synthetic checks** instead of or in addition to your real-user monitoring. This means having an automated test that performs actions that you expect to result in sending an email, and then checking to see that an email gets sent.


---

