Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ServiceNow event handler #2416

Merged
merged 4 commits into from
Oct 26, 2020
Merged

Conversation

alespour
Copy link
Contributor

@alespour alespour commented Oct 19, 2020

This PR adds ServiceNow event handler as requested by https://github.com/influxdata/feature-requests/issues/176.

The handler supports several string type options that can be set when using .serviceNow() in a TICKscript which are used to set corresponding fields in ServiceNow alert or event (see https://docs.servicenow.com/bundle/paris-it-operations-management/page/product/event-management/task/t_EMManuallyCreateAlert.html)

handler option alert/event field
node Node
type Type
resource Resource
metricName Metric name
messageKey Message key

All these options support templates with the following variables available: ID, Name, TaskName, Fields, Tags (with the same meaning as in AlertNode.message)

By default, the handler maps config and/or event values to ServiceNow Alert or Event fields as follows:

value field
source Source
message Description
alert ID Message key

TICKscript examples:

stream
  |from()
    .measurement('cpu')
  |alert()
    .crit(lambda: "usage_user" > 90)
    .stateChangesOnly()
    .message('Hey, check your CPU')
    .serviceNow()
stream
  |from()
    .measurement('cpu')
  |alert()
    .crit(lambda: "usage_user" > 90)
    .message('Hey, check your CPU')
    .serviceNow()
        .node('{{ index .Tags "host" }}')
        .type('CPU')
        .resource('CPU-Total')
        .metricName('usage_user')
        .messageKey('Alert: {{ .ID }}')

Default configuration:

[servicenow]
  # Configure ServiceNow.
  enabled = false
  # The ServiceNow URL for target table (Alert or Event). Replace instance with actual hostname.
  url = "https://instance.service-now.com/api/now/v1/table/em_alert"
  # Default source identification.
  source = "Kapacitor"
  # Username for HTTP BASIC authentication
  # username = ""
  # Password for HTTP BASIC authentication
  # password = ""
Required for all non-trivial PRs
  • Rebased/mergable
  • Tests pass
  • CHANGELOG.md updated
  • Sign CLA (if not already signed)
Required only if applicable

You can erase any checkboxes below this note if they are not applicable to your Pull Request.
N/A

ServiceNow alert with default options:
servicenow-alert-default

ServiceNow alert with custom options:
servicenow-alert-with-options

@alespour alespour marked this pull request as ready for review October 19, 2020 15:16
@timhallinflux timhallinflux mentioned this pull request Oct 22, 2020
4 tasks
@docmerlin
Copy link
Contributor

@alespour has this been tested against ServiceNow? I don't have an account to test this. Otherwise it looks fine.

Copy link
Contributor

@docmerlin docmerlin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks fine so long as it has been manually tested with ServiceNow.

@alespour
Copy link
Contributor Author

@docmerlin Yes it was tested manually, the screenshots show alerts sent from Kapacitor.

@docmerlin docmerlin merged commit 2750476 into influxdata:master Oct 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants