ats1999 / WatchMan

An query and alerting engine...!
MIT License
0 stars 0 forks source link

API #3

Open ats1999 opened 5 months ago

ats1999 commented 5 months ago

The user will send two things

  1. event name - the name of the event which is to be monitored
  2. event payload - data for the event at any particular time

Consider the following events and sample data

Page View Event

// page_view
{
   "url":"https://dsabyte.com/blog/dsabyte/news/dsabyte-Open-Graph-Image-Generator-26384f92-83da-4da6-92fd-a8e5ccd73dc1",
   "domain":"dsabyte.com",
   "path":"/blog/dsabyte/news/dsabyte-Open-Graph-Image-Generator-26384f92-83da-4da6-92fd-a8e5ccd73dc1",
   "country":"IN",
   "device":"DESKTOP",
   "ip":"127.0.0.1",
   "browser":"Chrome",
   "os":"linux",
   "ts":"1706380834215",
   "pageOnTimeMs":1200
}

Queries

{
    "from":"today",
    "to":"3 days before",
    "dimensions": ["device","country"],
    "filters":{
        "country":"IN",
        "domain":"ogp.dsabyte.com" 
   },
  "metric":[count(*),avg(pageOnTimeMs)]
}

Sales Event

// sales
{
  "event": "purchase",
  "timestamp": "2024-02-04T15:30:00",
  "user_id": 12345,
  "product_id": 6789,
  "quantity": 2,
  "total_price": 50.00,
  "payment_method": "credit_card"
  "customer_age":29
}

Query

{
    "from":"today",
    "to":"3 days before",
    "dimensions": ["product_id","payment_method"],
    "metric":[sum(total_price),avg(quantity)]
}

APIs