{
  "name": "AI Ops Log Analysis API",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "analyze",
        "options": {}
      },
      "name": "Webhook - Input Log",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        460,
        300
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "http://192.168.20.21:11434/v1/chat/completions",
        "sendBody": true,
        "contentType": "json",
        "bodyParameters": {
          "parameters": [
            {
              "name": "model",
              "value": "qwen2.5:7b"
            },
            {
              "name": "messages",
              "value": "={{ [ {\"role\": \"system\", \"content\": \"You are an AIOps engineer. Analyze the provided log and output the result in the following YAML-like format:\\n\\nIncident Summary:\\n[Brief summary of what happened]\\n\\nLikely Cause (confidence: [0.00-1.00]):\\n[The most probable root cause]\\n\\nEvidence:\\n- Error logs: [Key error message extracted from log]\\n- Impact: [Brief impact description]\\n\\nRecommended next step:\\n[Single specific actionable step]\"}, {\"role\": \"user\", \"content\": $json[\"body\"][\"log\"]} ] }}"
            },
            {
              "name": "temperature",
              "value": "={{0.2}}"
            }
          ]
        },
        "options": {}
      },
      "name": "Llama 2 Analysis",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.1,
      "position": [
        680,
        300
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ { \"analysis\": $json[\"choices\"][0][\"message\"][\"content\"] } }}",
        "options": {}
      },
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        900,
        200
      ]
    },
    {
      "parameters": {
        "fromEmail": "your-email@gmail.com",
        "toEmail": "recipient@example.com",
        "subject": "AI Ops Log Analysis",
        "text": "={{$json[\"choices\"][0][\"message\"][\"content\"]}}",
        "options": {}
      },
      "name": "SMTP - Send Analysis",
      "type": "n8n-nodes-base.emailSend",
      "typeVersion": 2,
      "position": [
        900,
        400
      ],
      "credentials": {
        "smtp": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Webhook - Input Log": {
      "main": [
        [
          {
            "node": "Llama 2 Analysis",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Llama 2 Analysis": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          },
          {
            "node": "SMTP - Send Analysis",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}