pager_tree-integrations 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/pager_tree/integrations/alert.rb +3 -1
- data/app/models/pager_tree/integrations/app_dynamics/v3.rb +74 -0
- data/app/models/pager_tree/integrations/auvik/v3.rb +94 -0
- data/app/models/pager_tree/integrations/aws_cloudwatch/v3.rb +108 -0
- data/app/models/pager_tree/integrations/azure_monitor/v3.rb +79 -0
- data/app/models/pager_tree/integrations/boolean_store_accessor.rb +42 -0
- data/app/models/pager_tree/integrations/channel/hangouts/v3.rb +176 -0
- data/app/models/pager_tree/integrations/channel/mattermost/v3.rb +6 -0
- data/app/models/pager_tree/integrations/channel/microsoft_teams/v3.rb +142 -0
- data/app/models/pager_tree/integrations/channel/slack/v3.rb +136 -0
- data/app/models/pager_tree/integrations/cronitor/v3.rb +64 -0
- data/app/models/pager_tree/integrations/datadog/v3.rb +72 -0
- data/app/models/pager_tree/integrations/dead_mans_snitch/v3.rb +76 -0
- data/app/models/pager_tree/integrations/elast_alert/v3.rb +63 -0
- data/app/models/pager_tree/integrations/form/v3.rb +114 -0
- data/app/models/pager_tree/integrations/freshdesk/v3.rb +103 -0
- data/app/models/pager_tree/integrations/freshservice/v3.rb +103 -0
- data/app/models/pager_tree/integrations/grafana/v3.rb +67 -0
- data/app/models/pager_tree/integrations/healthchecks/v3.rb +68 -0
- data/app/models/pager_tree/integrations/honeybadger/v3.rb +76 -0
- data/app/models/pager_tree/integrations/hyperping/v3.rb +60 -0
- data/app/models/pager_tree/integrations/integration.rb +27 -5
- data/app/models/pager_tree/integrations/jira_server/v3.rb +61 -0
- data/app/models/pager_tree/integrations/jotform/v3.rb +50 -0
- data/app/models/pager_tree/integrations/kapacitor/v3.rb +65 -0
- data/app/models/pager_tree/integrations/logic_monitor/v3.rb +79 -0
- data/app/models/pager_tree/integrations/mattermost/outgoing_webhook/v3.rb +77 -0
- data/app/models/pager_tree/integrations/new_relic/v3.rb +67 -0
- data/app/models/pager_tree/integrations/outgoing_event.rb +2 -0
- data/app/models/pager_tree/integrations/outgoing_webhook/v3.rb +37 -6
- data/app/models/pager_tree/integrations/outgoing_webhook_delivery/hook_relay.rb +8 -6
- data/app/models/pager_tree/integrations/outgoing_webhook_delivery.rb +1 -1
- data/app/models/pager_tree/integrations/pingdom/v3.rb +71 -0
- data/app/models/pager_tree/integrations/prometheus/v3.rb +79 -0
- data/app/models/pager_tree/integrations/prtg/v3.rb +58 -0
- data/app/models/pager_tree/integrations/server_guard24/v3.rb +74 -0
- data/app/models/pager_tree/integrations/site24x7/v3.rb +68 -0
- data/app/models/pager_tree/integrations/solar_winds/v3.rb +77 -0
- data/app/models/pager_tree/integrations/stackdriver/v3.rb +60 -0
- data/app/models/pager_tree/integrations/status_cake/v3.rb +65 -0
- data/app/models/pager_tree/integrations/twilio/incoming_sms/v3.rb +78 -0
- data/app/models/pager_tree/integrations/typeform/v3.rb +43 -0
- data/app/models/pager_tree/integrations/uptime/v3.rb +68 -0
- data/app/models/pager_tree/integrations/uptime_robot/v3.rb +79 -0
- data/app/models/pager_tree/integrations/webhook/v3.rb +112 -0
- data/app/models/pager_tree/integrations/zendesk/v3.rb +83 -0
- data/app/views/pager_tree/integrations/app_dynamics/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/app_dynamics/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/auvik/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/auvik/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/aws_cloudwatch/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/aws_cloudwatch/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/azure_monitor/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/azure_monitor/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/channel/hangouts/v3/_form_options.html.erb +34 -0
- data/app/views/pager_tree/integrations/channel/hangouts/v3/_show_options.html.erb +40 -0
- data/app/views/pager_tree/integrations/channel/mattermost/v3/_form_options.html.erb +1 -0
- data/app/views/pager_tree/integrations/channel/mattermost/v3/_show_options.html.erb +1 -0
- data/app/views/pager_tree/integrations/channel/microsoft_teams/v3/_form_options.html.erb +34 -0
- data/app/views/pager_tree/integrations/channel/microsoft_teams/v3/_show_options.html.erb +40 -0
- data/app/views/pager_tree/integrations/channel/slack/v3/_form_options.html.erb +34 -0
- data/app/views/pager_tree/integrations/channel/slack/v3/_show_options.html.erb +40 -0
- data/app/views/pager_tree/integrations/cronitor/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/cronitor/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/datadog/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/datadog/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/dead_mans_snitch/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/dead_mans_snitch/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/elast_alert/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/elast_alert/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/form/v3/_form_options.html.erb +64 -0
- data/app/views/pager_tree/integrations/form/v3/_show_options.html.erb +122 -0
- data/app/views/pager_tree/integrations/freshdesk/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/freshdesk/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/freshservice/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/freshservice/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/grafana/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/grafana/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/healthchecks/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/healthchecks/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/honeybadger/v3/_form_options.html.erb +7 -0
- data/app/views/pager_tree/integrations/honeybadger/v3/_show_options.html.erb +12 -0
- data/app/views/pager_tree/integrations/hyperping/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/hyperping/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/jira_server/v3/_form_options.html.erb +7 -0
- data/app/views/pager_tree/integrations/jira_server/v3/_show_options.html.erb +12 -0
- data/app/views/pager_tree/integrations/jotform/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/jotform/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/kapacitor/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/kapacitor/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/logic_monitor/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/logic_monitor/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/mattermost/outgoing_webhook/v3/_form_options.html.erb +7 -0
- data/app/views/pager_tree/integrations/mattermost/outgoing_webhook/v3/_show_options.html.erb +12 -0
- data/app/views/pager_tree/integrations/new_relic/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/new_relic/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/outgoing_webhook/v3/_form_options.html.erb +12 -4
- data/app/views/pager_tree/integrations/outgoing_webhook/v3/_show_options.html.erb +20 -2
- data/app/views/pager_tree/integrations/pingdom/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/pingdom/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/prometheus/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/prometheus/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/prtg/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/prtg/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/server_guard24/v3/_form_options.html.erb +7 -0
- data/app/views/pager_tree/integrations/server_guard24/v3/_show_options.html.erb +12 -0
- data/app/views/pager_tree/integrations/site24x7/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/site24x7/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/solar_winds/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/solar_winds/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/stackdriver/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/stackdriver/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/status_cake/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/status_cake/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/twilio/incoming_sms/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/twilio/incoming_sms/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/typeform/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/typeform/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/uptime/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/uptime/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/uptime_robot/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/uptime_robot/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/webhook/v3/_form_options.html.erb +15 -0
- data/app/views/pager_tree/integrations/webhook/v3/_show_options.html.erb +26 -0
- data/app/views/pager_tree/integrations/zendesk/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/zendesk/v3/_show_options.html.erb +0 -0
- data/config/locales/en.yml +83 -23
- data/lib/generators/integration/integration_generator.rb +2 -1
- data/lib/generators/integration/templates/model.rb.tt +16 -6
- data/lib/pager_tree/integrations/version.rb +1 -1
- metadata +121 -3
@@ -0,0 +1,65 @@
|
|
1
|
+
module PagerTree::Integrations
|
2
|
+
class Kapacitor::V3 < Integration
|
3
|
+
OPTIONS = []
|
4
|
+
store_accessor :options, *OPTIONS.map { |x| x[:key] }.map(&:to_s), prefix: "option"
|
5
|
+
|
6
|
+
after_initialize do
|
7
|
+
end
|
8
|
+
|
9
|
+
def adapter_supports_incoming?
|
10
|
+
true
|
11
|
+
end
|
12
|
+
|
13
|
+
def adapter_supports_outgoing?
|
14
|
+
false
|
15
|
+
end
|
16
|
+
|
17
|
+
def adapter_incoming_can_defer?
|
18
|
+
true
|
19
|
+
end
|
20
|
+
|
21
|
+
def adapter_thirdparty_id
|
22
|
+
adapter_incoming_request_params.dig("id")
|
23
|
+
end
|
24
|
+
|
25
|
+
def adapter_action
|
26
|
+
adapter_incoming_request_params.dig("level") == "OK" ? :resolve : :create
|
27
|
+
end
|
28
|
+
|
29
|
+
def adapter_process_create
|
30
|
+
Alert.new(
|
31
|
+
title: _title,
|
32
|
+
description: _description,
|
33
|
+
urgency: _urgency,
|
34
|
+
thirdparty_id: adapter_thirdparty_id,
|
35
|
+
dedup_keys: [adapter_thirdparty_id],
|
36
|
+
additional_data: _additional_datums
|
37
|
+
)
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def _title
|
43
|
+
adapter_incoming_request_params.dig("message")
|
44
|
+
end
|
45
|
+
|
46
|
+
def _description
|
47
|
+
adapter_incoming_request_params.dig("details")
|
48
|
+
end
|
49
|
+
|
50
|
+
def _urgency
|
51
|
+
case adapter_incoming_request_params.dig("level")
|
52
|
+
when "INFO"
|
53
|
+
"low"
|
54
|
+
when "WARN"
|
55
|
+
"medium"
|
56
|
+
when "CRITICAL"
|
57
|
+
"critical"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def _additional_datums
|
62
|
+
[]
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
module PagerTree::Integrations
|
2
|
+
class LogicMonitor::V3 < Integration
|
3
|
+
OPTIONS = []
|
4
|
+
store_accessor :options, *OPTIONS.map { |x| x[:key] }.map(&:to_s), prefix: "option"
|
5
|
+
|
6
|
+
after_initialize do
|
7
|
+
end
|
8
|
+
|
9
|
+
def adapter_supports_incoming?
|
10
|
+
true
|
11
|
+
end
|
12
|
+
|
13
|
+
def adapter_supports_outgoing?
|
14
|
+
false
|
15
|
+
end
|
16
|
+
|
17
|
+
def adapter_incoming_can_defer?
|
18
|
+
true
|
19
|
+
end
|
20
|
+
|
21
|
+
def adapter_thirdparty_id
|
22
|
+
adapter_incoming_request_params.dig("alertid")
|
23
|
+
end
|
24
|
+
|
25
|
+
def adapter_action
|
26
|
+
alert_status = adapter_incoming_request_params.dig("alertstatus")
|
27
|
+
case alert_status
|
28
|
+
when "active", "test"
|
29
|
+
:create
|
30
|
+
# when "ack"
|
31
|
+
# :acknowledge
|
32
|
+
when "clear"
|
33
|
+
:resolve
|
34
|
+
else
|
35
|
+
:other
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def adapter_process_create
|
40
|
+
Alert.new(
|
41
|
+
title: _title,
|
42
|
+
description: _description,
|
43
|
+
urgency: _urgency,
|
44
|
+
thirdparty_id: adapter_thirdparty_id,
|
45
|
+
dedup_keys: [adapter_thirdparty_id],
|
46
|
+
additional_data: _additional_datums
|
47
|
+
)
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def _title
|
53
|
+
adapter_incoming_request_params.dig("eventmsg")
|
54
|
+
end
|
55
|
+
|
56
|
+
def _description
|
57
|
+
adapter_incoming_request_params.dig("eventlogmsg")
|
58
|
+
end
|
59
|
+
|
60
|
+
def _urgency
|
61
|
+
level = adapter_incoming_request_params.dig("level").to_s.downcase
|
62
|
+
case level
|
63
|
+
when "warn", "warning"
|
64
|
+
"medium"
|
65
|
+
when "error"
|
66
|
+
"high"
|
67
|
+
when "critical"
|
68
|
+
"critical"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def _additional_datums
|
73
|
+
[
|
74
|
+
AdditionalDatum.new(format: "text", label: "Host", value: adapter_incoming_request_params.dig("host")),
|
75
|
+
AdditionalDatum.new(format: "text", label: "Service", value: adapter_incoming_request_params.dig("service"))
|
76
|
+
]
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
module PagerTree::Integrations
|
2
|
+
class Mattermost::OutgoingWebhook::V3 < Integration
|
3
|
+
OPTIONS = [
|
4
|
+
{key: :token, type: :string, default: nil}
|
5
|
+
]
|
6
|
+
store_accessor :options, *OPTIONS.map { |x| x[:key] }.map(&:to_s), prefix: "option"
|
7
|
+
|
8
|
+
after_initialize do
|
9
|
+
self.option_token ||= nil
|
10
|
+
end
|
11
|
+
|
12
|
+
def adapter_should_block_incoming?(request)
|
13
|
+
self.option_token.present? && (request.params["token"] != self.option_token)
|
14
|
+
end
|
15
|
+
|
16
|
+
def adapter_supports_incoming?
|
17
|
+
true
|
18
|
+
end
|
19
|
+
|
20
|
+
def adapter_supports_outgoing?
|
21
|
+
false
|
22
|
+
end
|
23
|
+
|
24
|
+
def adapter_incoming_can_defer?
|
25
|
+
true
|
26
|
+
end
|
27
|
+
|
28
|
+
def adapter_thirdparty_id
|
29
|
+
"#{adapter_incoming_request_params.dig("channel_id")}.#{adapter_incoming_request_params.dig("timestamp")}"
|
30
|
+
end
|
31
|
+
|
32
|
+
def adapter_action
|
33
|
+
:create
|
34
|
+
end
|
35
|
+
|
36
|
+
def adapter_process_create
|
37
|
+
Alert.new(
|
38
|
+
title: _title,
|
39
|
+
urgency: _urgency,
|
40
|
+
thirdparty_id: adapter_thirdparty_id,
|
41
|
+
dedup_keys: [adapter_thirdparty_id],
|
42
|
+
additional_data: _additional_datums
|
43
|
+
)
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def _title
|
49
|
+
adapter_incoming_request_params.dig("text")
|
50
|
+
end
|
51
|
+
|
52
|
+
def _urgency
|
53
|
+
text = adapter_incoming_request_params.dig("text").to_s
|
54
|
+
match = text.match(/low|medium|high|critical/i).try("[]", 0)
|
55
|
+
match&.downcase!
|
56
|
+
|
57
|
+
case match
|
58
|
+
when "low"
|
59
|
+
"low"
|
60
|
+
when "medium"
|
61
|
+
"medium"
|
62
|
+
when "high"
|
63
|
+
"high"
|
64
|
+
when "critical"
|
65
|
+
"critical"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def _additional_datums
|
70
|
+
[
|
71
|
+
AdditionalDatum.new(format: "text", label: "Trigger", value: adapter_incoming_request_params.dig("trigger_word")),
|
72
|
+
AdditionalDatum.new(format: "text", label: "Channel", value: adapter_incoming_request_params.dig("channel_name")),
|
73
|
+
AdditionalDatum.new(format: "text", label: "User", value: adapter_incoming_request_params.dig("user_name"))
|
74
|
+
]
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module PagerTree::Integrations
|
2
|
+
class NewRelic::V3 < Integration
|
3
|
+
OPTIONS = []
|
4
|
+
store_accessor :options, *OPTIONS.map { |x| x[:key] }.map(&:to_s), prefix: "option"
|
5
|
+
|
6
|
+
after_initialize do
|
7
|
+
end
|
8
|
+
|
9
|
+
def adapter_supports_incoming?
|
10
|
+
true
|
11
|
+
end
|
12
|
+
|
13
|
+
def adapter_supports_outgoing?
|
14
|
+
false
|
15
|
+
end
|
16
|
+
|
17
|
+
def adapter_incoming_can_defer?
|
18
|
+
true
|
19
|
+
end
|
20
|
+
|
21
|
+
def adapter_thirdparty_id
|
22
|
+
adapter_incoming_request_params.dig("incident_id")
|
23
|
+
end
|
24
|
+
|
25
|
+
def adapter_action
|
26
|
+
event_type = adapter_incoming_request_params.dig("event_type")
|
27
|
+
current_state = adapter_incoming_request_params.dig("current_state")
|
28
|
+
|
29
|
+
if event_type == "INCIDENT_OPEN" || (event_type == "INCIDENT" && current_state == "open")
|
30
|
+
:create
|
31
|
+
# elsif event_type == "INCIDENT_ACKNOWLEDGED" || (event_type == "INCIDENT" && current_state == "acknowledged")
|
32
|
+
# :acknowledge
|
33
|
+
elsif event_type == "INCIDENT_RESOLVED" || (event_type == "INCIDENT" && current_state == "closed")
|
34
|
+
:resolve
|
35
|
+
else
|
36
|
+
:other
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def adapter_process_create
|
41
|
+
Alert.new(
|
42
|
+
title: _title,
|
43
|
+
description: _description,
|
44
|
+
thirdparty_id: adapter_thirdparty_id,
|
45
|
+
dedup_keys: [adapter_thirdparty_id],
|
46
|
+
additional_data: _additional_datums
|
47
|
+
)
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def _title
|
53
|
+
adapter_incoming_request_params.dig("condition_name")
|
54
|
+
end
|
55
|
+
|
56
|
+
def _description
|
57
|
+
adapter_incoming_request_params.dig("details")
|
58
|
+
end
|
59
|
+
|
60
|
+
def _additional_datums
|
61
|
+
[
|
62
|
+
AdditionalDatum.new(format: "text", label: "Account Name", value: adapter_incoming_request_params.dig("account_name")),
|
63
|
+
AdditionalDatum.new(format: "text", label: "Incident URL", value: adapter_incoming_request_params.dig("incident_url"))
|
64
|
+
]
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -7,6 +7,7 @@ module PagerTree::Integrations
|
|
7
7
|
attr_accessor :event_name
|
8
8
|
attr_accessor :item
|
9
9
|
attr_accessor :changes
|
10
|
+
attr_accessor :outgoing_rules_data
|
10
11
|
|
11
12
|
define_model_callbacks :initialize
|
12
13
|
|
@@ -20,6 +21,7 @@ module PagerTree::Integrations
|
|
20
21
|
self.event_name ||= nil
|
21
22
|
self.item ||= nil
|
22
23
|
self.changes ||= nil
|
24
|
+
self.outgoing_rules_data ||= {}
|
23
25
|
end
|
24
26
|
end
|
25
27
|
end
|
@@ -13,7 +13,8 @@ module PagerTree::Integrations
|
|
13
13
|
{key: :alert_dropped, type: :boolean, default: false},
|
14
14
|
{key: :alert_handoff, type: :boolean, default: false},
|
15
15
|
{key: :template, type: :string, default: nil},
|
16
|
-
{key: :send_linked, type: :boolean, default: false}
|
16
|
+
{key: :send_linked, type: :boolean, default: false},
|
17
|
+
{key: :outgoing_rules, type: :string, default: nil}
|
17
18
|
]
|
18
19
|
store_accessor :options, *OPTIONS.map { |x| x[:key] }.map(&:to_s), prefix: "option"
|
19
20
|
|
@@ -39,6 +40,7 @@ module PagerTree::Integrations
|
|
39
40
|
self.option_alert_handoff ||= false
|
40
41
|
self.option_send_linked ||= false
|
41
42
|
self.option_template ||= ""
|
43
|
+
self.option_outgoing_rules ||= ""
|
42
44
|
end
|
43
45
|
|
44
46
|
def adapter_supports_outgoing?
|
@@ -49,20 +51,49 @@ module PagerTree::Integrations
|
|
49
51
|
true
|
50
52
|
end
|
51
53
|
|
54
|
+
def adapter_supports_title_template?
|
55
|
+
false
|
56
|
+
end
|
57
|
+
|
58
|
+
def adapter_supports_description_template?
|
59
|
+
false
|
60
|
+
end
|
61
|
+
|
52
62
|
def adapter_outgoing_interest?(event_name)
|
53
63
|
try("option_#{event_name}") || false
|
54
64
|
end
|
55
65
|
|
56
66
|
def adapter_process_outgoing
|
57
|
-
body =
|
58
|
-
|
59
|
-
|
67
|
+
body = nil
|
68
|
+
event_type = adapter_outgoing_event.event_name.to_s.tr("_", ".")
|
69
|
+
|
70
|
+
# Do the custom templating portion for outgoing hooks
|
71
|
+
if self.option_template.present?
|
72
|
+
begin
|
73
|
+
body = JSON.parse(handlebars(self.option_template, {
|
74
|
+
alert: adapter_outgoing_event.item.try(:v3_format) || adapter_outgoing_event.item,
|
75
|
+
event: {
|
76
|
+
type: event_type
|
77
|
+
}
|
78
|
+
}))
|
79
|
+
rescue JSON::ParserError => e
|
80
|
+
logs.create(message: "Error parsing JSON, abort custom format for option template. Error: #{e.message}")
|
81
|
+
rescue => e
|
82
|
+
Rails.logger.error "Error while processing option_template for #{id}: #{e.message}"
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
body ||= {
|
87
|
+
data: adapter_outgoing_event.item.try(:v3_format) || adapter_outgoing_event.item,
|
88
|
+
type: event_type
|
60
89
|
}
|
61
90
|
|
62
|
-
|
91
|
+
url = adapter_outgoing_event.outgoing_rules_data.dig("webhook_url") || option_webhook_url
|
92
|
+
body.merge!(adapter_outgoing_event.outgoing_rules_data.except("webhook_url"))
|
93
|
+
|
63
94
|
outgoing_webhook_delivery = OutgoingWebhookDelivery.factory(
|
64
95
|
resource: self,
|
65
|
-
url:
|
96
|
+
url: url,
|
66
97
|
auth: {username: option_username, password: option_password},
|
67
98
|
body: body
|
68
99
|
)
|
@@ -40,8 +40,8 @@ module PagerTree::Integrations
|
|
40
40
|
pagertree_options = {
|
41
41
|
headers: {
|
42
42
|
Accept: "*/*",
|
43
|
-
|
44
|
-
|
43
|
+
"User-Agent": "pagertree outgoing webhook service; ref: #{resource&.id}; report: support@pagertree.com",
|
44
|
+
"Content-Type": "application/json"
|
45
45
|
}
|
46
46
|
}
|
47
47
|
|
@@ -77,18 +77,20 @@ module PagerTree::Integrations
|
|
77
77
|
|
78
78
|
options = {
|
79
79
|
headers: {
|
80
|
-
|
80
|
+
"Content-Type": "application/json",
|
81
81
|
Authorization: "Bearer #{OutgoingWebhookDelivery::HookRelay.hook_relay_api_key}"
|
82
82
|
},
|
83
83
|
timeout: 15
|
84
84
|
}
|
85
85
|
|
86
|
-
|
87
|
-
@delivery
|
86
|
+
response = ::HTTParty.get(hook_relay_delivery_url, **options)
|
87
|
+
@delivery = response.parsed_response if response.success?
|
88
|
+
|
89
|
+
@delivery || {}
|
88
90
|
end
|
89
91
|
|
90
92
|
def request
|
91
|
-
delivery&.dig("request")
|
93
|
+
delivery&.dig("request") || {}
|
92
94
|
end
|
93
95
|
|
94
96
|
def responses
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module PagerTree::Integrations
|
2
|
+
class Pingdom::V3 < Integration
|
3
|
+
OPTIONS = []
|
4
|
+
store_accessor :options, *OPTIONS.map { |x| x[:key] }.map(&:to_s), prefix: "option"
|
5
|
+
|
6
|
+
after_initialize do
|
7
|
+
end
|
8
|
+
|
9
|
+
def adapter_supports_incoming?
|
10
|
+
true
|
11
|
+
end
|
12
|
+
|
13
|
+
def adapter_supports_outgoing?
|
14
|
+
false
|
15
|
+
end
|
16
|
+
|
17
|
+
def adapter_incoming_can_defer?
|
18
|
+
true
|
19
|
+
end
|
20
|
+
|
21
|
+
def adapter_thirdparty_id
|
22
|
+
adapter_incoming_request_params.dig("check_id")
|
23
|
+
end
|
24
|
+
|
25
|
+
def adapter_action
|
26
|
+
previous_state = adapter_incoming_request_params.dig("previous_state")
|
27
|
+
current_state = adapter_incoming_request_params.dig("current_state")
|
28
|
+
|
29
|
+
if (previous_state == "UP" && current_state == "DOWN") || (previous_state == "SUCCESS" && current_state == "FAILING")
|
30
|
+
:create
|
31
|
+
elsif (previous_state == "DOWN" && current_state == "UP") || (previous_state == "FAILING" && current_state == "SUCCESS")
|
32
|
+
:resolve
|
33
|
+
else
|
34
|
+
:other
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def adapter_process_create
|
39
|
+
Alert.new(
|
40
|
+
title: _title,
|
41
|
+
description: _description,
|
42
|
+
thirdparty_id: adapter_thirdparty_id,
|
43
|
+
dedup_keys: [adapter_thirdparty_id],
|
44
|
+
additional_data: _additional_datums,
|
45
|
+
tags: _tags
|
46
|
+
)
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def _title
|
52
|
+
[adapter_incoming_request_params.dig("check_name"), adapter_incoming_request_params.dig("current_state")].join(" ")
|
53
|
+
end
|
54
|
+
|
55
|
+
def _description
|
56
|
+
adapter_incoming_request_params.dig("description")
|
57
|
+
end
|
58
|
+
|
59
|
+
def _tags
|
60
|
+
adapter_incoming_request_params.dig("tags") || []
|
61
|
+
end
|
62
|
+
|
63
|
+
def _additional_datums
|
64
|
+
[
|
65
|
+
AdditionalDatum.new(format: "link", label: "Full URL", value: adapter_incoming_request_params.dig("check_params", "full_url")),
|
66
|
+
AdditionalDatum.new(format: "text", label: "Importance Level", value: adapter_incoming_request_params.dig("importance_level")),
|
67
|
+
AdditionalDatum.new(format: "text", label: "Custom Message", value: adapter_incoming_request_params.dig("custom_message"))
|
68
|
+
]
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
module PagerTree::Integrations
|
2
|
+
class Prometheus::V3 < Integration
|
3
|
+
OPTIONS = []
|
4
|
+
store_accessor :options, *OPTIONS.map { |x| x[:key] }.map(&:to_s), prefix: "option"
|
5
|
+
|
6
|
+
after_initialize do
|
7
|
+
end
|
8
|
+
|
9
|
+
def adapter_supports_incoming?
|
10
|
+
true
|
11
|
+
end
|
12
|
+
|
13
|
+
def adapter_supports_outgoing?
|
14
|
+
false
|
15
|
+
end
|
16
|
+
|
17
|
+
def adapter_incoming_can_defer?
|
18
|
+
true
|
19
|
+
end
|
20
|
+
|
21
|
+
def adapter_thirdparty_id
|
22
|
+
adapter_incoming_request_params.dig("groupKey")
|
23
|
+
end
|
24
|
+
|
25
|
+
def adapter_action
|
26
|
+
case adapter_incoming_request_params.dig("status")
|
27
|
+
when "firing"
|
28
|
+
:create
|
29
|
+
when "resolved"
|
30
|
+
:resolve
|
31
|
+
else
|
32
|
+
:other
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def adapter_process_create
|
37
|
+
Alert.new(
|
38
|
+
title: _title,
|
39
|
+
description: _description,
|
40
|
+
urgency: _urgency,
|
41
|
+
thirdparty_id: adapter_thirdparty_id,
|
42
|
+
dedup_keys: [adapter_thirdparty_id],
|
43
|
+
additional_data: _additional_datums
|
44
|
+
)
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def _title
|
50
|
+
adapter_incoming_request_params.dig("commonLabels", "alertname") || ["Prometheus", adapter_incoming_request_params.dig("receiver"), "firing"].compact_blank.join(" ")
|
51
|
+
end
|
52
|
+
|
53
|
+
def _description
|
54
|
+
adapter_incoming_request_params.dig("commonAnnotations", "summary")
|
55
|
+
end
|
56
|
+
|
57
|
+
def _urgency
|
58
|
+
case adapter_incoming_request_params.dig("commonLabels", "severity")
|
59
|
+
when "low"
|
60
|
+
"low"
|
61
|
+
when "medium"
|
62
|
+
"medium"
|
63
|
+
when "high"
|
64
|
+
"high"
|
65
|
+
when "critical"
|
66
|
+
"critical"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def _additional_datums
|
71
|
+
[
|
72
|
+
AdditionalDatum.new(format: "link", label: "Alert Manager URL", value: adapter_incoming_request_params.dig("externalURL")),
|
73
|
+
AdditionalDatum.new(format: "text", label: "Receiver", value: adapter_incoming_request_params.dig("receiver"))
|
74
|
+
] + adapter_incoming_request_params.dig("commonLabels").map do |key, value|
|
75
|
+
AdditionalDatum.new(format: "text", label: key, value: value.to_s)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module PagerTree::Integrations
|
2
|
+
class Prtg::V3 < Integration
|
3
|
+
OPTIONS = []
|
4
|
+
store_accessor :options, *OPTIONS.map { |x| x[:key] }.map(&:to_s), prefix: "option"
|
5
|
+
|
6
|
+
after_initialize do
|
7
|
+
end
|
8
|
+
|
9
|
+
def adapter_supports_incoming?
|
10
|
+
true
|
11
|
+
end
|
12
|
+
|
13
|
+
def adapter_supports_outgoing?
|
14
|
+
false
|
15
|
+
end
|
16
|
+
|
17
|
+
def adapter_incoming_can_defer?
|
18
|
+
true
|
19
|
+
end
|
20
|
+
|
21
|
+
def adapter_thirdparty_id
|
22
|
+
adapter_incoming_request_params.dig("sensorid")
|
23
|
+
end
|
24
|
+
|
25
|
+
def adapter_action
|
26
|
+
status = adapter_incoming_request_params.dig("status").to_s.downcase
|
27
|
+
|
28
|
+
if status == "down"
|
29
|
+
:create
|
30
|
+
elsif status.include?("now: up")
|
31
|
+
:resolve
|
32
|
+
else
|
33
|
+
:other
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def adapter_process_create
|
38
|
+
Alert.new(
|
39
|
+
title: _title,
|
40
|
+
thirdparty_id: adapter_thirdparty_id,
|
41
|
+
dedup_keys: [adapter_thirdparty_id],
|
42
|
+
additional_data: _additional_datums
|
43
|
+
)
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def _title
|
49
|
+
"Sensor #{adapter_incoming_request_params.dig("sensorid")} #{adapter_incoming_request_params.dig("sensor")} is DOWN"
|
50
|
+
end
|
51
|
+
|
52
|
+
def _additional_datums
|
53
|
+
adapter_incoming_request_params.map do |key, value|
|
54
|
+
AdditionalDatum.new(format: "text", label: key, value: value.to_s)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|