Files in this directory represent DynamicWindowUDF usage in bundle with the Kapacitor SideloadNode
@dynamicWindowUDF()
.periodField('period')
.periodTimeUnit('m')
.defaultPeriod(default_period)
.staticEvery(30s)
.fillPeriod()
.emitTimeout(10s)
// alternative configuration
@dynamicWindowUDF()
.staticPeriod(60s)
.everyField('every')
.everyTimeUnit('m')
.defaultEvery(default_every)
.emitTimeout(10s)
periodField–-periodfield nameperiodTimeUnit–-periodvalues time unit to interpret them correctly: ns – nanoseconds, u/mcs/us – microseconds, ms – milliseconds, s – seconds, m – minutes, h – hours, d – days, w – weeksdefaultPeriod–-perioddefault valuestaticPeriod-- setsperiodconstant value, cannot be changed with incoming points (Kapacitor WindowNode'speriodproperty analogue); conflicts with three previous propertieseveryField–-everyfield nameeveryTimeUnit–-everyvalues time unit, similarly toperiodTimeUnitdefaultEvery-–everydefault valuestaticEvery-- setseveryconstant value, cannot be changed with incoming points (Kapacitor WindowNode'severyproperty analogue); conflicts with three previous propertiesemitTimeout-– UDF accumulates several points before processing.emitTimeoutproperty defines timeout between two sequential processing momentsfillPeriod–- optional property. Defines if UDF should wait until the first window is fully filled (Kapacitor WindowNode'sfillPeriodproperty analogue)
Just run the following in the current directory:
$ docker-compose up
Now you can use kapacitor commands right from your host system. For example,
you can run dynamic_window.tick and watch the results:
$ kapacitor define dynamic_window_task -tick dynamic_window.tick
$ kapacitor enable dynamic_window_task
$ kapacitor watch dynamic_window_task
After that you will able to see points coming from UDF.
To remove intermediate build container, call:
$ docker image prune --filter "label=stage=builder" --filter "label=project=dynamic_window_udf_example" --force
This example uses number of Docker containers:
- kapacitor-udf -- container with UDF. Uses Docker image built from Dockerfile.
- collectd -- metrics producer. Sends them to InfluxDB. In theory, can be replaced.
- indluxdb -- InfluxDB container. Parses Graphite data format coming from collectd. Provides metrics for Kapacitor.
- kapacitor -- Kapacitor container. Subscribes to InfluxDB to receive metrics, processes them with TICK scripts, communicates with UDF.