Liking cljdoc? Tell your friends :D
Clojure only.

mirabelle.action


above-dtclj

(above-dt config & children)

Takes a number threshold and a time period in seconds duration. If the condition "the event metric is > to the threshold" is valid for all events received during at least the period duration, valid events received after the duration period will be passed on until an invalid event arrives. :metric should not be nil (it will produce exceptions).

(above-dt {:threshold 100 :duration 10}
  (debug))

In this example, if the events :metric field are greater than 100 for more than 10 seconds, events are passed downstream.

Takes a number `threshold` and a time period in seconds `duration`.
If the condition "the event metric is > to the threshold" is valid for all events
received during at least the period `duration`, valid events received after the `duration`
period will be passed on until an invalid event arrives.
`:metric` should not be nil (it will produce exceptions).

```clojure
(above-dt {:threshold 100 :duration 10}
  (debug))
```

In this example, if the events `:metric` field are greater than 100 for more than 10 seconds, events are passed downstream.
sourceraw docstring

action->fnclj

source

aggregation*clj

(aggregation* _ {:keys [duration] :as config} & children)
source

async-queue!clj

(async-queue! queue-name & children)

Execute children into the specific async queue. The async queue should be defined in the I/O configuration file.

(async-queue! :my-queue
  (info))
Execute children into the specific async queue.
The async queue should be defined in the I/O configuration file.

```clojure
(async-queue! :my-queue
  (info))
```
sourceraw docstring

async-queue!*clj

(async-queue!* context queue-name & children)
source

below-dtclj

(below-dt config & children)

Takes a number threshold and a time period in seconds duration. If the condition the event metric is < to the threshold is valid for all events received during at least the period duration, valid events received after the duration period will be passed on until an invalid event arrives. :metric should not be nil (it will produce exceptions).

(below-dt {:threshold 100 :duration 10}
(debug))

In this example, if the events :metric field are lower than 100 for more than 10 seconds, events are passed downstream.

Takes a number `threshold` and a time period in seconds `duration`.
If the condition `the event metric is < to the threshold` is valid for all
events received during at least the period `duration`, valid events received after
the `duration` period will be passed on until an invalid event arrives.
`:metric` should not be nil (it will produce exceptions).

  ```clojure
(below-dt {:threshold 100 :duration 10}
  (debug))
```

In this example, if the events `:metric` field are lower than 100 for more than 10 seconds, events are passed downstream.
sourceraw docstring

between-dtclj

(between-dt config & children)

Takes two numbers, low and high, and a time period in seconds, duration. If the condition the event metric is > low and < high is valid for all events received during at least the period duration, valid events received after the duration period will be passed on until an invalid event arrives. :metric should not be nil (it will produce exceptions).

(between-dt {:low 50 :high 100 :duration 10}
  (debug))

In this example, if the events :metric field are between 50 ans 100 for more than 10 seconds, events are passed downstream.

Takes two numbers, `low` and `high`, and a time period in seconds, `duration`.
If the condition `the event metric is > low and < high` is valid for all events
received during at least the period `duration`, valid events received after the `duration`
period will be passed on until an invalid event arrives.
`:metric` should not be nil (it will produce exceptions).

```clojure
(between-dt {:low 50 :high 100 :duration 10}
  (debug))
```

In this example, if the events `:metric` field are between 50 ans 100 for more than 10 seconds, events are passed downstream.
sourceraw docstring

bottomclj

(bottom config & children)

Get the min event from the last dt seconds.

(bottom {:duration 10}
  (info))

You can pass a :delay key to the configuration in order to tolerate late events. In that case, events from previous windows will be flushed after this delay:

(bottom {:duration 10 :delay 5}
  (info))
Get the min event from the last dt seconds.

```clojure
(bottom {:duration 10}
  (info))
```

You can pass a `:delay` key to the configuration in order to tolerate late
events. In that case, events from previous windows will be flushed after this
delay:

```clojure
(bottom {:duration 10 :delay 5}
  (info))
```
sourceraw docstring

byclj

(by config & children)

Split stream by field Every time an event arrives with a new value of field, this action invokes its child forms to return a new, distinct set of streams for that particular value.

(by {:fields [:host :service]}
  (fixed-time-window {:duration 60}))

This example generates a moving window for each host/service combination.

You can also pass the :gc-interval and :fork-ttl keys to the action. This will enable garbage collections of children actions, executed every :gc-interval (in seconds) and which will remove actions which didn't receive events since :fork-ttl seconds

(by {:fields [:host :service [:a :nested-key]
     :gc-interval 3600
     :fork-ttl 1800}
  (fixed-time-window {:duration 60}))
Split stream by field
Every time an event arrives with a new value of field, this action invokes
its child forms to return a *new*, distinct set of streams for that
particular value.

```clojure
(by {:fields [:host :service]}
  (fixed-time-window {:duration 60}))
```

This example generates a moving window for each host/service combination.

You can also pass the `:gc-interval` and `:fork-ttl` keys to the action.
This will enable garbage collections of children actions, executed every
`:gc-interval` (in seconds) and which will remove actions which didn't
receive events since `:fork-ttl` seconds

```clojure
(by {:fields [:host :service [:a :nested-key]
     :gc-interval 3600
     :fork-ttl 1800}
  (fixed-time-window {:duration 60}))
```
sourceraw docstring

by-fnclj

(by-fn {:keys [fields gc-interval fork-ttl]} new-fork)
source

by-get-field-fnclj

(by-get-field-fn field)
source

call-rescueclj

(call-rescue event children)
source

changedclj

(changed config & children)

Passes on events only if the field passed as parameter differs from the previous one. The init parameter is the default value for the stream.

(changed {:field :state :init "ok"})

For example, this action will let event pass if the :state field vary, the initial value being ok.

This stream is useful to get only events making a transition.

It also supported nested fields:

(changed {:field [:nested :field] :init "ok"})
Passes on events only if the `field` passed as parameter differs
from the previous one.
The `init` parameter is the default value for the stream.

```clojure
(changed {:field :state :init "ok"})
```

For example, this action will let event pass if the :state field vary,
the initial value being `ok`.

This stream is useful to get only events making a transition.

It also supported nested fields:

```clojure
(changed {:field [:nested :field] :init "ok"})
```
sourceraw docstring

changed*clj

(changed* _ {:keys [field init]} & children)
source

clear-forksclj

(clear-forks state current-time fork-ttl)
source

coalesceclj

(coalesce config & children)

Returns a list of the latest non-expired events (by fields) every dt seconds (at best).

(coalesce {:duration 10 :fields [:host :service]}
  (debug)

In this example, the latest event for each host/service combination will be kept and forwarded downstream. The debug action will then receive this list of events. Expired events will be removed from the list.

coalesce supports nested fields:

(coalesce {:duration 10 :fields [:host [:nested :field]]}
  (debug)
Returns a list of the latest non-expired events (by `fields`) every dt seconds
(at best).

```clojure
(coalesce {:duration 10 :fields [:host :service]}
  (debug)
```

In this example, the latest event for each host/service combination will be
kept and forwarded downstream. The `debug` action will then receive this list
of events.
Expired events will be removed from the list.

coalesce supports nested fields:

```clojure
(coalesce {:duration 10 :fields [:host [:nested :field]]}
  (debug)
```
sourceraw docstring

coalesce*clj

(coalesce* _ {:keys [duration fields]} & children)
source

coll-bottomclj

(coll-bottom nb-events & children)

Receives a list of events, returns the bottom N events with the lowest metrics.

(fixed-time-window {:duration 60}
  (coll-bottom 5
    (info)))
Receives a list of events, returns the bottom N events with the lowest metrics.

```clojure
(fixed-time-window {:duration 60}
  (coll-bottom 5
    (info)))
```
sourceraw docstring

coll-bottom*clj

(coll-bottom* _ nb-events & children)
source

coll-countclj

(coll-count & children)

Count the number of events. Should receive a list of events from the previous stream. The most recent event is used as a base to create the new event, and its :metric field is set to the number of events received as input.

(fixed-time-window {:duration 60}
  (coll-count
    (debug)))
Count the number of events.
Should receive a list of events from the previous stream.
The most recent event is used as a base to create the new event, and
its :metric field is set to the number of events received as input.

```clojure
(fixed-time-window {:duration 60}
  (coll-count
    (debug)))
```
sourceraw docstring

coll-count*clj

(coll-count* _ & children)
source

coll-increaseclj

(coll-increase & children)

Receives a list of events which should represent an always-increasing counter and returns the latest event with its :metric field set to the value of the increase between the oldest and the latest event.

If it receives for example:

[{:time 1 :metric 10} {:time 9 :metric 20} {:time 20 :metric 30}}

It will produces (30-10 = 20):

{:time 20 :metric 20}

Events produced with a negative metric (which can happen if the counter is resetted) are not send downstream.

Receives a list of events which should represent an always-increasing counter
and returns the latest event with its :metric field set to the value of the
increase between the oldest and the latest event.

If it receives for example:

```clojure
[{:time 1 :metric 10} {:time 9 :metric 20} {:time 20 :metric 30}}
```

It will produces (30-10 = 20):

```clojure
{:time 20 :metric 20}
```

Events produced with a negative metric (which can happen if the counter is resetted) are not send downstream.
sourceraw docstring

coll-increase*clj

(coll-increase* _ & children)
source

coll-maxclj

(coll-max & children)

Returns the event with the biggest metric. Should receive a list of events from the previous stream.

(fixed-event-window {:size 10}
  (coll-max
    (debug)))

Get the event the biggest metric on windows of 10 events.

Check top and smax as well.

Returns the event with the biggest metric.
Should receive a list of events from the previous stream.

```clojure
(fixed-event-window {:size 10}
  (coll-max
    (debug)))
```

Get the event the biggest metric on windows of 10 events.

Check `top` and `smax` as well.
sourceraw docstring

coll-max*clj

(coll-max* _ & children)
source

coll-meanclj

(coll-mean & children)

Computes the events mean (on metric). Should receive a list of events from the previous stream. The most recent event is used as a base to create the new event

(fixed-event-window {:size 10}
  (coll-mean
    (debug)))

Computes the mean on windows of 10 events

Computes the events mean (on metric).
Should receive a list of events from the previous stream.
The most recent event is used as a base to create the new event

```clojure
(fixed-event-window {:size 10}
  (coll-mean
    (debug)))
```

Computes the mean on windows of 10 events
sourceraw docstring

coll-mean*clj

(coll-mean* _ & children)
source

coll-minclj

(coll-min & children)

Returns the event with the smallest metric. Should receive a list of events from the previous stream.

(fixed-event-window {:size 10}
  (coll-min
    (debug)))

Get the event the smallest metric on windows of 10 events.

Check bottom and smin as well.

Returns the event with the smallest metric.
Should receive a list of events from the previous stream.

```clojure
(fixed-event-window {:size 10}
  (coll-min
    (debug)))
```

Get the event the smallest metric on windows of 10 events.

Check `bottom` and `smin` as well.
sourceraw docstring

coll-min*clj

(coll-min* _ & children)
source

coll-percentilesclj

(coll-percentiles points & children)

Receives a list of events and selects one event from that period for each point. If point is 0, takes the lowest metric event. If point is 1, takes the highest metric event. 0.5 is the median event, and so forth. Forwards each of these events to children. The event has the point appended the :quantile key. Useful for extracting histograms and percentiles.

(fixed-event-window {:size 10}
  (coll-percentiles [0.5 0.75 0.98 0.99]))
Receives a list of events and selects one
event from that period for each point. If point is 0, takes the lowest metric
event.  If point is 1, takes the highest metric event. 0.5 is the median
event, and so forth. Forwards each of these events to children. The event
has the point appended the `:quantile` key.
Useful for extracting histograms and percentiles.

```clojure
(fixed-event-window {:size 10}
  (coll-percentiles [0.5 0.75 0.98 0.99]))
```
sourceraw docstring

coll-percentiles*clj

(coll-percentiles* _ points & children)
source

coll-quotientclj

(coll-quotient & children)

Divide the first event :metrìc field by all subsequent events :metric. Return a new event containing the new :metric.

Should receive a list of events from the previous stream.

Divide the first event `:metrìc` field by all subsequent events `:metric`.
Return a new event containing the new `:metric`.

Should receive a list of events from the previous stream.
sourceraw docstring

coll-quotient*clj

(coll-quotient* _ & children)
source

coll-rateclj

(coll-rate & children)

Computes the rate on a list of events. Should receive a list of events from the previous stream. The latest event is used as a base to build the new event.

(fixed-event-window {:size 3}
  (coll-rate
    (debug)))

If this example receives the events:

{:metric 1 :time 1} {:metric 2 :time 2} {:metric 1 :time 3}

The stream will return {:metric 2 :time 3}

Indeed, (1+2+1)/2 = 3 (we divide by 2 because we have 2 seconds between the min and max events time).

Computes the rate on a list of events.
Should receive a list of events from the previous stream.
The latest event is used as a base to build the new event.

```clojure
(fixed-event-window {:size 3}
  (coll-rate
    (debug)))
```

If this example receives the events:

{:metric 1 :time 1} {:metric 2 :time 2} {:metric 1 :time 3}

The stream will return {:metric 2 :time 3}

Indeed, (1+2+1)/2 = 3 (we divide by 2 because we have 2 seconds between the
min and max events time).
sourceraw docstring

coll-rate*clj

(coll-rate* _ & children)
source

coll-sortclj

(coll-sort field & children)

Sort events based on the field passed as parameter Should receive a list of events from the previous stream.

(fixed-event-window {:size 10}
  (coll-sort :time
    (debug)))
Sort events based on the field passed as parameter
Should receive a list of events from the previous stream.

```clojure
(fixed-event-window {:size 10}
  (coll-sort :time
    (debug)))
```
sourceraw docstring

coll-sort*clj

(coll-sort* _ field & children)
source

coll-sumclj

(coll-sum & children)

Sum all the events :metric fields Should receive a list of events from the previous stream.

(fixed-event-window {:size 10}
  (coll-sum
    (debug)))

Sum all :metric fields for windows of 10 events

Sum all the events :metric fields
Should receive a list of events from the previous stream.

```clojure
(fixed-event-window {:size 10}
  (coll-sum
    (debug)))
```

Sum all :metric fields for windows of 10 events
sourceraw docstring

coll-sum*clj

(coll-sum* _ & children)
source

coll-topclj

(coll-top nb-events & children)

Receives a list of events, returns the top N events with the highest metrics.

(fixed-time-window {:duration 60}
  (coll-top 5
    (info)))
Receives a list of events, returns the top N events with the highest metrics.

```clojure
(fixed-time-window {:duration 60}
  (coll-top 5
    (info)))
```
sourceraw docstring

coll-top*clj

(coll-top* _ nb-events & children)
source

coll-whereclj

(coll-where conditions & children)

Like where but should receive a list of events.

(fixed-time-window {:duration 60}
  (coll-where [:and [:= :host "foo"]
                    [:> :metric 10]))
Like `where` but should receive a list of events.

```clojure
(fixed-time-window {:duration 60}
  (coll-where [:and [:= :host "foo"]
                    [:> :metric 10]))
```
sourceraw docstring

coll-where*clj

(coll-where* _ conditions & children)
source

cond-dt*clj

(cond-dt* _ conditions dt & children)

A stream which detects if a condition (f event) is true during dt seconds. Takes conditions (like in the where action) and a time period dt in seconds. If the condition is valid for all events received during at least the period dt, valid events received after the dt period will be passed on until an invalid event arrives. Skips events that are too old or that do not have a timestamp.

A stream which detects if a condition `(f event)` is true during `dt` seconds.
Takes `conditions` (like in the where action) and a time period `dt` in seconds.
If the condition is valid for all events received during at least the period `dt`, valid events received after the `dt` period will be passed on until an invalid event arrives.
Skips events that are too old or that do not have a timestamp.
sourceraw docstring

criticalclj

(critical & children)

Keep all events in state critical.

(critical
  (error))

In this example, all events with :state "critical" will be logged.

Keep all events in state critical.

```clojure
(critical
  (error))
```

In this example, all events with `:state` "critical" will be logged.
sourceraw docstring

critical*clj

(critical* _ & children)
source

critical-dtclj

(critical-dt config & children)

Takes a time period in seconds duration. If all events received during at least the period duration have :state critical, new critical events received after the duration period will be passed on until an invalid event arrives.

(critical-dt {:duration 10}
  (debug))

In this example, if the events :state are "critical" for more than 10 seconds, events are passed downstream.

Takes a time period in seconds `duration`.
If all events received during at least the period `duration` have `:state` critical,
new critical events received after the `duration` period will be passed on until
an invalid event arrives.

```clojure
(critical-dt {:duration 10}
  (debug))
```

In this example, if the events `:state` are "critical" for more than 10 seconds, events are passed downstream.
sourceraw docstring

customclj

(custom action-name params & children)

Executes a custom action. Custom actions are defined in the Mirabelle configuration file. The actomn can then be called (by name) using this custom action.

(custom :my-custom-action ["parameters"]
  (info))
Executes a custom action.
Custom actions are defined in the Mirabelle configuration file.
The actomn can then be called (by name) using this `custom` action.

```clojure
(custom :my-custom-action ["parameters"]
  (info))
```
sourceraw docstring

ddtclj

(ddt & children)

Differentiate metrics with respect to time. Emits an event for each event received, but with metric equal to the difference between the current event and the previous one, divided by the difference in their times. Skips events without metrics.

(ddt
  (info))

If ddt receives {:metric 1 :time 1} and {:metric 10 :time 4}, it will produce {:metric (/ 9 3) :time 4}.

Differentiate metrics with respect to time.
Emits an event for each event received, but with metric equal to
the difference between the current event and the previous one, divided by the
difference in their times. Skips events without metrics.

```clojure
(ddt
  (info))
```

If ddt receives {:metric 1 :time 1} and {:metric 10 :time 4}, it will produce
{:metric (/ 9 3) :time 4}.
sourceraw docstring

ddt*clj

(ddt* _ remove-neg? & children)
source

ddt-posclj

(ddt-pos & children)

Like ddt but do not forward events with negative metrics. This can be used for counters which may be reseted to zero for example.

Like ddt but do not forward events with negative metrics.
This can be used for counters which may be reseted to zero for example.
sourceraw docstring

debugclj

(debug)

Print the event in the logs using the debug level

(increment
  (debug))
Print the event in the logs using the debug level

```clojure
(increment
  (debug))
```
sourceraw docstring

debug*clj

(debug* ctx)
source

decrementclj

(decrement & children)

Decrement the event :metric field.

(decrement
  (index [:host]))
Decrement the event :metric field.

```
(decrement
  (index [:host]))
```
sourceraw docstring

decrement*clj

(decrement* _ & children)
source

defaultclj

(default field value & children)

Set a default value for an event

(default :state "ok"
  (info))

In this example, all events where :state is not set will be updated with :state to "ok".

It also supports nested keys:

(default [:nested :key] "ok"
  (info))
Set a default value for an event

```clojure
(default :state "ok"
  (info))
```

In this example, all events where `:state` is not set will be updated with
`:state` to "ok".

It also supports nested keys:

```clojure
(default [:nested :key] "ok"
  (info))
```
sourceraw docstring

default*clj

(default* _ field value & children)
source

default-aggr-finalizerclj

(default-aggr-finalizer _ event)
source

discard-fnclj

(discard-fn e)
source

dissoc-inclj

(dissoc-in m [k & ks :as keys])

Dissociates an entry from a nested associative structure returning a new nested structure. keys is a sequence of keys. Any empty maps that result will not be present in the new structure.

Dissociates an entry from a nested associative structure returning a new
nested structure. keys is a sequence of keys. Any empty maps that result
will not be present in the new structure.
sourceraw docstring

errorclj

(error)

Print the event in the logs using the error level

(increment
  (debug))
Print the event in the logs using the error level

```clojure
(increment
  (debug))
```
sourceraw docstring

error*clj

(error* ctx)
source

ewma-timelessclj

(ewma-timeless r & children)

Exponential weighted moving average. Constant space and time overhead. Passes on each event received, but with metric adjusted to the moving average. Does not take the time between events into account. R is the ratio between successive events: r=1 means always return the most recent metric; r=1/2 means the current event counts for half, the previous event for 1/4, the previous event for 1/8, and so on.

Exponential weighted moving average. Constant space and time overhead.
Passes on each event received, but with metric adjusted to the moving
average. Does not take the time between events into account. R is the ratio
between successive events: r=1 means always return the most recent metric;
r=1/2 means the current event counts for half, the previous event for 1/4,
the previous event for 1/8, and so on.
sourceraw docstring

ewma-timeless*clj

(ewma-timeless* _ r & children)
source

exception->eventclj

(exception->event e base-event)

Build a new event from an Exception and from the event which caused it.

Build a new event from an Exception and from the event which caused it.
sourceraw docstring

exception-streamclj

(exception-stream & children)

Takes two actions. If an exception is thrown in the first action, an event representing this exception is emitted in in the second action.

(exception-stream
  (bad-action)
  (error))

Here, if bad-action throws, an event will be built (using the exception->event function) and sent to the error action (which will log it).

Takes two actions. If an exception is thrown in the first action, an event
representing this exception is emitted in in the second action.

```
(exception-stream
  (bad-action)
  (error))
```

Here, if `bad-action` throws, an event will be built (using the `exception->event`
function) and sent to the `error` action (which will log it).
sourceraw docstring

exception-stream*clj

(exception-stream* _ success-child failure-child)
source

expiredclj

(expired & children)

Keep expired events.

(expired
  (increment))

In this example, all expired events will be forwarded to the incrementstream.

Keep expired events.

```clojure
(expired
  (increment))
```

In this example, all expired events will be forwarded to the `increment`stream.
sourceraw docstring

expired*clj

(expired* _ & children)

Keep expired events.

Keep expired events.
sourceraw docstring

extractclj

(extract k & children)

Takes a key as parameter and send downstream the content of this key.

(extract :base-event
  (info))

If extract receives in this example {:time 1 :base-event {:time 1 :service "foo" :host "bar"}, info will receive the content of :base-time.

It also supports nested keys:

(extract [:foo :bar]
  (info))
Takes a key as parameter and send downstream the content of this key.

```clojure
(extract :base-event
  (info))
```

If `extract` receives in this example `{:time 1 :base-event {:time 1 :service "foo" :host "bar"}`, `info` will receive the content of `:base-time`.

It also supports nested keys:


```clojure
(extract [:foo :bar]
  (info))
```
sourceraw docstring

extract*clj

(extract* _ k & children)
source

fixed-event-windowclj

(fixed-event-window config & children)

Returns a fixed-sized window of events.

(fixed-event-window {:size 5}
  (debug))

This example will return a vector events partitioned 5 by 5.

Returns a fixed-sized window of events.

```clojure
(fixed-event-window {:size 5}
  (debug))
```

This example will return a vector events partitioned 5 by 5.
sourceraw docstring

fixed-event-window*clj

(fixed-event-window* _ {:keys [size]} & children)
source

fixed-time-windowclj

(fixed-time-window config & children)

A fixed window over the event stream in time. Emits vectors of events, such that each vector has events from a distinct n-second interval. Windows do not overlap; each event appears at most once in the output stream.

(fixed-time-window {:duration 60}
  (coll-max
    (info)))

You can pass a :delay key to the configuration in order to tolerate late events. In that case, previous windows will be flushed after this delay:

(fixed-time-window {:duration 60 :delay 30}
  (coll-max
    (info)))
A fixed window over the event stream in time. Emits vectors of events, such
that each vector has events from a distinct n-second interval. Windows do
*not* overlap; each event appears at most once in the output stream.

```clojure
(fixed-time-window {:duration 60}
  (coll-max
    (info)))
```

You can pass a `:delay` key to the configuration in order to tolerate late
events. In that case, previous windows will be flushed after this
delay:

```clojure
(fixed-time-window {:duration 60 :delay 30}
  (coll-max
    (info)))
```
sourceraw docstring

from-base64clj

(from-base64 field & children)

Decode a base64 field.

(sdo
  ;; you can pass one field
  (from-base64 :host)
  ;; or a list to update a nested keys
  (from-base64 [:host :service]))
Decode a base64 field.

```clojure
(sdo
  ;; you can pass one field
  (from-base64 :host)
  ;; or a list to update a nested keys
  (from-base64 [:host :service]))
```
sourceraw docstring

from-base64*clj

(from-base64* _ fields & children)
source

from-jsonclj

(from-json k & children)

Takes a field or a list of fields, and converts the values associated to these fields from a json string to edn.

(with :my-field "{"foo": "bar"}
  (from-json :my-field))

In this example, we associate to :my-field a json string and then we call from-json on it. :my-field will now contain an edn map built from the json data, with keywords as keys.

This action also supports nested keys by passing an array of keys (for example (from-json [:nested :key]))

Takes a field or a list of fields, and converts the values associated to these
fields from a json string to edn.

```clojure
(with :my-field "{"foo": "bar"}
  (from-json :my-field))
```

In this example, we associate to `:my-field` a json string and then we call
`from-json` on it. `:my-field` will now contain an edn map built from the json
data, with keywords as keys.

This action also supports nested keys by passing an array of keys (for example `(from-json [:nested :key])`)
sourceraw docstring

from-json*clj

(from-json* _ k & children)
source

gen-docclj

(gen-doc)
source

get-env-profileclj

(get-env-profile)
source

get-fork-and-gcclj

(get-fork-and-gc state new-fork fork-name current-time fork-ttl gc-interval)
source

get-windowclj

(get-window event start-time duration)
source

includeclj

(include path config)

Include an configuration file by path into the configuration. The file will be read using the aero (https://github.com/juxt/aero/) library. The config variable supports these optional options:

  • :profile: the aero profile to use. By default, Mirabelle will read (and convert to a Clojure keyword) the PROFILE environment variable during compilation. You can override this value by setting :profile.
  • :variables: variables to pass to the configuration file. You can use the #mirabelle/var reader in order to define variables in your EDN file.

This allows you to use the same configuration snippet (eventually templated) from multiple streams (or multiple parts of the same stream)

(includes"/etc/mirabelle/includes/my-actions.clj {:profile :dev
                                                   :variables {:foo "bar"})
Include an configuration file by path into the configuration. The file will be read
using the aero (https://github.com/juxt/aero/) library.
The `config` variable supports these optional options:

- `:profile`: the aero profile to use. By default, Mirabelle will read (and convert
to a Clojure keyword) the PROFILE environment variable during compilation.
You can override this value by setting `:profile`.
- `:variables`: variables to pass to the configuration file.
You can use the `#mirabelle/var` reader in order to define variables in your
EDN file.

This allows you to use the same configuration snippet (eventually templated) from
multiple streams (or multiple parts of the same stream)

```clojure
(includes"/etc/mirabelle/includes/my-actions.clj {:profile :dev
                                                   :variables {:foo "bar"})
```
sourceraw docstring

incrementclj

(increment & children)

Increment the event :metric field.

(increment
  (index [:host]))
Increment the event :metric field.

```
(increment
  (index [:host]))
```
sourceraw docstring

increment*clj

(increment* _ & children)
source

indexclj

(index labels)

Insert events into the index. Events are indexed using the keys passed as parameter.

(index [:host :service])

This example will index events by host and services.

Insert events into the index.
Events are indexed using the keys passed as parameter.

```clojure
(index [:host :service])
```

This example will index events by host and services.
sourceraw docstring

index*clj

(index* context labels)
source

infoclj

(info)

Print the event in the logs using the info level

(increment
  (info))
Print the event in the logs using the info level

```clojure
(increment
  (info))
```
sourceraw docstring

info*clj

(info* ctx)
source

ioclj

(io & children)

Discard all events in test mode. Else, forward to children. You can use this stream to avoid side effects in test mode.

Discard all events in test mode. Else, forward to children.
You can use this stream to avoid side effects in test mode.
sourceraw docstring

io*clj

(io* context & children)
source

keep-keysclj

(keep-keys keys-to-keep & children)

Keep only the specified keys for events.

(keep-keys [:host :metric :time :environment :description]
  (info))

Also works with nested keys:

(keep-keys [:host :metric :time [:a :nested-key]]
  (info))
Keep only the specified keys for events.

```clojure
(keep-keys [:host :metric :time :environment :description]
  (info))
```

Also works with nested keys:

```clojure
(keep-keys [:host :metric :time [:a :nested-key]]
  (info))
```
sourceraw docstring

keep-keys*clj

(keep-keys* _ keys-to-keep & children)
source

keep-non-discarded-eventsclj

(keep-non-discarded-events events)

Takes an event or a list of events. Returns an event (or a list of events depending of the input) with all events tagged "mirabelle/discard" filtered. Returns nil if all events are filtered.

Takes an event or a list of events. Returns an event (or a list of events
depending of the input) with all events tagged "mirabelle/discard" filtered.
Returns nil if all events are filtered.
sourceraw docstring

keyword->aggr-finalizer-fnclj

source

keyword->aggr-fnclj

source

log-actionclj

(log-action source-stream level)

Generic logger

Generic logger
sourceraw docstring

meanclj

(mean config & children)

Get the mean of event metrics from the last dt seconds.

(mean {:duration 10}
  (info))

You can pass a :delay key to the configuration in order to tolerate late events. In that case, events from previous windows will be flushed after this delay:

(mean {:duration 10 :delay 5}
  (info))
Get the mean of event metrics from the last dt seconds.

```clojure
(mean {:duration 10}
  (info))
```

You can pass a `:delay` key to the configuration in order to tolerate late
events. In that case, events from previous windows will be flushed after this
delay:

```clojure
(mean {:duration 10 :delay 5}
  (info))
```
sourceraw docstring

moving-event-windowclj

(moving-event-window config & children)

A sliding window of the last few events. Every time an event arrives, calls children with a vector of the last n events, from oldest to newest. Ignores event times. Example:

(moving-event-window {:size 5}
  (coll-mean (info))
A sliding window of the last few events. Every time an event arrives, calls
children with a vector of the last n events, from oldest to newest. Ignores
event times. Example:

```clojure
(moving-event-window {:size 5}
  (coll-mean (info))
```
sourceraw docstring

moving-event-window*clj

(moving-event-window* _ config & children)
source

moving-time-windowclj

(moving-time-window config & children)

A sliding window of all events with times within the last n seconds. Uses the maximum event time as the present-time horizon. Every time a new event arrives within the window, emits a vector of events in the window to children.

Events without times accrue in the current window.

A sliding window of all events with times within the last n seconds. Uses
the maximum event time as the present-time horizon. Every time a new event
arrives within the window, emits a vector of events in the window to
children.

Events without times accrue in the current window.
sourceraw docstring

moving-time-window*clj

(moving-time-window* _ {:keys [duration]} & children)
source

not-expiredclj

(not-expired & children)

Keep non-expired events.

(not-expired
  (increment))

In this example, all non-expired events will be forwarded to the `increment`stream.
Keep non-expired events.

```clojure
(not-expired
  (increment))

In this example, all non-expired events will be forwarded to the `increment`stream.
```
sourceraw docstring

not-expired*clj

(not-expired* _ & children)

Keep non-expired events.

Keep non-expired events.
sourceraw docstring

output!clj

(output! output-name)

Push events to an external system.

Outputs are configured into the main Mirabelle configuration file. If you create a new output named :influxdb for example, you can use output! to push all events into this I/O:

(output! :influxdb)

Outputs are automatically discarded in test mode.

Push events to an external system.

Outputs are configured into the main Mirabelle configuration file.
If you create a new output named `:influxdb`
for example, you can use output! to push all events into this I/O:

```clojure
(output! :influxdb)
```

Outputs are automatically discarded in test mode.
sourceraw docstring

output!*clj

(output!* context output-name)
source

outside-dtclj

(outside-dt config & children)

Takes two numbers, low and high, and a time period in seconds, duration. If the condition the event metric is < low or > high is valid for all events received during at least the period duration, valid events received after the duration period will be passed on until an invalid event arrives. :metric should not be nil (it will produce exceptions).

(outside-dt {:low 50 :high 100 :duration 10}
  (debug))

In this example, if the events :metric field are outside the 50-100 range for more than 10 seconds, events are passed downstream.

Takes two numbers, `low` and `high`, and a time period in seconds, `duration`.
If the condition `the event metric is < low or > high` is valid for all events
received during at least the period `duration`, valid events received after the `duration`
period will be passed on until an invalid event arrives.
`:metric` should not be nil (it will produce exceptions).


```clojure
(outside-dt {:low 50 :high 100 :duration 10}
  (debug))
```

In this example, if the events `:metric` field are outside the 50-100 range for more than 10 seconds, events are passed downstream.
sourceraw docstring

overclj

(over n & children)

Passes on events only when their metric is greater than x.

(over 10
  (info))
Passes on events only when their metric is greater than x.

```clojure
(over 10
  (info))
```
sourceraw docstring

over*clj

(over* _ n & children)
source

percentilesclj

(percentiles config & children)
source

percentiles*clj

(percentiles* _
              {:keys [duration percentiles delay highest-trackable-value
                      nb-significant-digits lowest-discernible-value]}
              &
              children)
source

projectclj

(project conditions & children)

Takes a list of conditions. Like coalesce, project will return the most recent events matching the conditions.

(project [[:= :service "enqueues"]
          [:= :service "dequeues"]]
  (coll-quotient
    (with :service "enqueues per dequeue"
      (info))))

We divide here the latest event for the "enqueues" :service by the latest event from the "dequeues" one.

Takes a list of conditions.
Like coalesce, project will return the most recent events matching
the conditions.

```clojure
(project [[:= :service "enqueues"]
          [:= :service "dequeues"]]
  (coll-quotient
    (with :service "enqueues per dequeue"
      (info))))
```

We divide here the latest event for the "enqueues" :service by the
latest event from the "dequeues" one.
sourceraw docstring

project*clj

(project* _ conditions & children)
source

publish!clj

(publish! channel)

Publish events in the given channel.

(publish! :my-channel)

Users can then subscribe to channels using the websocket engine.

Publish events in the given channel.

```clojure
(publish! :my-channel)
```

Users can then subscribe to channels using the websocket engine.
sourceraw docstring

publish!*clj

(publish!* context channel)
source

rateclj

(rate config & children)
source

reaperclj

(reaper interval)
(reaper interval destination-stream)

Everytime this action receives an event, it will expires events from the index (every dt seconds) and reinject them into a stream (default to the current stream if not specified).

(reaper 5)
(reaper 5 :custom-stream)
Everytime this action receives an event, it will expires events from the
index (every dt seconds) and reinject them into a stream
(default to the current stream if not specified).

```clojure
(reaper 5)
```

```clojure
(reaper 5 :custom-stream)
```
sourceraw docstring

reaper*clj

(reaper* context interval destination-stream)
source

reinject!clj

(reinject!)
(reinject! destination-stream)

Reinject an event into the streaming system. By default, events are reinject into the real time engine. You can reinject events to a specific stream by passing the destination stream as parameter.

(reinject)

This example reinjects events into the real stream engine.

(reinject :foo)

This example reinjects events into the stream named :foo.

Reinject an event into the streaming system.
By default, events are reinject into the real time engine. You can reinject
events to a specific stream by passing the destination stream as parameter.

```clojure
(reinject)
```

This example reinjects events into the real stream engine.

```clojure
(reinject :foo)
```

This example reinjects events into the stream named `:foo`.
sourceraw docstring

reinject!*clj

(reinject!* context destination-stream)
source

rename-keysclj

(rename-keys replacement & children)

Rename events keys.

(rename-keys {:host :service
              :environment :env}

In this example, the :host key will be renamed :service and the :environment key is renamed :env. Existing values will be overrided.

Rename events keys.

```clojure
(rename-keys {:host :service
              :environment :env}
```

In this example, the `:host` key will be renamed `:service` and the
`:environment` key is renamed `:env`.
Existing values will be overrided.
sourceraw docstring

rename-keys*clj

(rename-keys* _ replacement & children)
source

scaleclj

(scale factor & children)

Multiplies the event :metric field by the factor passed as parameter.

(scale 1000
  (info

This example will multiply the :metric field for all events by 1000.

Multiplies the event :metric field by the factor passed as parameter.

```clojure
(scale 1000
  (info
```

This example will multiply the :metric field for all events by 1000.
sourceraw docstring

scale*clj

(scale* _ factor & children)
source

scondition*clj

(scondition* _ {:keys [condition]} & children)
source

sdissocclj

(sdissoc fields & children)

Remove a key (or a list of keys) from the events.

(sdissoc :host (info))

(sdissoc [:environment :host] (info))

(sdissoc [:environment [:nested :key] (info))
Remove a key (or a list of keys) from the events.

```clojure
(sdissoc :host (info))

(sdissoc [:environment :host] (info))

(sdissoc [:environment [:nested :key] (info))
```
sourceraw docstring

sdissoc*clj

(sdissoc* _ fields & children)
source

sdoclj

(sdo & children)

Send events to children. useful when you want to send the same events to multiple downstream actions.

(sdo
  (increment)
  (decrement))

Here, events arriving in sdo will be forwarded to both increment and decrement.

Send events to children. useful when you want to send the same
events to multiple downstream actions.

```clojure
(sdo
  (increment)
  (decrement))
```

Here, events arriving in sdo will be forwarded to both increment and
decrement.
sourceraw docstring

sdo*clj

(sdo* _ & children)
source

select-keys-nestedclj

(select-keys-nested event keyseq)
source

sflattenclj

(sflatten & children)

Streaming flatten. Calls children with each event in events. Events should be a sequence.

This stream can be used to "flat" a sequence of events (emitted by a time window stream for example).

(fixed-event-window {:size 5}
  (sflatten
    (info)))
Streaming flatten. Calls children with each event in events.
Events should be a sequence.

This stream can be used to "flat" a sequence of events (emitted
by a time window stream for example).

```clojure
(fixed-event-window {:size 5}
  (sflatten
    (info)))
```
sourceraw docstring

sflatten*clj

(sflatten* _ & children)
source

sformatclj

(sformat template target-field fields & children)

Takes the content of multiple event keys, and use them to build a string value and assign it to a given key.

(sformat "%s-foo-%s" :format-test [:host :service])

If the event {:host "machine" :service "bar"} is passed to this action the event will become {:host "machine" :service "bar" :format-test "machine-foo-bar"}.

It also supports nested keys both for the destination or the fields to extract:

(sformat "%s-foo-%s" [:nested :key] [[:host :name] :service])

More information about availables formatters in the Clojure documentation: https://clojuredocs.org/clojure.core/format

Takes the content of multiple event keys, and use them to build a string value
and assign it to a given key.

```clojure
(sformat "%s-foo-%s" :format-test [:host :service])
```

If the event `{:host "machine" :service "bar"}` is passed to this action
the event will become
`{:host "machine" :service "bar" :format-test "machine-foo-bar"}`.

It also supports nested keys both for the destination or the fields to extract:

```clojure
(sformat "%s-foo-%s" [:nested :key] [[:host :name] :service])
```

More information about availables formatters in the Clojure documentation:
https://clojuredocs.org/clojure.core/format
sourceraw docstring

sformat*clj

(sformat* _ template target-field fields & children)
source

smaxclj

(smax & children)

Send downstream the event with the biggest :metric every time it receives an event

(smax
  (info))

If the events {:time 1 :metric 10} {:time 2 :metric 3} {:time 3 :metric 11} are injected, info will receive:

{:time 1 :metric 10} {:time 1 :metric 10} {:time 3 :metric 11}
Send downstream the event with the biggest :metric every time it receives an event

```clojure
(smax
  (info))
```

If the events `{:time 1 :metric 10} {:time 2 :metric 3} {:time 3 :metric 11}`
are injected, `info` will receive:

```
{:time 1 :metric 10} {:time 1 :metric 10} {:time 3 :metric 11}
```
sourceraw docstring

sminclj

(smin & children)

Send downstream the event with the lowest :metric every time it receives an event

(smin
  (info))

If the events {:time 1 :metric 10} {:time 2 :metric 3} {:time 3 :metric 11} are injected, info will receive:

{:time 1 :metric 10} {:time 2 :metric 3} {:time 3 :metric 11}
Send downstream the event with the lowest :metric every time it receives an event

```clojure
(smin
  (info))
```

If the events `{:time 1 :metric 10} {:time 2 :metric 3} {:time 3 :metric 11}`
are injected, `info` will receive:

```clojure
{:time 1 :metric 10} {:time 2 :metric 3} {:time 3 :metric 11}
```
sourceraw docstring

splitclj

(split & clauses)

Split by conditions.

(split
  [:> :metric 10] (debug)
  [:> :metric 5] (info)
  (error)

In this example, all events with :metric > 10 will go into the debug stream, all events with :metric > 5 in the info stream, and other events will to the default stream which is "error".

The default stream is optional, if not set all events not matching a condition will be discarded.

Split by conditions.

```clojure
(split
  [:> :metric 10] (debug)
  [:> :metric 5] (info)
  (error)
```

In this example, all events with :metric > 10 will go into the debug stream,
all events with :metric > 5 in the info stream, and other events will to the
default stream which is "error".

The default stream is optional, if not set all events not matching a condition
will be discarded.
sourceraw docstring

split*clj

(split* _ clauses & children)
source

ssortclj

(ssort config & children)

Streaming sort. Takes a configuration containing a :duration and a :field key. The action will buffer events during :duration seconds and then send the events downstream one by one, sorted by :field.

(ssort {:duration 10 :field :time}
  (info))

This example will sort events based on the :time field.

For example, if it get as input:

{:time 1} {:time 10} {:time 4} {:time 9} {:time 13} {:time 31}

Info will receive these events:

{:time 1} {:time 4} {:time 9} {:time 10} {:time 13}

You can add a :delay key to the action configuration in order to tolerate late events:

(ssort {:duration 10 :field :time :delay 10}
  (info))

In this example, events from previous windows will be sent with a delay of 10 seconds.

ssort supports sorting on a nested field (example :field [:nested :field])

Streaming sort.
Takes a configuration containing a `:duration` and a `:field` key.
The action will buffer events during `:duration` seconds and then
send the events downstream one by one, sorted by `:field`.

```clojure
(ssort {:duration 10 :field :time}
  (info))
```

This example will sort events based on the :time field.

For example, if it get as input:

```clojure
{:time 1} {:time 10} {:time 4} {:time 9} {:time 13} {:time 31}
```

Info will receive these events:

```clojure
{:time 1} {:time 4} {:time 9} {:time 10} {:time 13}
```

You can add a `:delay` key to the action configuration in order to tolerate
late events:

```clojure
(ssort {:duration 10 :field :time :delay 10}
  (info))
```

In this example, events from previous windows will be sent with a delay of
10 seconds.

`ssort` supports sorting on a nested field (example `:field [:nested :field]`)
sourceraw docstring

stableclj

(stable dt field & children)

Takes a duration (dt) in second and a field name as parameter. Returns events where the value of the field specified as second argument is equal to the value of the field for the last event, for at least dt seconds. Events can be buffered for dt seconds before being forwarded in order to see if they are stable or not.

Events should arrive in order (old events will be dropped).

You can use this stream to remove flapping states for example.

(stable 10 :state
  (info))

In this example, events will be forwarded of the value of the :state key is the same for at least 10 seconds.

Support nested fields:

(stable 10 [:nested :field]
  (info))
```.
Takes a duration (dt) in second and a field name as parameter.
Returns events where the value of the field specified as second argument
is equal to the value of the field for the last event, for at least dt seconds.
Events can be buffered for dt seconds before being forwarded in order to see
if they are stable or not.

Events should arrive in order (old events will be dropped).

You can use this stream to remove flapping states for example.

```clojure
(stable 10 :state
  (info))
```

In this example, events will be forwarded of the value of the `:state` key
is the same for at least 10 seconds.

Support nested fields:

```clojure
(stable 10 [:nested :field]
  (info))
```.
sourceraw docstring

stable*clj

(stable* _ dt field & children)
source

streamclj

(stream config & children)

Creates a new stream. This action takes a map where the :name key, which will be the name of the stream, is mandatory.

Creates a new stream. This action takes a map where the `:name` key, which
will be the name of the stream, is mandatory.
sourceraw docstring

streamsclj

(streams & streams)

Entrypoint for all streams.

(streams
  (stream {:name :fobar}
    (info))
  (stream {:name :foo}
    (info)))
Entrypoint for all streams.

```clojure
(streams
  (stream {:name :fobar}
    (info))
  (stream {:name :foo}
    (info)))
```
sourceraw docstring

sumclj

(sum config & children)

Sum the events field from the last dt seconds.

(sum {:duration 10}
  (info))

You can pass a :delay key to the configuration in order to tolerate late events. In that case, events from previous windows will be flushed after this delay:

(sum {:duration 10 :delay 5}
  (info))
Sum the events field from the last dt seconds.

```clojure
(sum {:duration 10}
  (info))
```

You can pass a `:delay` key to the configuration in order to tolerate late
events. In that case, events from previous windows will be flushed after this
delay:

```clojure
(sum {:duration 10 :delay 5}
  (info))
```
sourceraw docstring

tagclj

(tag tags & children)

Adds a new tag, or set of tags, to events which flow through.

(tag "foo"
  (info))

This example adds the tag "foo" to events.

(tag ["foo" "bar"] (info))

This example adds the tag "foo" and "bar" to events.

Adds a new tag, or set of tags, to events which flow through.

```clojure
(tag "foo"
  (info))
```

This example adds the tag "foo" to events.

```clojure
(tag ["foo" "bar"] (info))
```

This example adds the tag "foo" and "bar" to events.
sourceraw docstring

tag*clj

(tag* _ tags & children)
source

tagged-allclj

(tagged-all tags & children)

Passes on events where all tags are present.

(tagged-all "foo"
  (info))

This example keeps only events tagged "foo".

(tagged-all ["foo" "bar"] (info))

This example keeps only events tagged "foo" and "bar".

Passes on events where all tags are present.

```clojure
(tagged-all "foo"
  (info))
```

This example keeps only events tagged "foo".

```clojure
(tagged-all ["foo" "bar"] (info))
```

This example keeps only events tagged "foo" and "bar".
sourceraw docstring

tagged-all*clj

(tagged-all* _ tags & children)
source

tapclj

(tap tap-name)

Save events into the tap. Noop outside tests.

(where [:= :service "foo"]
  (tap :foo)

In test mode, all events with :service "foo" will be saved in a tap named :foo

Save events into the tap. Noop outside tests.

```clojure
(where [:= :service "foo"]
  (tap :foo)
```

In test mode, all events with `:service` "foo" will be saved in a tap
named `:foo`
sourceraw docstring

tap*clj

(tap* context tape-name)
source

test-actionclj

(test-action state & children)

Bufferize all received events in the state (an atom) passed as parameter

Bufferize all received events in the state (an atom)
passed as parameter
sourceraw docstring

test-action*clj

(test-action* _ state)
source

throttleclj

(throttle config & children)

Let N event pass at most every duration seconds. Can be used for example to avoid sending to limit the number of alerts sent to an external system.

(throttle {:count 3 :duration 10}
  (error))

In this example, throttle will let 3 events pass at most every 10 seconds. Other events, or events with no time, are filtered.

Let N event pass at most every duration seconds.
Can be used for example to avoid sending to limit the number of alerts
sent to an external system.

```clojure
(throttle {:count 3 :duration 10}
  (error))
```

In this example, throttle will let 3 events pass at most every 10 seconds.
Other events, or events with no time, are filtered.
sourceraw docstring

throttle*clj

(throttle* _ config & children)
source

to-base64clj

(to-base64 field & children)

Convert a field to base64. Field value should be string.

(sdo
  ;; you can pass one field
  (to-base64 :host)
  ;; or a list to update a nested keys
  (to-base64 [:host :service]))
Convert a field to base64.
Field value should be string.

```clojure
(sdo
  ;; you can pass one field
  (to-base64 :host)
  ;; or a list to update a nested keys
  (to-base64 [:host :service]))
```
sourceraw docstring

to-base64*clj

(to-base64* _ fields & children)
source

topclj

(top config & children)

Get the max event from the last dt seconds.

(top {:duration 10}
  (info))

You can pass a :delay key to the configuration in order to tolerate late events. In that case, events from previous windows will be flushed after this delay:

(top {:duration 10 :delay 5}
  (info))
Get the max event from the last dt seconds.

```clojure
(top {:duration 10}
  (info))
```

You can pass a `:delay` key to the configuration in order to tolerate late
events. In that case, events from previous windows will be flushed after this
delay:

```clojure
(top {:duration 10 :delay 5}
  (info))
```
sourceraw docstring

underclj

(under n & children)

Passes on events only when their metric is under than x.

(under 10
  (info))
Passes on events only when their metric is under than x.

```clojure
(under 10
  (info))
```
sourceraw docstring

under*clj

(under* _ n & children)
source

untagclj

(untag tags & children)

Removes a tag, or set of tags, from events which flow through.

(untag "foo" index)

This example removes the tag "foo" from events.

(untag ["foo" "bar"] index)

This example removes the tags "foo" and "bar" from events

Removes a tag, or set of tags, from events which flow through.

```clojure
(untag "foo" index)
```

This example removes the tag "foo" from events.

```clojure
(untag ["foo" "bar"] index)
```

This example removes the tags "foo" and "bar" from events
sourceraw docstring

untag*clj

(untag* _ tags & children)
source

warningclj

(warning & children)

Keep all events in state warning.

(warning
  (warning))

In this example, all events with :state "warning" will be logged.

Keep all events in state warning.

```clojure
(warning
  (warning))
```

In this example, all events with `:state` "warning" will be logged.
sourceraw docstring

warning*clj

(warning* _ & children)
source

whereclj

(where conditions & children)

Filter events based on conditions. Each condition is a vector composed of the function to apply on the field, the field to extract from the event, and the event itself. Multiple conditions can be added by using :or or :and.

(where [:= :metric 4])

Here, we keep only events where the :metric field is equal to 4.

(where [:and [:= :host "foo"]
             [:> :metric 10])

Here, we keep only events with :host = foo and with :metric > 10

Filter events based on conditions.
Each condition is a vector composed of the function to apply on the field,
the field to extract from the event, and the event itself.
Multiple conditions can be added by using `:or` or `:and`.

```clojure
(where [:= :metric 4])
```

Here, we keep only events where the :metric field is equal to 4.

```clojure
(where [:and [:= :host "foo"]
             [:> :metric 10])
```

Here, we keep only events with :host = foo and with :metric > 10
sourceraw docstring

where*clj

(where* _ conditions & children)
source

withclj

(with & args)

Set an event field to the given value.

(with :state "critical"
  (debug))

This example set the field :state to "critical" for events.

A map can also be provided:

(with {:service "foo" :state "critical"}
  (debug))

This example set the the field :service to "foo" and the field :state to "critical" for events.

This action also supports updated nested keys:

(with [:nested :key] "critical"
  (debug))
(with {[:nested :key] "critical"}
  (debug))
Set an event field to the given value.

```clojure
(with :state "critical"
  (debug))
```

This example set the field `:state` to "critical" for events.

A map can also be provided:

```clojure
(with {:service "foo" :state "critical"}
  (debug))
```

This example set the the field `:service` to "foo" and the field `:state`
to "critical" for events.

This action also supports updated nested keys:

```clojure
(with [:nested :key] "critical"
  (debug))
```

```clojure
(with {[:nested :key] "critical"}
  (debug))
```
sourceraw docstring

with*clj

(with* _ fields & children)
source

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close