Sha256: 93533b215cb6909b5d3943b4d38961bf4a0ba7e572d62496f86cfdd2f446b474

Contents?: true

Size: 1.06 KB

Versions: 3

Compression:

Stored size: 1.06 KB

Contents

# frozen_string_literal: true

require "dogapi"

module Eye

  class Notify

    class DataDog < Eye::Notify

      param :aggregation_key, String
      param :alert_type, String
      param :api_key, String, true
      param :source_type, String
      param :tags, Array

      def execute
        options = {
          alert_type: "error",
          aggregation_key: msg_host + msg_full_name,
          source_type: "None",
          tags: ["eye"],
        }

        options[:alert_type] = alert_type if alert_type
        options[:aggregation_key] = aggregation_key if aggregation_key
        options[:source_type] = source_type if source_type
        options[:tags] = tags if tags

        event = Dogapi::Event.new(
          message_body,
          aggregation_key: options[:aggregation_key],
          alert_type: options[:alert_type],
          msg_title: message_subject,
          host: msg_host,
          source_type: options[:source_type],
          tags: options[:tags],
        )

        Dogapi::Client.new(api_key).emit_event(event)
      end

    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
eye-patch-1.1.0 lib/eye/notify/datadog.rb
eye-patch-1.0.1 lib/eye/notify/datadog.rb
eye-patch-1.0.0 lib/eye/notify/datadog.rb