influxdata / chronograf

Open source monitoring and visualization UI for the TICK stack
https://www.influxdata.com/time-series-platform/chronograf/
Other
1.51k stars 258 forks source link

Support for String fields compare kapacitor rules in Chronograf UI #865

Closed chetu closed 7 years ago

chetu commented 7 years ago

Haproxy input plugin field "status" have UP, DOWN , OPEN.

In tick its works:

var period = 10s
var every = 10s
var data = stream
    |from()
        .database('influxdb')
        .retentionPolicy('autogen')
        .measurement('haproxy')
        .groupBy('pxname')
    |window()
        .period(period)
        .every(every)
    |last('status')
        .as('value')

var alert = data
    |alert()
        .message('Haproxy monitor : {{.ID}} : {{ index .Tags "server" }} : {{ index .Tags "pxname" }} is {{ .Level }} ')
        .crit(lambda: "value" == 'DOWN' )
        .stateChangesOnly()
        .id('{{ .Name }}')
        .details(''' Email template ''')

In above tick script its working, however chronograf UI not working or not have option to it.

string_support

goller commented 7 years ago

Hi @chetu, thanks for writing in this bug! I've been able to reproduce in a unit test. I'm working on a fix right now and it'll ship with today's release.

goller commented 7 years ago

Hi @chetu, I've fixed this in PR #867.

Here is the output tickscript now with your parameters:

var db = 'influxdb'

var rp = 'autogen'

var measurement = 'haproxy'

var groupBy = ['pxname']

var whereFilter = lambda: TRUE

var period = 10s

var every = 10s

var name = 'haproxy'

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

var message = 'Haproxy monitor : {{.ID}} : {{ index .Tags "server" }} : {{ index .Tags "pxname" }} is {{ .Level }} '

var idTag = 'alertID'

var levelTag = 'level'

var messageField = 'message'

var durationField = 'duration'

var outputDB = 'chronograf'

var outputRP = 'autogen'

var outputMeasurement = 'alerts'

var triggerType = 'threshold'

var details = 'Email template'

var crit = 'DOWN'

var data = stream
    |from()
        .database(db)
        .retentionPolicy(rp)
        .measurement(measurement)
        .groupBy(groupBy)
        .where(whereFilter)
    |window()
        .period(period)
        .every(every)
        .align()
    |last('status')
        .as('value')

var trigger = data
    |alert()
        .crit(lambda: "value" == crit)
        .stateChangesOnly()
        .message(message)
        .id(idVar)
        .idTag(idTag)
        .levelTag(levelTag)
        .messageField(messageField)
        .durationField(durationField)
        .details(details)
        .email()

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

trigger
    |httpOut('output')

... which is now in our test cases!

goller commented 7 years ago

Ok, it's merged in and will ship with our release today!