diff --git a/templates/alertalerta.py b/templates/alertalerta.py
index 6d43855dfb664bf4bf3de247208ad9a8aa33c97e..41a46a901bd77509c1bda8d0dd736e1b892780db 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 17a3851829e8227cc1c1681f038018552b3c1c75..559d0fb3e759b2a0df45f77c902867bda88b6841 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