Se ha denunciado esta presentación.
Se está descargando tu SlideShare. ×

Scott Anderson [InfluxData] | Flux Alerts and Notifications | InfluxDays NA 2021

Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio

Eche un vistazo a continuación

1 de 43 Anuncio

Scott Anderson [InfluxData] | Flux Alerts and Notifications | InfluxDays NA 2021

Descargar para leer sin conexión

Learn how to generate and send notifications in raw Flux. Use the InfluxDB alerts and notification system or build out your own. Familiarize yourself with patterns and functions built into Flux for sending alerts.

Learn how to generate and send notifications in raw Flux. Use the InfluxDB alerts and notification system or build out your own. Familiarize yourself with patterns and functions built into Flux for sending alerts.

Anuncio
Anuncio

Más Contenido Relacionado

Presentaciones para usted (20)

Similares a Scott Anderson [InfluxData] | Flux Alerts and Notifications | InfluxDays NA 2021 (20)

Anuncio

Más de InfluxData (20)

Más reciente (20)

Anuncio

Scott Anderson [InfluxData] | Flux Alerts and Notifications | InfluxDays NA 2021

  1. 1. Flux Alerts & Notifications Scott Anderson Senior Technical Writer & Technical Lead of the Docs team @ InfluxData
  2. 2. © 2021  InfluxData Inc. All Rights Reserved. Goals ● Demystify Flux notifications ● Explain notification conventions ● Demonstrate notifications in raw Flux
  3. 3. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved. * *
  4. 4. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved.
  5. 5. © 2021  InfluxData Inc. All Rights Reserved. 5 © 2021  InfluxData Inc. All Rights Reserved. Notification packages
  6. 6. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved. Each notification package An endpoint function A function that outputs a function that iterates over all input rows and generates another function that sends a notification for each input row. Notification function A function that sends a single notification.
  7. 7. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved. slack package slack.endpoint() slack.message() pagerduty package pagerduty.endpoint() pagerduty.sendEvent()
  8. 8. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved. Notification Conventions ● One-off convention ● Map convention ● Endpoint convention
  9. 9. © 2021  InfluxData Inc. All Rights Reserved. 9 © 2021  InfluxData Inc. All Rights Reserved. One-off convention
  10. 10. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved. sendFn(...)
  11. 11. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved. import "slack"
  12. 12. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved. import "slack" slack.message(...)
  13. 13. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved. import "slack" slack.message( url: "https://slack.com/api/chat.postMessage", token: "mYSuP3rSecR37T0kEN", channel: "#mychannel", text: "Hey, here's a message!", color: "danger" )
  14. 14. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved. import "slack" lastReported = data |> last() |> findRecord(fn: (key) => true, idx: 0) slack.message( url: "https://slack.com/api/chat.postMessage", token: "mYSuP3rSecR37T0kEN", channel: "#mychannel", text: "The last reported value was ${lastReported._value}.", color: "#000" )
  15. 15. © 2021  InfluxData Inc. All Rights Reserved. 15 © 2021  InfluxData Inc. All Rights Reserved. Map Convention
  16. 16. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved. map(fn: (r) => ({ r with sent: sendFn(...) }))
  17. 17. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved. import "slack" data
  18. 18. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved. import "slack" data |> map(fn: (r) => ({ ... }))
  19. 19. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved. import "slack" data |> map(fn: (r) => ({ r with sent: ... }))
  20. 20. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved. import "slack" data |> map(fn: (r) => ({ r with sent: slack.message( url: "https://slack.com/api/chat.postMessage", token: "mYSuP3rSecR37T0kEN", channel: "#mychannel", text: "Oh no! *${r.tag} had a value of *${r._value}*.", color: "danger" }))
  21. 21. © 2021  InfluxData Inc. All Rights Reserved. 21 © 2021  InfluxData Inc. All Rights Reserved. Endpoint convention
  22. 22. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved. endpointFn(...) => (mapFn) => (tables=<-)
  23. 23. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved. import "slack" data
  24. 24. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved. import "slack" data |> slack.endpoint(...)
  25. 25. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved. import "slack" data |> slack.endpoint( url: "https://slack.com/api/chat.postMessage", token: "mYSuP3rSecR37T0kEN" )
  26. 26. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved. import "slack" data |> slack.endpoint( url: "https://slack.com/api/chat.postMessage", token: "mYSuP3rSecR37T0kEN" )(mapFn: (r) => ({ channel: "#mychannel", text: "Oh no! *${r.tag} had a value of *${r._value}*.", color: "danger" }))
  27. 27. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved. import "slack" data |> slack.endpoint( url: "https://slack.com/api/chat.postMessage", token: "mYSuP3rSecR37T0kEN" )(mapFn: (r) => ({ channel: "#mychannel", text: "Oh no! *${r.tag} had a value of *${r._value}*.", color: "danger" }))()
  28. 28. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved. import "influxdata/influxdb/monitor" import "influxdata/influxdb/secrets" import "slack" notification_data = {...} token = secrets.get(key: "SLACK_TOKEN") endpoint = slack.endpoint(token: token)(mapFn: (r) => ({ channel: "#mychannel", text: "Oh no! *${r.tag} had a value of *${r._value}*.", color: "#000" })) monitor.from(start: -1h, fn: (r) => r._level == "crit”) |> monitor.notify(endpoint: endpoint, data: notification_data)
  29. 29. © 2021  InfluxData Inc. All Rights Reserved. 29 © 2021  InfluxData Inc. All Rights Reserved. Custom notifications
  30. 30. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved. http.post( url: "...", headers: "...", data: bytes(v: "...") )
  31. 31. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved. import "http" tweet = (status, oauth) => { }
  32. 32. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved. import "http" tweet = (status, oauth) => { apiURL = "https://api.twitter.com/1.1/statuses/update.json" }
  33. 33. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved. import "http" tweet = (status, oauth) => { apiURL = "https://api.twitter.com/1.1/statuses/update.json" return http.post( ) }
  34. 34. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved. import "http" tweet = (status, oauth) => { apiURL = "https://api.twitter.com/1.1/statuses/update.json" return http.post( url: "${apiURL}?status=${http.pathEscape(inputString: status)}" headers: {Authorization: "OAuth ${oauth}"} ) }
  35. 35. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved. import "http" tweet = (status, oauth) => {...} tweet( status: "This tweet was created by Flux and InfluxDB!", oauth: "..." )
  36. 36. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved. import "http" tweet = (status, oauth) => {...} tweet( status: "This tweet was created by Flux and InfluxDB!", oauth: "..." )
  37. 37. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved. import "http" tweet = (status, oauth) => {...} oauth: "..." data |> map(fn: (r) => ({ r with sent: }))
  38. 38. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved. import "http" tweet = (status, oauth) => {...} oauth: "..." data |> map(fn: (r) => ({ r with sent: tweet( status: "At ${r._time}, ${r._field} was ${r._value}.", oauth: oauth ) }))
  39. 39. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved. http.endpoint(url: "...") => (mapFn: (r) => ({ headers: "...", data: bytes(v: "...") })) => (tables=<-)
  40. 40. © 2021  InfluxData Inc. All Rights Reserved. © 2021  InfluxData Inc. All Rights Reserved. import "http" import "influxdata/influxdb/monitor" apiURL = "https://api.twitter.com/1.1/statuses/update.json" oauth = "..." notification_data = {...} endpoint = http.endpoint( url: "${apiURL}" )(mapFn: (r) => ({ url: "${apiURL}?status=${http.pathEscape(inputString: r._message)}", headers: {Authorization: "OAuth ${oauth}"}, data: bytes(v: "") })) monitor.from(start: -1h) |> monitor.notify(endpoint: endpoint, data: notification_data)
  41. 41. © 2021  InfluxData Inc. All Rights Reserved. Demo!
  42. 42. © 2021  InfluxData Inc. All Rights Reserved. Questions?
  43. 43. © 2021  InfluxData Inc. All Rights Reserved. Thank You

×