From a6074cf166a74a74463e26d68fd537707c3013d3 Mon Sep 17 00:00:00 2001 From: jurgenhaas <juergen@paragon-es.de> Date: Wed, 19 Jun 2019 16:11:16 +0200 Subject: [PATCH] customer/bitegra/mobimo/drupal#240 Implement support for an optional project ID when sending alert from fluentd to alerta --- templates/alertalerta.py | 3 +++ templates/td-agent.conf | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/templates/alertalerta.py b/templates/alertalerta.py index 6d43855..41a46a9 100755 --- a/templates/alertalerta.py +++ b/templates/alertalerta.py @@ -28,6 +28,7 @@ class Alerta: self.parser.add_argument('webhook', help='Alerta webhook') self.parser.add_argument('apikey', help='Alerta API key') self.parser.add_argument('payload', help='Json string or filename') + self.parser.add_argument('--pid', help='Project ID') self.args, self.extras = self.parser.parse_known_args() if os.path.isfile(self.args.payload): @@ -52,6 +53,8 @@ class Alerta: 'value': '', 'rawData': '', } + if 'pid' in self.args: + values['tags'].append('gitlab_project_id:%s' % self.args.pid) return values @staticmethod diff --git a/templates/td-agent.conf b/templates/td-agent.conf index 17a3851..559d0fb 100644 --- a/templates/td-agent.conf +++ b/templates/td-agent.conf @@ -196,7 +196,7 @@ <match alerta> @type exec - command /usr/local/bin/alertalerta.py {{ inventory_hostname }} {{ netdata_alerta_environment|default("production") }} {{ netdata_alerta_webhook }} {{ netdata_alerta_apikey }} + command /usr/local/bin/alertalerta.py{% if netdata_alerta_project_id is defined %} --pid={{ netdata_alerta_project_id }}{% endif %} {{ inventory_hostname }} {{ netdata_alerta_environment|default("production") }} {{ netdata_alerta_webhook }} {{ netdata_alerta_apikey }} <buffer> @type file path /var/log/td-agent/buffer/alerta.*.buffer -- GitLab