Curator
Server that accepts Event via WebSocket or HTTP POST request. Filters them based on defined rules. Forwards thems to other nodes.
Available endpoints:
Upon start, server exposes two endpoints:
- /ingestWebsocket endpoint which accepts- Eventin a json format.
- /ingestHTTP POST endpoint which accepts- Eventin bulk, where list of events are specified in ndjson format.
Starting server as crystal script
API_KEY=password CURATOR_ID=cur-45678 CURATOR_PEPPER=secret FORWARDS="ws://127.0.0.1:4444|secret_api_key" crystal run src/curator.crConfiguration
Available Environment variables:
- ENV["PORT"]
- Port on which the WebSocket and HTTP POST endpoints are available
- Optional - Default value: 3000
 
- ENV["API_KEY"]
- API Key that needs to be passed as x-api-keyheader to communicate with the Curator endpoints.
- Required
 
- API Key that needs to be passed as 
- ENV["CURATOR_ID"]
- Unique ID that identifies a running curator instance. Appended to Event.curbefore forwarding.
- Required
 
- Unique ID that identifies a running curator instance. Appended to 
- ENV["CURATOR_PEPPER"]
- PEPPER string that is used to hash the Event.refbefore forwarding.
- Required
 
- PEPPER string that is used to hash the 
- ENV["FORWARDS"]
- List of forward nodes that will receive the event via WebSocket after they have been filtered by the curator.
- Format: "URL_1|KEY_1 URL_2|KEY_2"
- e.g. "ws://127.0.0.1:2000|SECRET1 ws://127.0.0.1:3000|SECRET2"
- Required
 
- ENV["BUFFER_SIZE"]
- Number of Eventthat are buffered per forward. If a forward defined in the configuration isnt available, incoming event is stored until curator can reconnect. Upon connection, buffered events are offloaded to the forward. Buffer is implemented asRingBufferwhere recent events, push the old events out when buffer capacity is reached.
- Optional - Default value: 100,000
 
- Number of 
Event filtering rules:
Curator accepts rules in a yml format. Rules are defined in config/rules.yml for all Event attributes except Event.ref.
Event.ref rules are defined in config/ref_rules.yml
rules.yml example:
-
  attribute: "org"
  operation: "exclude"
  values:
    - fb
-
  attribute: "org"
  operation: "include"
  values:
    - microsoft
    - google
-
  attribute: "uts"
  operation: "greater_than_equal"
  values:
    - 1580276617006
-
  attribute: "uts"
  operation: "less_than_equal"
  values:
    - 1880276617000ref_rules.yml example:
-
  attribute: "ref"
  operation: "exclude"
  values:
    - blank
    - [email protected]Allowed Operators for Rules:
Available operators are Event attribute dependent.
- If Eventattribute:uts- available operators: [greater_than_equal, less_than_equal]
 
- For rest of attributes
- available operators: [include, exclude]
 
Allowed values for Rules:
- For greater_than_equalandless_than_equaloperators- values is an array with single unix timestampvalue as aInt64.
- e.g [1580276617006]
 
- values is an array with single 
- For includeandexclude- values is an array with as many stringvalues as needed.- e.g ["test-123", "mod-555"]
 
- To match against empty values, blankstring value can be provided.- e.g ["test-123", "blank", "mod-555"]
 
 
- values is an array with as many 
Development
To run specs crystal spec
Contributing
- Fork it (https://github.com/place-labs/curator/fork)
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request