Add datadog driver
Change-Id: Id2f0c5cd53da96cc18f80822de713d99dd1f21ed
This commit is contained in:
parent
0715f0a4f8
commit
e568aff26b
@ -12,7 +12,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
|
||||
known_drivers = {
|
||||
'dummy': 'libra.statsd.drivers.dummy.driver.DummyDriver'
|
||||
'dummy': 'libra.statsd.drivers.dummy.driver.DummyDriver',
|
||||
'datadog': 'libra.statsd.driver.dummy.driver.DatadogDriver'
|
||||
}
|
||||
|
||||
|
||||
|
13
libra/statsd/drivers/datadog/__init__.py
Normal file
13
libra/statsd/drivers/datadog/__init__.py
Normal file
@ -0,0 +1,13 @@
|
||||
# Copyright 2013 Hewlett-Packard Development Company, L.P.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
27
libra/statsd/drivers/datadog/driver.py
Normal file
27
libra/statsd/drivers/datadog/driver.py
Normal file
@ -0,0 +1,27 @@
|
||||
# Copyright 2013 Hewlett-Packard Development Company, L.P.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
|
||||
from libra.statsd.drivers.base import AlertDriver
|
||||
from dogapi import dog_http_api as api
|
||||
|
||||
|
||||
class DatadogDriver(AlertDriver):
|
||||
def send_alert(self, message):
|
||||
api.api_key = self.args.datadog_apikey
|
||||
api.application_key = self.args.datadog_appkey
|
||||
title = 'Load balancer failure'
|
||||
text = 'Load balancer failed with message {0} {1}'.format(
|
||||
message, self.args.datadog_message_tail
|
||||
)
|
||||
tags = self.args.datadog_tags.split()
|
||||
api.event_with_response(title, text, tags=tags, alert_type='error')
|
@ -59,6 +59,21 @@ def main():
|
||||
'--api_server', action='append', metavar='HOST:PORT', default=[],
|
||||
help='a list of API servers to connect to'
|
||||
)
|
||||
# Datadog plugin options
|
||||
options.parser.add_argument(
|
||||
'--datadog_api_key', help='API key for datadog alerting'
|
||||
)
|
||||
options.parser.add_argument(
|
||||
'--datadog_app_key', help='Application key for datadog alerting'
|
||||
)
|
||||
options.parser.add_argument(
|
||||
'--datadog_message_tail',
|
||||
help='Text to add at the end of a Datadog alert'
|
||||
)
|
||||
options.parser.add_argument(
|
||||
'--datadog_tags',
|
||||
help='A space separated list of tags for Datadog alerts'
|
||||
)
|
||||
|
||||
args = options.run()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user