Module: PagerDuty::Client::LogEntries

Included in:
PagerDuty::Client
Defined in:
lib/pager_duty/client/log_entries.rb

Overview

Module encompassing interactions with the incidents API endpoint

PagerDuty keeps a log of all the events that happen to an incident

These are exposed as log entries.

Log entries give you more insight into how your team or organization is handling your incidents.

Log entry data includes details about the event(s) that affected the incident throughout its lifecycle, such as:

  • the data contained in events sent by the integration

  • what users were notified and when

  • how they were notified

  • what user(s) acknowledged or resolved the incident

  • any automatic actions that occurred to the incident

  • other manual user actions, such as a reassignment or a note

Log entries cannot be created directly through the API; they are a result of other actions. The API provides read-only access to the log entries generated by PagerDuty.

Instance Method Summary collapse

Instance Method Details

#log_entries(options = {}) ⇒ Array<Sawyer::Resource> Also known as: list_log_entries

List all of the incident log entries across the entire account.

Parameters:

  • options (Sawyer::Resource) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :time_zone (String)

    Time zone in which dates in the result will be rendered.

  • :since (String)

    The start of the date range over which you want to search ISO8601 format

  • :until (String)

    The end of the date range over which you want to search ISO8601 format

  • :is_overview (Boolean)

    If true, will return a subset of log entries that show only the most important changes to the incident.

  • :include (Array<String>)

    Array of additional details to include. (One or more of incidents, services, channels or teams.)

Returns:

  • (Array<Sawyer::Resource>)

    An array of hashes representing log_entries

See Also:



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/pager_duty/client/log_entries.rb', line 32

def log_entries(options = {})
  query_params = Hash.new
  query_params[:since] = options[:since].utc.iso8601 if options[:since]
  query_params[:until] = options[:until].utc.iso8601 if options[:until]
  query_params[:time_zone] = options[:time_zone] if options[:time_zone]
  query_params[:is_overview] = options.fetch(:is_overview, false)
  query_params[:include]       = options[:include] if options[:include]

  response = get "/log_entries", options.merge({query: query_params})
  response[:log_entries]
end

#log_entry(id, options = {}) ⇒ Sawyer::Resource Also known as: get_log_entry

Get details for a specific incident log entry. This method provides additional information you can use to get at raw event data.

Parameters:

  • id (String)

    A log entry id (required)

  • options (Sawyer::Resource) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :time_zone (String)

    Default to UTC

  • :include (Array<String>)

    Array of additional details to include. (One or more of incidents, services, channels or teams.)

Returns:

  • (Sawyer::Resource)

    A hash representing log entry

See Also:



53
54
55
56
57
58
59
60
# File 'lib/pager_duty/client/log_entries.rb', line 53

def log_entry(id, options = {})
  query_params = Hash.new
  query_params[:time_zone] = options[:time_zone] if options[:time_zone]
  query_params[:include]   = options[:include] if options[:include]

  response = get "/log_entries/#{id}", options.merge({query: query_params})
  response[:log_entry]
end