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

TickScript deadman groupby nil value #2750

Open
enzdal opened this issue Mar 13, 2023 · 0 comments
Open

TickScript deadman groupby nil value #2750

enzdal opened this issue Mar 13, 2023 · 0 comments

Comments

@enzdal
Copy link

enzdal commented Mar 13, 2023

Hi all, I have a strange problem with the deadman type alert. I defined a groupby condition on a tag that by the time the script is deployed the data hasn't arrived yet, so a "nil" error is thrown. Is there a way to ignore when the bucket is empty and not throw this kind of error?
This is the current script:

var db = 'test-db'

var rp = 'test-rp'

var measurement = 'my-test'

var groupBy = ['unique-field']

var whereFilter = lambda: ("condition" == 'false') AND ("description" == 'my-desc')

var period = 1m

var name = 'Dead-unique'

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

var message = ''

var idTag = 'alertID'

var levelTag = 'level'

var messageField = 'message'

var durationField = 'duration'

var outputDB = 'alarms-db'

var outputRP = 'alarms-rp'

var outputMeasurement = 'alerts'

var triggerType = 'deadman'

var threshold = 0.0

var data = stream
    |from()
        .database(db)
        .retentionPolicy(rp)
        .measurement(measurement)
        .groupBy(groupBy)
        .where(whereFilter)

var trigger = data
    |deadman(threshold, period)
        .message(message)
        .id(idVar)
        .idTag(idTag)
        .levelTag(levelTag)
        .messageField(messageField)
        .durationField(durationField)
        .stateChangesOnly()

trigger
    |eval(lambda: "emitted")
        .as('value')
        .keep('value', messageField, durationField)
    |eval(lambda: float("value"))
        .as('value')
        .keep()
    |influxDBOut()
        .create()
        .database(outputDB)
        .retentionPolicy(outputRP)
        .measurement(outputMeasurement)
        .tag('alertName', name)
        .tag('triggerType', triggerType)

trigger
    |httpOut('output')

and this is the error with nil value:

{
   "id": "Dead-unique-nil",
   "message": "",
   "details": "....",
   "duration": 0,
   "level": "CRITICAL",
   "data": {
      "series": [
         {
            "name": "stats",
            "columns": [
               "time",
               "emitted"
            ],
            "values": [
               [
                  "2023-03-13T11:01:00Z",
                  0
               ]
            ]
         }
      ]
   },
   "previousLevel": "OK",
   "recoverable": true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant