TICK Script never sets .Level to OK


#1

Hey all, I’m writing a TickScript that acts on a series of points that can have exactly two outcomes.

Either the result is pass or “not pass” (usually some variant of exit NUM).

The script I have looks sort of like this:

// RP: autogen
// Monitor the result of updates
// WARNING if the result is anything other than pass
batch
    |query('''SELECT * FROM "mydb"."autogen"."measurement"''')
        .period(25h)
        .every(24h)
        .groupBy('host')
    |alert()
        .id('kapacitor/{{ .TaskName }}/{{ .Group }}')
        .infoReset(lambda: TRUE)
        .warn(lambda: "result" != 'pass')
        .message(
            '{{ index .Tags "host" }}' +
            '{{ if eq .Level "OK" }} are updating again.' +
            '{{ else }}' +
            'are failing to update.' +
            '{{ end }}'
        )
        .idField('id')
        .levelField('level')
        .messageField('description')
        .stateChangesOnly()
    @alertFilterAdapter()
    @alertFilter()

The script does seem to sort of do its thing, but has a critical issue of never setting the Level back to OK.

If I feed influx these 4 points:

time                host     name                   result
----                ----     ----                   ------
1544079584447374994 fakeS176 /usr/bin/yum update -y pass
1544079584447374994 fakeS177 /usr/bin/yum update -y exit 1
1544129084447375177 fakeS176 /usr/bin/yum update -y exit 1
1544129084447375177 fakeS177 /usr/bin/yum update -y pass

I would expect 1 warning, and 1 OK. Where all of the timestamps listed above are within the 25 hour period.

However what actually happens is that I get 2 warns and no OKs.

Could someone give some advice on how to move forward?


#2

Man, nobody really does use the god-forsaken language. We could have used a Go or Python based API, but instead we get this.

And then with Influx 2 we get a SECOND language, not an API with a well known language, and not improvements on the main language either because who needs any of the tooling made beforehand or prior knowledge?

Ugh