Webhook de PROXMOX a Telegram
Itops
JFC
(@JF_Car)
Copiar
A partir de PROXMOX 8.3 puedes definir un webhook para tu sistema de notificaciones, con este workflow, puedes recibir un mensaje en telegram con el log en un archivo adjunto.
Creado: 2024-11-30
5 nodos
{
"meta": {
"instanceId": "08b7c45495aaa3612df600822e44f3d213ac41891a4f0921909837df27d3b120"
},
"nodes": [
{
"parameters": {
"chatId": "={{ $json.headers[\"telegram-chatid\"] }}",
"text": "=PROXMOX Notification #{{ $('Webhook').item.json.body.severity }} \nHost: {{ $('Webhook').item.json.headers['proxmox-hostname'] }} \nStorage: {{ $json.body.content.match(/--storage ([^\\s]+)/)[1] }} \n\nTitle: {{ $('Webhook').item.json.body.title.replaceAll('<','(').replaceAll('>',')') }} \n\nTime: {{DateTime.fromSeconds(+ $('Webhook').item.json.body.timestamp, {zone: \"America/Monterrey\"}).toFormat('DDDD - HH:mm:ss')}}\n{{ $json.body.content.split('\\n').find(line => line.startsWith('Total running time:')) }}\n{{ $json.body.content.split('\\n').find(line => line.startsWith('Total size:')) }}\n\n{{ $json.webhookUrl.slice(0, $json.webhookUrl.indexOf('webhook'))}}workflow/{{$workflow.id}}\n",
"additionalFields": {
"appendAttribution": false,
"parse_mode": "HTML"
}
},
"id": "40cdbaed-b6f3-4dde-b843-1882f1de68fa",
"name": "Telegram-send-message",
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.2,
"position": [
780,
380
],
"retryOnFail": true,
"maxTries": 5,
"waitBetweenTries": 5000,
"credentials": {
"telegramApi": {
"id": "5",
"name": "concari_notification_bot"
}
}
},
{
"parameters": {
"operation": "sendDocument",
"chatId": "={{ $('Webhook').item.json.headers['telegram-chatid'] }}",
"binaryData": true,
"binaryPropertyName": "fileContent",
"additionalFields": {
"reply_to_message_id": "={{ $('Telegram-send-message').item.json.result.message_id }}"
}
},
"id": "f5134cc8-42de-4433-8498-1ee31db7e9a5",
"name": "Telegram-send-file",
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.2,
"position": [
1440,
380
],
"retryOnFail": true,
"maxTries": 5,
"waitBetweenTries": 5000,
"credentials": {
"telegramApi": {
"id": "5",
"name": "concari_notification_bot"
}
}
},
{
"parameters": {
"operation": "toText",
"sourceProperty": "content",
"binaryPropertyName": "fileContent",
"options": {
"fileName": "log.txt"
}
},
"id": "06d6fbeb-c5ac-4924-a42e-d3dd6c625300",
"name": "Convert to File",
"type": "n8n-nodes-base.convertToFile",
"typeVersion": 1.1,
"position": [
1220,
380
],
"retryOnFail": true,
"maxTries": 5,
"waitBetweenTries": 5000
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "e1273372-9def-40b4-b5dc-66c5905b9fe2",
"name": "content",
"value": "={{ $('Webhook').item.json.body.content }}",
"type": "string"
}
]
},
"options": {}
},
"id": "dc19ffa8-dbfa-425e-a355-8874fd596083",
"name": "Edit Fields",
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [
1000,
380
]
},
{
"parameters": {
"httpMethod": "POST",
"path": "a3648bd8-5de4-40e2-a974-49abd42d8992",
"options": {}
},
"id": "c0c4a0af-1130-4818-bf0f-6dd11e5ad383",
"name": "Webhook",
"type": "n8n-nodes-base.webhook",
"typeVersion": 2,
"position": [
580,
380
],
"webhookId": "a3648bd8-5de4-40e2-a974-49abd42d8992"
}
],
"connections": {
"Telegram-send-message": {
"main": [
[
{
"node": "Edit Fields",
"type": "main",
"index": 0
}
]
]
},
"Convert to File": {
"main": [
[
{
"node": "Telegram-send-file",
"type": "main",
"index": 0
}
]
]
},
"Edit Fields": {
"main": [
[
{
"node": "Convert to File",
"type": "main",
"index": 0
}
]
]
},
"Webhook": {
"main": [
[
{
"node": "Telegram-send-message",
"type": "main",
"index": 0
}
]
]
}
},
"pinData": {}
}