Search code examples
influxdbkapacitorchronograf

Create Kapacitor alert error


I get following error while creating an Kapacitor alert. Alert is created but not triggered.

ts=2018-08-21T15:01:05.329Z lvl=error msg="failed to create database" service=kapacitor task_master=main task=chronograf-v1-2004f027-091f-4af9-b5c8-a636ab28fcc8 node=influxdb_out8 err="retention policy conflicts with an existing policy" database=chronograf cluster=

Retention policy defined on influxdb database is defined as following.

show retention policies on chronograf name duration shardGroupDuration replicaN default ---- -------- ------------------ -------- ------- autogen 1440h0m0s 168h0m0s 1 true

Tickscript used

var db = 'telemetrics'    
var rp = 'two_months'    
var measurement = 'system'    
var groupBy = []    
var whereFilter = lambda: ("host" == 'hostname.domain.xxxx')    
var period = 1m    
0s    
var name = 'Redis Deadman'    
var idVar = name + ':{{.Group}}'    
var message = 'DEADMAN Alert REDIS.'     
var idTag = 'alertID'    
var levelTag = 'level'    
var messageField = 'message'
var durationField = 'duration'    
var outputDB = 'chronograf'    
var outputRP = 'autogen'    
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)
        .stateChangesOnly()
        .message(message)
        .id(idVar)
        .idTag(idTag)
        .levelTag(levelTag)
        .messageField(messageField)
        .durationField(durationField)
        .telegram()
        .chatId('-232933442')
        .log('/var/log/kapacitor/alerts.log')

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')

Any suggestions?


Solution

  • The conflict i guess is that you are trying to create the same db.

    "retention policy conflicts with an existing policy" you may need another rp.