Code Monkey home page Code Monkey logo

insights-about-pagerduty's Introduction

Archived header

Insights about Pagerduty

Purpose

How is your oncall shift going? How many incidents did you field this week, and for what services? Is your alert noise getting worse or better?

Find answers to these and more by using New Relic Insights to query your PagerDuty incident history! This is a small Ruby script, suitable for running in Heroku, that queries PagerDuty every 10 minutes and populates Insights with information about resolved PagerDuy incidents.

Usage

Software required:

  • Ruby 2.1.1
  • Bundler

Required environment variables:

  • PAGERDUTY_TOKEN - your PagerDuty API key.
  • PAGERDUTY_DOMAIN - your PagerDuty subdomain.
  • INSIGHTS_INSERT_KEY - your New Relic Insights insert key.
  • INSIGHTS_EVENT_URL - The Endpoint to send Insights events to. Can be found in the examples in your Data Management -> API Keys page. Will look like: https://insights-collector.newrelic.com/v1/accounts/<your account id>/events.

Optional environment variables:

  • FETCH_INCIDENTS_SINCE - The number of seconds to look in the past for pagerduty incidents. Defaults to 10 minutes. Set this to your run interval for the script. You may set this to be wider when running manually to backfill events, but note that Insights only allows backdated events up to 24 hours old. [NB: The code makes no attempt to prevent duplicate entries in Insights, so be careful when experimenting.]

Command line:

bundle install
bundle exec ./pagerduty-incident-scraper.rb

Heroku:

Set the required ENV inside your heroku app and configure the Heroku Scheduler add-on to the script every 10 minutes. Each run is very short, so it should fit easily into free dyno hours.

When configured, it will look something like this:

Then configure the Heroku Scheduler Add-on:

Example NRQL Queries

Once you've loaded some of your data, what kind of things can you find out?

Who fielded the most alerts this week?

SELECT count(*) from PagerdutyIncident FACET first_assigned_to_user SINCE 1 week ago TIMESERIES

alert recipient chart

What hours of the day are incidents created?

SELECT histogram(created_on_hour, 24, 24) from PagerdutyIncident WHERE eventVersion >= 2 SINCE 1 week ago

alert hour histogram

Wait, what's eventVersion?

Because Insights doesn't currently allow modification of stored events, if the schema of the events sent in changes, it can be hard to make queries that depend on the schema looking a certain way. This script sends an eventVersion integer attribute that you should increment if you change the schema of the events you send. For this query, created_on_hour was changed from a string to an integer in eventVersion 2, so it's scoped to those.

How long are our incidents open?

SELECT histogram(open_duration, 600) from PagerdutyIncident SINCE 1 week ago

incident open time histogram

How many incidents are being routed to my team?

SELECT count(*) from PagerdutyIncident WHERE  escalation_policy_name='Site Services' SINCE 1 week ago TIMESERIES

Escalation policy alert count chart

Contributing

You are welcome to send pull requests to us - however, by doing so you agree that you are granting New Relic a non-exclusive, non-revokable, no-cost license to use the code, algorithms, patents, and ideas in that code in our products if we so choose. You also agree the code is provided as-is and you provide no warranties as to its fitness or correctness for any purpose.

insights-about-pagerduty's People

Contributors

benders avatar intjonathan avatar melissaklein24 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.