Value Changing Monitor
This is an API which get you know some value changes. Implemented with Serverless
For example, you can watch registration count of some service, a product price, temparature, .etc. Anything which has value can be monitored.
Usage
- Create your resource that is to be monitored. Define initial value and Slack webhook info for receive notifications.
- Just only PUT a value continuously.
Create a resource
Request
POST a JSON to create a resource.
URL
https://monitor.ecp.plus/resources
Body
JSON schema is following.
{
"name": "TEST",
"initialValue": 0,
"slack": {
"url": "https://hooks.slack.com/services/AAAA/1111/qwerty",
"channel": "#value_test",
"template": "Users count is {value}",
"icon_emoji": ":smile:"
}
}
All fields except slack.icon_emoji
are required.
template
. It includes a special placeholder {value}
. When posting a notification, the {value}
will be replaced to the actual value.
cURL example
curl https://monitor.ecp.plus/resources -X POST -d "{name: 'Registration count', initialValue: 0, slack: {url: 'https://hooks.slack.com/services/1111/AAAA/qwerty', channel: '#value_changing_test', template: 'Awesome value is {value}'
, icon_emoji: ':smile:'}}"
Response
{
"uuid": "f0d675cf-b8dc-46c9-9536-23ab358d2817",
"name": "Registration count",
"value": 0
}
Please keep the uuid
.
You will use uuid
to PUT values.
Put a value
If PUT value is different from previous value, you will receive a Slack notification.
Request
URL
https://monitor.ecp.plus/resources/{uuid}
{uuid}
is that you got when creating.
Body
PUT only a value.
{
"value": 100
}
cURL example
curl https://monitor.ecp.plus/resources/f0d675cf-b8dc-46c9-9536-23ab358d2817 -X PUT -d "{value: 100}"
Response
If the value has changed.
{
"result": "changed"
}
If the value hasn't changed.
{
"result": "not changed"
}