curator
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:
/ingest
Websocket endpoint which acceptsEvent
in a json format./ingest
HTTP POST endpoint which acceptsEvent
in 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.cr
Configuration
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-key
header 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.cur
before forwarding. - Required
- Unique ID that identifies a running curator instance. Appended to
- ENV["CURATOR_PEPPER"]
- PEPPER string that is used to hash the
Event.ref
before 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
Event
that 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 asRingBuffer
where 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:
- 1880276617000
ref_rules.yml
example:
-
attribute: "ref"
operation: "exclude"
values:
- blank
- user@example.com
Allowed Operators for Rules:
Available operators are Event
attribute dependent.
- If
Event
attribute:uts
- available operators: [greater_than_equal, less_than_equal]
- For rest of attributes
- available operators: [include, exclude]
Allowed values for Rules:
- For
greater_than_equal
andless_than_equal
operators- values is an array with single
unix timestamp
value as aInt64
. - e.g [1580276617006]
- values is an array with single
- For
include
andexclude
- values is an array with as many
string
values as needed.- e.g ["test-123", "mod-555"]
- To match against empty values,
blank
string 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
Repository
curator
Owner
Statistic
- 1
- 0
- 0
- 0
- 0
- over 4 years ago
- April 15, 2020
License
MIT License
Links
Synced at
Sat, 21 Dec 2024 20:11:41 GMT
Languages