Code Monkey home page Code Monkey logo

semyi's Introduction

Semyi

An uptime monitoring platform to monitor your server and services. Best used as a Docker container, by running:

docker build -t semyi:latest .
docker run -d -p 5000:5000 -v ./config.json:/app/config.json semyi:latest
docker image prune

Or if you prefer it as a docker-compose:

uptime-monitor:
    build: .
    ports:
        - 5000:5000
    volumes:
        - ./config.json:/app/config.json
        - ./db.sqlite3:/app/db.sqlite3
    environment:
        DEFAULT_INTERVAL: 30
        DEFAULT_TIMEOUT: 10
        PORT: 5000

There is another convinient way, by us creating a Github Docker package that you can directly pull (via ghcr.io), but that will be coming soon.

License

Semyi
Copyright (C) 2022 Teknologi Umum <[email protected]>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <https://www.gnu.org/licenses/>.

See LICENSE

semyi's People

Contributors

afman42 avatar aldy505 avatar elianiva avatar takadev15 avatar yogipristiawan avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

semyi's Issues

add integration test

  • test for inserting & retrieving data from the sqlite3 database
  • test for creating the worker (can do without goroutines), by creating another http server instance that can be called
  • test for the webhook calls

Backend: Retry historical writes if fails

// TODO: Retry write if it fails
// Write the response to the historical writer
err := m.historicalWriter.Write(MonitorHistorical{
MonitorID: uniqueId,
Status: status,
Latency: response.RequestDuration,
Timestamp: response.Timestamp,
})
if err != nil {
log.Error().Err(err).Msg("failed to write historical data")
}

Historical writes should not be failing. But in any case of high database I/O throughput, this might be possible.

Backend: Add alerting integrations

For now these should do (treat these as "providers"):

  • Telegram (priority)
  • Webhook

What should be done:

  • Add a new section on configuration called "alerting", add generic schema for setting multiple alert integrations
  • Create alerting implementation for each providers
  • Implement the alerting on the monitor processor

Backend: Create worker to process hourly and daily monitor historical aggregates

semyi/backend/main.go

Lines 127 to 128 in 6a6a53b

// TODO: Create a new worker that process monitor_historical data and create monitor_historical_hourly_aggregate from it
// TODO: Create a new worker that process monitor_historical data and create monitor_historical_daily_aggregate from it

Should be a scheduler-like worker. Do a SELECT query to the raw monitor_historical table, then aggregate it by hourly or daily.

Backend: Implement `MonitorHistoricalReader` methods

func (r *MonitorHistoricalReader) ReadRawHistorical(ctx context.Context, monitorId string) ([]MonitorHistorical, error) {
panic("TODO: implement me!")
}
func (r *MonitorHistoricalReader) ReadHourlyHistorical(ctx context.Context, monitorId string) ([]MonitorHistorical, error) {
panic("TODO: implement me!")
}
func (r *MonitorHistoricalReader) ReadDailyHistorical(ctx context.Context, monitorId string) ([]MonitorHistorical, error) {
panic("TODO: implement me!")
}
func (r *MonitorHistoricalReader) ReadRawLatest(ctx context.Context, monitorId string) (MonitorHistorical, error) {
// Get the latest entry from the raw historical table
panic("TODO: implement me!")
}

Implement those. The schema is here https://github.com/teknologi-umum/semyi/blob/refactor/backend-duckdb/backend/migrations/20240523085502_monitor_historical.sql

implement webhook functionality

It's pretty useless if we need to open the uptime monitoring page again and again each day. One good approach about monitoring is we (or the team) should get a notification whenever there's a service that's suddenly went out.

Unlike other monitoring services, I don't want the providers to be non-agnostic, meaning the app is fully loaded with multiple providers that making it harder to maintain, no. I think one good approach to make the provider agnostic is by creating a webhook.

That sense, based on the configuration defined in #7, we can trigger a HTTP POST request to the endpoint provided that contains the information about the current state of service. Keep in mind that in webhook, we don't need to think of spamming the provided endpoint. All we do is just sending an event with information. Meaning the webhook will be sent immediately after meeting a certain condition based on the configuration.

Backend: Add database schema for storing incidents (or notice) data

On Railway status page (https://status.railway.app/) they call it "notice" instead of "incident", since not everything is an incident anyway. Maybe we should convert our wording into that.

But.. we still need a database schema for storing those notices. It should include this data (as minimum):

  • Title -> the title of the notice
  • Timestamp -> Event timestamp
  • Status -> must be one of "investigating" | "identified" | "monitoring" | "resolved" | "scheduled". If the timestamp is in the future, the status must only be "scheduled"
  • Level (or severity) -> Informational, Warning, Error, Fatal

Some examples on how we would display this on the frontend:

image

image

Incident detail:
image
image

add webhook configuration

for this one, the config.json file should be changed into this schema:

{
  "endpoints": [
    {
        "name": "Digital Ocean",
        "url": "https://status.digitalocean.com/",
        "description": "The place where the whale stands",
        "timeout": 60,
        "interval": 10
    }
  ],
  "webhook": {
    "url": "http://your-endpoint/",
    "success_responses": true,
    "failed_responses": true
  }
}

on the webhook object, the URL key provides the URL endpoint that this API hit. so it acts like a webhook.

success_responses and failed_responses are both boolean, this will define whether we should send a request if the current health check if successful or not. this is good for debugging if the team has a Slack server and needs downtime notification.

the task is pretty simple, you should (basically rewrite a bit) read the config.json file and parse the new schema so that it can be understood by the Go backend. the endpoints should be passed to the workers, the webhook's functionalities is discussed on a different issue.

add hover detail for each bar

when the cursor is hovered over the green/red bar, it should show the detail about the snapshot (time, status, etc)

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.