You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Opencanary is throwing errors and ends up crashing at startup, I think because of json structure for the data of the POST request.
Here's the log message :
{"dst_host": "", "dst_port": -1, "local_time": "2024-12-18 08:26:13.691166", "local_time_adjusted": "2024-12-18 08:26:13.691433", "logdata": {"msg": {"logdata": "Added service from class CanaryGit in opencanary.modules.git to fake"}}, "logtype": 1001, "node_id": "opencanary-vm-honey", "src_host": "", "src_port": -1, "utc_time": "2024-12-18 08:26:13.691200"}
{"dst_host": "", "dst_port": -1, "local_time": "2024-12-18 08:26:13.824122", "local_time_adjusted": "2024-12-18 08:26:13.824157", "logdata": {"msg": {"logdata": "Failed to add service from class CanaryGit in opencanary.modules.git. Traceback (most recent call last):\n File \"/opt/opencanary/bin/opencanary.tac\", line 135, in start_mod\n logMsg({\"logdata\": msg})\n File \"/opt/opencanary/bin/opencanary.tac\", line 154, in logMsg\n logger.log(data, retry=False)\n File \"/opt/opencanary/lib/python3.11/site-packages/opencanary/logger.py\", line 188, in log\n self.logger.warn(json.dumps(logdata, sort_keys=True))\n File \"/usr/lib/python3.11/logging/__init__.py\", line 1506, in warn\n self.warning(msg, *args, **kwargs)\n File \"/usr/lib/python3.11/logging/__init__.py\", line 1501, in warning\n self._log(WARNING, msg, args, **kwargs)\n File \"/usr/lib/python3.11/logging/__init__.py\", line 1634, in _log\n self.handle(record)\n File \"/usr/lib/python3.11/logging/__init__.py\", line 1644, in handle\n self.callHandlers(record)\n File \"/usr/lib/python3.11/logging/__init__.py\", line 1706, in callHandlers\n hdlr.handle(record)\n File \"/usr/lib/python3.11/logging/__init__.py\", line 978, in handle\n self.emit(record)\n File \"/opt/opencanary/lib/python3.11/site-packages/opencanary/logger.py\", line 353, in emit\n if any(e in message for e in self.ignore):\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/opt/opencanary/lib/python3.11/site-packages/opencanary/logger.py\", line 353, in <genexpr>\n if any(e in message for e in self.ignore):\n ^^^^^^^^^^^^\nTypeError: 'in <string>' requires string as left operand, not list\n"}}, "logtype": 1001, "node_id": "opencanary-vm-honey", "src_host": "", "src_port": -1, "utc_time": "2024-12-18 08:26:13.824152"}
Here's the config file generated by ansible template :
error will pop on any opencanary module : if i disable one, it just crashes the same on the next module.
If i change the data of the POST request so that it's not in an array : "data": {"status":"firing","labels":{"alertname":"opencanary","severity":"critical"},"annotations":{"summary":"Honey pot Alert from Opencanary","description":"%(message)s"}}
Then opencanary is not crashing anymore but alertmanager receives nothing as the data structure is not what is expected.
I tried modifying the ansible template to force add a header content-type: application/json but I get the same behavior.
Describe the bug
Hi, I'm trying to configure opencanary webhook handler to send an alert to alertmanager through a POST on /api/v2/alerts endpoint.
I've installed opencanary on a VM with this ansible role : https://github.com/thinkst/ansible-role-opencanary
Opencanary is throwing errors and ends up crashing at startup, I think because of json structure for the data of the POST request.
Here's the log message :
Here's the config file generated by ansible template :
Things i've noticed :
"data": {"status":"firing","labels":{"alertname":"opencanary","severity":"critical"},"annotations":{"summary":"Honey pot Alert from Opencanary","description":"%(message)s"}}
Then opencanary is not crashing anymore but alertmanager receives nothing as the data structure is not what is expected.
content-type: application/json
but I get the same behavior.Alertmanager json format : https://prometheus.io/docs/alerting/latest/clients/#sending-alerts
The text was updated successfully, but these errors were encountered: