{
  "name": "NexusOps - Log Analyzer",
  "settings": {},
  "nodes": [
    {
      "parameters": {
        "path": "logs/analyze",
        "options": {}
      },
      "id": "webhook-logs",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        400,
        240
      ]
    },
    {
      "parameters": {
        "url": "https://fs-le-dev-prometheus.finspot.in/loki/api/v1/query_range",
        "method": "GET",
        "queryParameters": {
          "parameters": [
            {
              "name": "query",
              "value": "={{$node[\"Webhook\"].json[\"body\"][\"query\"]}}"
            },
            {
              "name": "limit",
              "value": "100"
            }
          ]
        }
      },
      "id": "query-loki",
      "name": "Query Loki Logs",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.1,
      "position": [
        620,
        240
      ]
    },
    {
      "parameters": {
        "url": "http://ollama.ollama.svc.cluster.local:11434/api/generate",
        "method": "POST",
        "bodyParameters": {
          "parameters": [
            {
              "name": "model",
              "value": "llama3.1:8b"
            },
            {
              "name": "prompt",
              "value": "=Analyze these logs and identify the root cause:\\n{{$node[\"Query Loki Logs\"].json[\"data\"][\"result\"]}}"
            }
          ]
        }
      },
      "id": "ai-analysis",
      "name": "AI Log Analysis",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.1,
      "position": [
        840,
        240
      ]
    },
    {
      "parameters": {
        "options": {
          "responseCode": 200
        },
        "responseBody": "={\"success\": true, \"analysis\": {{$node[\"AI Log Analysis\"].json[\"response\"]}}, \"timestamp\": \"{{$now}}\"}"
      },
      "id": "respond-logs",
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        1060,
        240
      ]
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Query Loki Logs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Query Loki Logs": {
      "main": [
        [
          {
            "node": "AI Log Analysis",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Log Analysis": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}