fluent-plugin-pagerduty
Fluentd Output plugin to relay alert notification from application to PagerDuty.
Installation
install with td-agnet-gem
or fluent-gem
, gem
command as:
# for td-agent2 (recommend)
$ sudo td-agent-gem install fluent-plugin-pagerduty -v 0.0.1
# for td-agent
$ sudo /usr/lib64/fluent/ruby/bin/fluent-gem install fluent-plugin-pagerduty -v 0.0.1
# for system installed fluentd
$ gem install fluent-plugin-pagerduty
Usage
- add service selecting
Service Type : Generic API system
on PagerDuty websites - copy API Key from the
Services
page. - install fluent-plugin-pagerduty with gem or fluent-gem command.
- create fluentd configuration like below.
- restart fluentd process.
- send test message for fluent-plugin-pagerduty
Examples
Simple alert (JSON pass-thru)
In this example, a JSON record already conforming to the PagerDuty API is processed by Fluentd and passed through to PagerDuty as-is, triggering a simple alert.
<source>
@type forward
</source>
<source>
@type http
port 8888
</source>
<match notify.pagerduty>
type pagerduty
service_key ******************
</match>
# via forward
$ echo '{"description":"Form validation has failed","details":{"name":"success","mail":"failed"}}' | fluent-cat notify.pagerduty
# via http
$ curl http://localhost:8888/notify.pagerduty -F 'json={"description":"Form validation has failed","details":{"name":"success","mail":"failed"}}'
Advanced alert (transformed JSON)
In this example, a JSON record is referenced to build a PagerDuty event with an incident key for managing de-duplication.
<source>
@type forward
</source>
<source>
@type http
port 8888
</source>
<match notify.pagerduty>
type pagerduty
service_key ******************
description Alarm@${Node["Location"]}:: ${Log["Message"]}
incident_key [${tag_parts[-1]}] ${Log["File"]}:${Log["Line"]}
</match>
# via forward
$ echo '{"Node":{"Location":"Somewhere","IP Address":"10.0.0.1"},"Log":{"Level": "ERROR","File":"FooBar.cpp","Line":42,"Message":"A very important logging message"}}' | fluent-cat notify.pagerduty
# via http
$ curl http://localhost:8888/notify.pagerduty -F 'json={"Node":{"Location":"Somewhere","IP Address":"10.0.0.1"},"Log":{"Level": "ERROR","File":"FooBar.cpp","Line":42,"Message":"A very important logging message"}}'
Option Parameters
-
service_key
(required)The unique API identifier generated for each PagerDuty service belonging to a PagerDuty account. Must be present for any PagerDuty events.
-
event_type
(optional)The PagerDuty event type:
trigger
,acknowledge
, orresolve
. If unspecified, the default istrigger
. -
description
(conditionally required)The message content of a PagerDuty event. PagerDuty event types of
trigger
must contain a description. The content of the description may be built using Placeholders (see next section). -
incident_key
(optional)The identifier used for PagerDuty's de-duplication of events. The content of the incident key may be built using Placeholders (see next section).
Placeholders
These placeholders are available:
- ${…}
-
hashName["key"]
Value ofkey
in named hash -
arrayName[N]
Value at index N in named array -
primitive
Value of named primitivePlaceholders are built recursively and concatenated. For example, a specific value within a hash containing an array of hashes could be referenced as:
${foo["bar"][2]["baz"]}
.
-
- ${tag} Input tag
- ${tag_parts[N]} Input tag splitted by '.' indexed with N such as
${tag_parts[0]}
,${tag_parts[-1]}
.
Placeholder functionality is derived from features of fluent-plugin-record-reformer.
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
TODO
patches welcome!
Copyright
Copyright (c) 2013- Kentaro Yoshida (@yoshi_ken)