sensu.event() function

The sensu.event() function is a user-contributed function maintained by the package author and can be updated or removed at any time.

The sensu.event() function sends a single event to the Sensu Events API.

*Function type: Output*

  1. import "contrib/sranka/sensu"
  2. sensu.event(
  3. url: "http://localhost:8080",
  4. apiKey: "mYSuP3rs3cREtApIK3Y",
  5. checkName: "checkName",
  6. text: "Event output text",
  7. handlers: [],
  8. status: 0,
  9. state: "passing",
  10. namespace: "default",
  11. entityName: "influxdb"
  12. )

Parameters

url

Required Base URL of Sensu API without a trailing slash. Example: http://localhost:8080.

*Data type: String*

apiKey

Required Sensu API Key.

*Data type: String*

checkName

Required Check name. Use alphanumeric characters, underscores (_), periods (.), and hyphens (-). All other characters are replaced with an underscore.

*Data type: String*

text

Required Event text. Mapped to output in the Sensu Events API request.

*Data type: String*

handlers

Sensu handlers to execute. Default is [].

*Data type: Array of strings*

status

Event status code that indicates state. Default is 0.

*Data type: Integer*

Status codeState
0OK
1WARNING
2CRITICAL
Any other valueUNKNOWN or custom state

state

Event state. Default is "passing" for 0 status and "failing" for other statuses.

*Data type: string*

The following values are accepted:

  • "failing"
  • "passing"
  • "flapping"

namespace

Sensu namespace. Default is "default".

*Data type: String*

entityName

Event source. Use alphanumeric characters, underscores (_), periods (.), and hyphens (-). All other characters are replaced with an underscore. Default is influxdb.

*Data type: String*

Examples

Send the last reported status to Sensu
  1. import "influxdata/influxdb/secrets"
  2. import "contrib/sranka/sensu"
  3. apiKey = secrets.get(key: "SENSU_API_KEY")
  4. lastReported =
  5. from(bucket: "example-bucket")
  6. |> range(start: -1m)
  7. |> filter(fn: (r) => r._measurement == "statuses")
  8. |> last()
  9. |> findRecord(fn: (key) => true, idx: 0)
  10. sensu.event(
  11. url: "http://localhost:8080",
  12. apiKey: apiKey,
  13. checkName: "diskUsage",
  14. text: "Disk usage is **${lastReported.status}**.",
  15. )

Package author and maintainer

Github: @sranka
InfluxDB Slack: @sranka

Related articles