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

Added HipChat service for alerting. #125

Merged
merged 1 commit into from
Dec 30, 2015
Merged

Added HipChat service for alerting. #125

merged 1 commit into from
Dec 30, 2015

Conversation

ericiles
Copy link
Contributor

Implements #119

This code has been tested and has successfully sent alerts to HipChat as of 12/28/2015.

Usage:

stream
    .from().measurement('cpu')
    .where(lambda: "host" == 'serverA')
    .groupBy('host')
    .window()
        .period(10s)
        .every(10s)
    .mapReduce(influxql.count('idle'))
    .alert()
        .id('kapacitor/{{ .Name }}/{{ index .Tags "host" }}')
        .info(lambda: "count" > 6.0)
        .warn(lambda: "count" > 7.0)
        .crit(lambda: "count" > 8.0)
        .hipChat()
            .room('1234567')
            .token('testtoken1234567')

Configuration:

[hipchat]
  # Configure HipChat.
  enabled = false
  # The HipChat API URL. Replace subdomain with your
  # HipChat subdomain.
  url = "https://subdomain.hipchat.com/v2/room"
  # Visit https://www.hipchat.com/docs/apiv2
  # for information on obtaining your room id and
  # authentication token.
  # Default room for messages
  room = ""
  # Default authentication token
  token = ""
  # If true then all alerts will be sent to HipChat
  # without explicitly marking them in the TICKscript.
  global = false
  • CHANGELOG.md updated
  • Rebased/mergable
  • Tests pass
  • Sign CLA (if not already signed)

token = s.token
}

url := s.url + "/" + room + "/notification?auth_token=" + token
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we URL escape the room and token vars so the config doesn't have to do things like Test%20Room? See the answer to this SO question. It has a good example of how to safely craft the URL. http://stackoverflow.com/questions/13820280/encode-decode-urls

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In a test I did, it appears that the http.Post automatically url encodes the url string. However, I didn't see this behavior documented, so to play it safe, I went ahead and implented the net/url method of parsing the URL in order to encode it, so that if the http.Post behavior changes in the future, it doesn't break this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Great looks good.

@nathanielc
Copy link
Contributor

@ericiles This is great work! Just a few small changes to make the URL creation safer and easier for the config and this should be good to go.

How do you like the changes to having lists of handlers? Did that help clean it up a bit for you?

@ericiles
Copy link
Contributor Author

Having lists of handlers made things much nicer. Definitely an improvement. I have made the requested changes.

nathanielc pushed a commit that referenced this pull request Dec 30, 2015
Added HipChat service for alerting.
@nathanielc nathanielc merged commit 6ead173 into influxdata:master Dec 30, 2015
@ericiles ericiles deleted the hipchat branch December 30, 2015 21:24
@nathanielc nathanielc mentioned this pull request Jan 22, 2016
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