Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A way to specify tolerance in join for relative rules #2011

Closed
desa opened this issue Sep 19, 2017 · 1 comment
Closed

A way to specify tolerance in join for relative rules #2011

desa opened this issue Sep 19, 2017 · 1 comment
Assignees
Milestone

Comments

@desa
Copy link
Contributor

desa commented Sep 19, 2017

While working with @davidgs on creating a relative rule in Chronograf, we discovered that data was buffering up at the join node.

var db = 'iotdata'

var rp = 'autogen'

var measurement = 'influxdata_sensors'

var groupBy = []

var whereFilter = lambda: TRUE

var name = 'TemperatureChange'

var idVar = name + ':{{.Group}}'

var message = ' {{ index .Fields "value" }}'

var idTag = 'alertID'

var levelTag = 'level'

var messageField = 'message'

var durationField = 'duration'

var outputDB = 'chronograf'

var outputRP = 'autogen'

var outputMeasurement = 'alerts'

var triggerType = 'relative'

var shift = 1m

0s

var crit = 0.1

var data = stream
    |from()
        .database(db)
        .retentionPolicy(rp)
        .measurement(measurement)
        .groupBy(groupBy)
        .where(whereFilter)
    |eval(lambda: "temp_f")
        .as('value')

var past = data
    |shift(shift)

var current = data

var trigger = past
    |join(current)
        .as('past', 'current')
    |eval(lambda: float("current.value" - "past.value"))
        .keep()
        .as('value')
    |alert()
        .crit(lambda: "value" > crit)
        .stateChangesOnly()
        .message(message)
        .id(idVar)
        .idTag(idTag)
        .levelTag(levelTag)
        .messageField(messageField)
        .durationField(durationField)
        .post('http://davidgs.com:1880/sensor-reading')

trigger
    |influxDBOut()
        .create()
        .database(outputDB)
        .retentionPolicy(outputRP)
        .measurement(outputMeasurement)
        .tag('alertName', name)
        .tag('triggerType', triggerType)

trigger
    |httpOut('output')

The reason for this is that the timestamps of each of the points is ~1s, but not exactly 1s. The default tolerance for join is 0s and since each point isn't exactly 1s apart, the timestamps wont line up and data will not join.

Specifying a tolerance

...
past
    |join(current)
        .as('past', 'current')
        .tolerance(100ms)
...

allows data to be joined as expected. It would be awesome to have a way to specify tolerance via the UI.

@nhaugo nhaugo added this to the 1.3.10 milestone Sep 29, 2017
@nhaugo nhaugo added the ready label Oct 3, 2017
@nhaugo nhaugo modified the milestones: 1.3.10, 1.3.11 Oct 23, 2017
@nhaugo nhaugo modified the milestones: 1.3.11, 1.4.x Oct 31, 2017
@russorat russorat removed this from the 1.4.x milestone Nov 28, 2018
@russorat
Copy link
Contributor

closing due to inactivity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants