Advertisement
Guest User

Untitled

a guest
Aug 28th, 2021
26
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var db = 'progettogr'
  2.  
  3. var rp = 'autogen'
  4.  
  5. var measurement = 'dns_table'
  6.  
  7. var groupBy = ['IPv4']
  8.  
  9. var whereFilter = lambda: isPresent("alert")
  10.  
  11. var name = 'dns wrong reponses'
  12.  
  13. var idVar = name + '-{{.Group}}'
  14.  
  15. var message = 'Host {{ index .Tags "IPv4" }} received {{ index .Fields "count" }} ({{ index .Fields "threshold" }}) DNS wrong responses: {{.Level}}'
  16.  
  17. var idTag = 'alertID'
  18.  
  19. var levelTag = 'level'
  20.  
  21. var messageField = 'message'
  22.  
  23. var durationField = 'duration'
  24.  
  25. var outputDB = 'chronograf'
  26.  
  27. var outputRP = 'autogen'
  28.  
  29. var outputMeasurement = 'alerts'
  30.  
  31. var triggerType = 'threshold'
  32.  
  33. var crit = 1
  34.  
  35. var data = stream
  36. |from()
  37. .database(db)
  38. .retentionPolicy(rp)
  39. .measurement(measurement)
  40. .groupBy(groupBy)
  41. .where(whereFilter)
  42. |eval(lambda: "alert")
  43. .as('value')
  44.  
  45. var trigger = data
  46. |alert()
  47. .crit(lambda: "value" == crit)
  48. .message(message)
  49. .id(idVar)
  50. .idTag(idTag)
  51. .levelTag(levelTag)
  52. .messageField(messageField)
  53. .durationField(durationField)
  54. .telegram()
  55. .chatId('659170882')
  56. .parseMode('Markdown')
  57.  
  58. trigger
  59. |eval(lambda: float("value"))
  60. .as('value')
  61. .keep('value')
  62. |influxDBOut()
  63. .create()
  64. .database(outputDB)
  65. .retentionPolicy(outputRP)
  66. .measurement(outputMeasurement)
  67. .tag('alertName', name)
  68. .tag('triggerType', triggerType)
  69.  
  70. trigger
  71. |httpOut('output')
  72.  
Advertisement
RAW Paste Data Copied
Advertisement