Skip to content

Commit a89a373

Browse files
authored
Merge pull request #19 from eidam/develop
v1.1
2 parents 1991b6b + 3ed1540 commit a89a373

27 files changed

+2296
-477
lines changed
280 KB
Loading

.github/workflows/deploy.yml

+7
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,18 @@ jobs:
2828
echo "[env.production]" >> wrangler.toml
2929
echo "kv_namespaces = [{binding=\"KV_STATUS_PAGE\", id=\"${KV_NAMESPACE_ID}\"}]" >> wrangler.toml
3030
[ -z "$SECRET_SLACK_WEBHOOK_URL" ] && echo "Secret SECRET_SLACK_WEBHOOK_URL not set, creating dummy one..." && SECRET_SLACK_WEBHOOK_URL="default-gh-action-secret" || true
31+
[ -z "$SECRET_TELEGRAM_API_TOKEN" ] && echo "Secret SECRET_TELEGRAM_API_TOKEN not set, creating dummy one..." && SECRET_TELEGRAM_API_TOKEN="default-gh-action-secret" || true
32+
[ -z "$SECRET_TELEGRAM_CHAT_ID" ] && echo "Secret SECRET_TELEGRAM_CHAT_ID not set, creating dummy one..." && SECRET_TELEGRAM_CHAT_ID="default-gh-action-secret" || true
3133
postCommands: |
3234
yarn kv-gc
3335
secrets: |
3436
SECRET_SLACK_WEBHOOK_URL
37+
SECRET_TELEGRAM_API_TOKEN
38+
SECRET_TELEGRAM_CHAT_ID
3539
environment: production
3640
env:
41+
NODE_ENV: production
3742
CF_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }}
3843
SECRET_SLACK_WEBHOOK_URL: ${{secrets.SECRET_SLACK_WEBHOOK_URL}}
44+
SECRET_TELEGRAM_API_TOKEN: ${{secrets.SECRET_TELEGRAM_API_TOKEN}}
45+
SECRET_TELEGRAM_CHAT_ID: ${{secrets.SECRET_TELEGRAM_CHAT_ID}}

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,4 @@ worker/
133133
.direnv/
134134
out/
135135
package-lock.json
136+
public/style.css

.prettierignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Ignore generated files
2+
out
3+
public

CODE_OF_CONDUCT.md

+13-13
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,22 @@ appearance, race, religion, or sexual identity and orientation.
1414
Examples of behavior that contributes to creating a positive environment
1515
include:
1616

17-
* Using welcoming and inclusive language
18-
* Being respectful of differing viewpoints and experiences
19-
* Gracefully accepting constructive criticism
20-
* Focusing on what is best for the community
21-
* Showing empathy towards other community members
17+
- Using welcoming and inclusive language
18+
- Being respectful of differing viewpoints and experiences
19+
- Gracefully accepting constructive criticism
20+
- Focusing on what is best for the community
21+
- Showing empathy towards other community members
2222

2323
Examples of unacceptable behavior by participants include:
2424

25-
* The use of sexualized language or imagery and unwelcome sexual attention or
26-
advances
27-
* Trolling, insulting/derogatory comments, and personal or political attacks
28-
* Public or private harassment
29-
* Publishing others' private information, such as a physical or electronic
30-
address, without explicit permission
31-
* Other conduct which could reasonably be considered inappropriate in a
32-
professional setting
25+
- The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
- Trolling, insulting/derogatory comments, and personal or political attacks
28+
- Public or private harassment
29+
- Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
- Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
3333

3434
## Our Responsibilities
3535

README.md

+33-17
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ Monitor your websites, showcase status including daily history, and get Slack no
1010

1111
You'll need a [Cloudflare Workers account](https://dash.cloudflare.com/sign-up/workers) with
1212

13-
* A workers domain set up
14-
* The Workers Bundled subscription \($5/mo\)
15-
* [It works with Workers Free!](https://blog.cloudflare.com/workers-kv-free-tier/) Check [more info](#workers-kv-free-tier) on how to run on Workers Free.
16-
* Some websites/APIs to watch 🙂
13+
- A workers domain set up
14+
- The Workers Bundled subscription \($5/mo\)
15+
- [It works with Workers Free!](https://blog.cloudflare.com/workers-kv-free-tier/) Check [more info](#workers-kv-free-tier) on how to run on Workers Free.
16+
- Some websites/APIs to watch 🙂
1717

1818
Also, prepare the following secrets
1919

20-
* Cloudflare API token with `Edit Cloudflare Workers` permissions
21-
* Slack incoming webhook \(optional\)
20+
- Cloudflare API token with `Edit Cloudflare Workers` permissions
21+
- Slack incoming webhook \(optional\)
2222

2323
## Getting started
2424

@@ -39,6 +39,7 @@ You can either deploy with **Cloudflare Deploy Button** using GitHub Actions or
3939
- Name: SECRET_SLACK_WEBHOOK_URL (optional)
4040
- Value: your-slack-webhook-url
4141
```
42+
4243
3. Navigate to the **Actions** settings in your repository and enable them
4344
4. Edit [config.yaml](./config.yaml) to adjust configuration and list all of your websites/APIs you want to monitor
4445
@@ -48,6 +49,7 @@ You can either deploy with **Cloudflare Deploy Button** using GitHub Actions or
4849
url: 'https://status-page.eidam.dev' # used for Slack messages
4950
logo: logo-192x192.png # image in ./public/ folder
5051
daysInHistogram: 90 # number of days you want to display in histogram
52+
collectResponseTimes: false # experimental feature, enable only for <5 monitors or on paid plans
5153

5254
# configurable texts across the status page
5355
allmonitorsOperational: 'All Systems Operational'
@@ -73,32 +75,46 @@ You can either deploy with **Cloudflare Deploy Button** using GitHub Actions or
7375
5. Push to `main` branch to trigger the deployment
7476
6. 🎉
7577
7. _\(optional\)_ Go to [Cloudflare Workers settings](https://dash.cloudflare.com/?to=/workers) and assign custom domain/route
76-
* e.g. `status-page.eidam.dev/*` _\(make sure you include `/*` as the Worker also serve static files\)_
78+
- e.g. `status-page.eidam.dev/*` _\(make sure you include `/*` as the Worker also serve static files\)_
7779
8. _\(optional\)_ Edit [wrangler.toml](./wrangler.toml) to adjust Worker settings or CRON Trigger schedule, especially if you are on [Workers Free plan](#workers-kv-free-tier)
7880

81+
### Telegram notifications
82+
83+
To enable telegram notifications, you'll need to take a few additional steps.
84+
85+
1. [Create a new Bot](https://core.telegram.org/bots#creating-a-new-bot)
86+
2. Set the api token you received when creating the bot as content of the `SECRET_TELEGRAM_API_TOKEN` secret in your github repository.
87+
3. Send a message to the bot from the telegram account which should receive the alerts (Something more than `/start`)
88+
4. Get the chat id with `curl https://api.telegram.org/bot<YOUR TELEGRAM API TOKEN>/getUpdates | jq '.result[0] .message .chat .id'`
89+
5. Set the retrieved chat id in the `SECRET_TELEGRAM_CHAT_ID` secret variable
90+
6. Redeploy the status page using the github action
91+
7992
### Deploy on your own
8093

8194
You can clone the repository yourself and use Wrangler CLI to develop/deploy, extra list of things you need to take care of:
8295

83-
* create KV namespace and add the `KV_STATUS_PAGE` binding to [wrangler.toml](./wrangler.toml)
84-
* create Worker secrets _\(optional\)_
85-
* `SECRET_SLACK_WEBHOOK_URL`
96+
- create KV namespace and add the `KV_STATUS_PAGE` binding to [wrangler.toml](./wrangler.toml)
97+
- create Worker secrets _\(optional\)_
98+
- `SECRET_SLACK_WEBHOOK_URL`
8699

87100
## Workers KV free tier
88-
The Workers Free plan includes limited KV usage, but the quota is sufficient for 2-minute checks only
89-
* Change the CRON trigger to 2 minutes interval (`crons = ["*/2 * * * *"]`) in [wrangler.toml](./wrangler.toml)
101+
102+
The Workers Free plan includes limited KV usage, but the quota is sufficient for 2-minute checks only
103+
104+
- Change the CRON trigger to 2 minutes interval (`crons = ["*/2 * * * *"]`) in [wrangler.toml](./wrangler.toml)
90105

91106
## Known issues
92107

93-
* **Max 25 monitors to watch in case you are using Slack notifications**, due to the limit of subrequests Cloudflare Worker can make \(50\).
108+
- **Max 25 monitors to watch in case you are using Slack notifications**, due to the limit of subrequests Cloudflare Worker can make \(50\).
94109

95110
The plan is to support up to 49 by sending only one Slack notification per scheduled run.
96111

97-
* **KV replication lag** - You might get Slack notification instantly, however it may take couple of more seconds to see the change on your status page as [Cron Triggers are usually running on underutilized quiet hours machines](https://blog.cloudflare.com/introducing-cron-triggers-for-cloudflare-workers/#how-are-you-able-to-offer-this-feature-at-no-additional-cost).
112+
- **KV replication lag** - You might get Slack notification instantly, however it may take couple of more seconds to see the change on your status page as [Cron Triggers are usually running on underutilized quiet hours machines](https://blog.cloudflare.com/introducing-cron-triggers-for-cloudflare-workers/#how-are-you-able-to-offer-this-feature-at-no-additional-cost).
98113

99-
* **Initial delay (no data)** - It takes couple of minutes to schedule and run CRON Triggers for the first time
114+
- **Initial delay (no data)** - It takes couple of minutes to schedule and run CRON Triggers for the first time
100115

101116
## Future plans
117+
102118
Stay tuned for more features coming in, like leveraging the fact that CRON instances are scheduled around the world during the day
103-
so we can monitor the response times. However, we will most probably wait for the [Durable Objects](https://blog.cloudflare.com/introducing-workers-durable-objects/) to be in open beta
104-
as they are better fit to reliably store such info.
119+
so we can monitor the response times. However, we will most probably wait for the [Durable Objects](https://blog.cloudflare.com/introducing-workers-durable-objects/) to be in open beta
120+
as they are better fit to reliably store such info.

SUMMARY.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
# Table of contents
22

3-
* [Cloudflare Worker - Status Page](README.md)
4-
3+
- [Cloudflare Worker - Status Page](README.md)

config.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ settings:
33
url: 'https://status-page.eidam.dev' # used for Slack messages
44
logo: logo-192x192.png # image in ./public/ folder
55
daysInHistogram: 90 # number of days you want to display in histogram
6+
collectResponseTimes: false # experimental feature, enable only for <5 monitors or on paid plans
67

78
allmonitorsOperational: 'All Systems Operational'
89
notAllmonitorsOperational: 'Not All Systems Operational'
@@ -11,7 +12,7 @@ settings:
1112
monitorLabelNoData: 'No data'
1213
dayInHistogramNoData: 'No data'
1314
dayInHistogramOperational: 'All good'
14-
dayInHistogramNotOperational: 'Some checks failed'
15+
dayInHistogramNotOperational: ' incident(s)' # xx incident(s) recorded
1516

1617
monitors:
1718
- id: workers-cloudflare-com # unique identifier

index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { processCronTrigger } from './src/functions/cronTrigger'
1010
*/
1111
const DEBUG = false
1212

13-
addEventListener('fetch', event => {
13+
addEventListener('fetch', (event) => {
1414
try {
1515
event.respondWith(
1616
handleEvent(event, require.context('./pages/', true, /\.js$/), DEBUG),
@@ -27,6 +27,6 @@ addEventListener('fetch', event => {
2727
}
2828
})
2929

30-
addEventListener('scheduled', event => {
30+
addEventListener('scheduled', (event) => {
3131
event.waitUntil(processCronTrigger(event))
3232
})

package.json

+16-8
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,29 @@
77
"private": true,
88
"scripts": {
99
"dev": "flareact dev",
10-
"build": "flareact build",
11-
"deploy": "flareact publish",
10+
"build": "yarn css && flareact build",
11+
"deploy": "yarn build && flareact publish",
1212
"kv-gc": "node ./src/cli/gcMonitors.js",
13-
"format": "prettier --write '**/*.{js,css,json,md}'"
13+
"format": "prettier --write '**/*.{js,css,json,md}'",
14+
"css": "postcss public/tailwind.css -o public/style.css",
15+
"postinstall": "patch-package"
1416
},
1517
"dependencies": {
16-
"flareact": "^0.9.0",
18+
"flareact": "0.9.0",
1719
"laco": "^1.2.1",
1820
"laco-react": "^1.1.0",
19-
"react": "^16.13.1",
20-
"react-dom": "^16.13.1"
21+
"react": "^17.0.1",
22+
"react-dom": "^17.0.1"
2123
},
2224
"devDependencies": {
25+
"autoprefixer": "^10.0.2",
2326
"node-fetch": "^2.6.1",
24-
"prettier": "^1.18.2",
25-
"yaml-loader": "^0.6.0"
27+
"postcss": "^8.1.8",
28+
"postcss-cli": "^8.3.0",
29+
"prettier": "^2.2.0",
30+
"tailwindcss": "^2.0.1",
31+
"yaml-loader": "^0.6.0",
32+
"patch-package": "^6.2.2",
33+
"postinstall-postinstall": "^2.1.0"
2634
}
2735
}

pages/api/triggerCron.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { processCronTrigger } from '../../src/functions/cronTrigger'
22

3-
export default async event => {
3+
export default async (event) => {
44
// used only for local debugging
55
//return processCronTrigger(event)
66
}

0 commit comments

Comments
 (0)