Skip to content

Commit 1fb9e92

Browse files
committed
Add Example Usage to the README
1 parent 7cc4283 commit 1fb9e92

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,57 @@ This is a plugin for [Logstash](https://github.com/elastic/logstash).
1010

1111
It is fully free and fully open source. The license is Apache 2.0, meaning you are pretty much free to use it however you want in whatever way.
1212

13+
## Example Usage
14+
15+
``` ruby
16+
output {
17+
if [@metadata][event_type] == "product.event.created" {
18+
mongodb {
19+
id => "orders.projection.mongodb.product-insert"
20+
uri => "${MONGO_DNS}"
21+
collection => "product-aggregates"
22+
database => "carts"
23+
isodate => true
24+
action => "update"
25+
upsert => true
26+
}
27+
}
28+
29+
if [@metadata][event_type] == "product.event.updated" or [@metadata][event_type] == "product.event.deleted" {
30+
mongodb {
31+
id => "orders.projection.mongodb.product-update"
32+
uri => "${MONGO_DNS}"
33+
collection => "product-aggregates"
34+
database => "carts"
35+
isodate => true
36+
action => "update"
37+
filter => {
38+
"_id" => "[_id]"
39+
"store_id" => "[store_id]"
40+
}
41+
}
42+
}
43+
44+
if [@metadata][event_type] == "stock.updated" and [quantity] > 0 {
45+
mongodb {
46+
id => "orders.projection.mongodb.stock-update"
47+
uri => "${MONGO_DNS}"
48+
collection => "product-aggregates"
49+
database => "carts"
50+
isodate => true
51+
action => "update"
52+
filter => {
53+
"_id" => "[_id]"
54+
"store_id" => "[store_id]"
55+
}
56+
update_expressions => {
57+
"$inc" => {"stock" => "[stock_delta]"}
58+
}
59+
}
60+
}
61+
}
62+
```
63+
1364
## Documentation
1465

1566
Logstash provides infrastructure to automatically generate documentation for this plugin. We use the asciidoc format to write documentation so any comments in the source code will be first converted into asciidoc and then into html. All plugin documentation are placed under one [central location](http://www.elastic.co/guide/en/logstash/current/).

0 commit comments

Comments
 (0)