content/flux/v0/stdlib/contrib/bonitoo-io/servicenow/event.md
servicenow.event() sends an event to ServiceNow.
ServiceNow Event API fields are described in ServiceNow Create Event documentation.
(
description: A,
password: string,
severity: B,
url: string,
username: string,
?additionalInfo: C,
?messageKey: D,
?metricName: E,
?metricType: F,
?node: G,
?resource: H,
?source: I,
) => int where B: Equatable, C: Equatable
{{% caption %}} For more information, see Function type signatures. {{% /caption %}}
({{< req >}}) ServiceNow web service URL.
({{< req >}}) ServiceNow username to use for HTTP BASIC authentication.
({{< req >}}) ServiceNow password to use for HTTP BASIC authentication.
({{< req >}}) Event description.
({{< req >}}) Severity of the event.
Supported values:
criticalmajorminorwarninginfoclearSource name. Default is "Flux".
Node name or IP address related to the event.
Default is an empty string ("").
Metric type related to the event (for example, CPU).
Default is an empty string ("").
Resource related to the event (for example, CPU-1).
Default is an empty string ("").
Metric name related to the event (for example, usage_idle).
Default is an empty string ("").
Unique identifier of the event (for example, the InfluxDB alert ID).
Default is an empty string ("").
If an empty string, ServiceNow generates a value.
Additional information to include with the event.
import "contrib/bonitoo-io/servicenow"
import "influxdata/influxdb/secrets"
username = secrets.get(key: "SERVICENOW_USERNAME")
password = secrets.get(key: "SERVICENOW_PASSWORD")
lastReported =
from(bucket: "example-bucket")
|> range(start: -1m)
|> filter(fn: (r) => r._measurement == "cpu" and r._field == "usage_idle")
|> last()
|> findRecord(fn: (key) => true, idx: 0)
servicenow.event(
url: "https://tenant.service-now.com/api/global/em/jsonv2",
username: username,
password: password,
node: lastReported.host,
metricType: lastReported._measurement,
resource: lastReported.instance,
metricName: lastReported._field,
severity:
if lastReported._value < 1.0 then
"critical"
else if lastReported._value < 5.0 then
"warning"
else
"info",
additionalInfo: {"devId": r.dev_id},
)