{
  "id": "XIPHhh3HU6jfTgyC",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Send N8N Audits and Failed Workflows to InfluxDB",
  "tags": [
    {
      "id": "vfJ7DxaB1BnsVQhe",
      "name": "Public",
      "createdAt": "2025-06-23T09:52:14.318Z",
      "updatedAt": "2025-06-23T09:52:14.318Z"
    }
  ],
  "nodes": [
    {
      "id": "8ed8f8ed-5352-4eb2-a0cf-2dbbc78f2a9a",
      "name": "When clicking \u2018Execute workflow\u2019",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -780,
        220
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "001ca208-f181-4270-be91-e30a316e624b",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        300,
        -120
      ],
      "parameters": {
        "width": 1100,
        "height": 520,
        "content": "## Parse for Influx-understandable data\nInflux sample data sent via CURL is following:\n\ncurl --request POST \\\n\"http://localhost:8086/api/v2/write?org=YOUR_ORG&bucket=YOUR_BUCKET&precision=ns\" \\\n  --header \"Authorization: Token YOUR_API_TOKEN\" \\\n  --header \"Content-Type: text/plain; charset=utf-8\" \\\n  --header \"Accept: application/json\" \\\n  --data-binary '\n    airSensors,sensor_id=TLM0201 temperature=73.97038159354763,humidity=35.23103248356096,co=0.48445310567793615 1630424257000000000\n    airSensors,sensor_id=TLM0202 temperature=75.30007505999716,humidity=35.651929918691714,co=0.5141876544505826 1630424257000000000\n    '\n\nWhat this part does, is it formats data into --data-binary that can be sent into influx"
      },
      "typeVersion": 1
    },
    {
      "id": "e4f3e592-8c71-4c0e-998e-3bb93ee12751",
      "name": "Database Audit",
      "type": "n8n-nodes-base.n8n",
      "position": [
        -180,
        180
      ],
      "parameters": {
        "resource": "audit",
        "operation": "generate",
        "requestOptions": {},
        "additionalOptions": {
          "categories": [
            "database"
          ]
        }
      },
      "credentials": {
        "n8nApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "c719a748-8048-4471-a560-7abfe1249235",
      "name": "Filesystem Audit",
      "type": "n8n-nodes-base.n8n",
      "position": [
        -180,
        360
      ],
      "parameters": {
        "resource": "audit",
        "operation": "generate",
        "requestOptions": {},
        "additionalOptions": {
          "categories": [
            "filesystem"
          ]
        }
      },
      "credentials": {
        "n8nApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "d0b36463-ee8d-4455-bffd-0217dacf3f47",
      "name": "Instance Audit",
      "type": "n8n-nodes-base.n8n",
      "position": [
        -180,
        540
      ],
      "parameters": {
        "resource": "audit",
        "operation": "generate",
        "requestOptions": {},
        "additionalOptions": {
          "categories": [
            "instance"
          ]
        }
      },
      "credentials": {
        "n8nApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "d17b1536-0322-443b-a431-cbb60684e399",
      "name": "Nodes Audit",
      "type": "n8n-nodes-base.n8n",
      "position": [
        -180,
        720
      ],
      "parameters": {
        "resource": "audit",
        "operation": "generate",
        "requestOptions": {},
        "additionalOptions": {
          "categories": [
            "nodes"
          ]
        }
      },
      "credentials": {
        "n8nApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "a0750d26-f5bf-42e1-bd8b-ceb357d1c331",
      "name": "Credentials Audit",
      "type": "n8n-nodes-base.n8n",
      "position": [
        -180,
        0
      ],
      "parameters": {
        "resource": "audit",
        "operation": "generate",
        "requestOptions": {},
        "additionalOptions": {
          "categories": [
            "credentials"
          ]
        }
      },
      "credentials": {
        "n8nApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "11e65615-0b5e-4e36-932b-3f2b335ea937",
      "name": "Split Report Data",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        440,
        200
      ],
      "parameters": {
        "include": "selectedOtherFields",
        "options": {},
        "fieldToSplitOut": "report",
        "fieldsToInclude": "risk, report[0].title"
      },
      "typeVersion": 1
    },
    {
      "id": "55071cff-b94b-4f15-b5ab-42a65ba90ed9",
      "name": "Prepare Influx Input Strings",
      "type": "n8n-nodes-base.set",
      "position": [
        700,
        200
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "a62768f8-431f-48e7-b2a9-95971d9e1dc1",
              "name": "title_key_count",
              "type": "string",
              "value": "={{ $json.report.title.toLowerCase().replaceAll(\" \",\"_\") }}={{ $json.report.location?.length ?? 0 }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "718a1193-1b98-4def-9a29-a81925d67e06",
      "name": "Contactenate with Commas",
      "type": "n8n-nodes-base.summarize",
      "position": [
        960,
        200
      ],
      "parameters": {
        "options": {},
        "fieldsToSummarize": {
          "values": [
            {
              "field": "title_key_count",
              "aggregation": "concatenate"
            }
          ]
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "bf04e182-1028-4e21-930e-8c3097fa060c",
      "name": "Pull Report Data and Risk Credentials",
      "type": "n8n-nodes-base.set",
      "position": [
        60,
        0
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "de836603-6982-4b43-ae85-440f0852cd74",
              "name": "report",
              "type": "array",
              "value": "={{ $json['Credentials Risk Report'].sections }}"
            },
            {
              "id": "012bd4f1-9877-48fb-b5ab-f8e3e1d81dd3",
              "name": "risk",
              "type": "string",
              "value": "={{ $json['Credentials Risk Report'].risk }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "b502d235-ddc4-49ce-8ae6-fdcfab1ca1a9",
      "name": "Pull Report Data and Risk Database",
      "type": "n8n-nodes-base.set",
      "position": [
        60,
        180
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "de836603-6982-4b43-ae85-440f0852cd74",
              "name": "report",
              "type": "array",
              "value": "={{ $json['Database Risk Report'].sections }}"
            },
            {
              "id": "012bd4f1-9877-48fb-b5ab-f8e3e1d81dd3",
              "name": "risk",
              "type": "string",
              "value": "={{ $json['Database Risk Report'].risk }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "fe8dfa8a-6363-49a6-808e-1feed4b627d1",
      "name": "Pull Report Data and Risk Filesystem",
      "type": "n8n-nodes-base.set",
      "position": [
        60,
        360
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "de836603-6982-4b43-ae85-440f0852cd74",
              "name": "report",
              "type": "array",
              "value": "={{ $json['Filesystem Risk Report'].sections }}"
            },
            {
              "id": "012bd4f1-9877-48fb-b5ab-f8e3e1d81dd3",
              "name": "risk",
              "type": "string",
              "value": "={{ $json['Filesystem Risk Report'].risk }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "d47b4d10-3abe-41bc-868e-4b855b9e8052",
      "name": "Pull Report Data and Risk Instance",
      "type": "n8n-nodes-base.set",
      "position": [
        60,
        540
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "de836603-6982-4b43-ae85-440f0852cd74",
              "name": "report",
              "type": "array",
              "value": "={{ $json['Instance Risk Report'].sections }}"
            },
            {
              "id": "012bd4f1-9877-48fb-b5ab-f8e3e1d81dd3",
              "name": "risk",
              "type": "string",
              "value": "={{ $json['Instance Risk Report'].risk }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "14bb0859-d7ca-4177-a833-94cb4c94990e",
      "name": "Pull Report Data and Risk Nodes",
      "type": "n8n-nodes-base.set",
      "position": [
        60,
        720
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "de836603-6982-4b43-ae85-440f0852cd74",
              "name": "report",
              "type": "array",
              "value": "={{ $json['Nodes Risk Report'].sections }}"
            },
            {
              "id": "012bd4f1-9877-48fb-b5ab-f8e3e1d81dd3",
              "name": "risk",
              "type": "string",
              "value": "={{ $json['Nodes Risk Report'].risk }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "852bf036-611c-416e-83d5-e926e38bb8ba",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -280,
        -120
      ],
      "parameters": {
        "color": 7,
        "width": 560,
        "height": 1020,
        "content": "## Get N8N Audits\nGet different type of audits and parse them into format that will be understandable for further processing"
      },
      "typeVersion": 1
    },
    {
      "id": "127908d3-de5e-443b-a920-47569ea890b0",
      "name": "Influx Globals",
      "type": "n8n-nodes-base.set",
      "position": [
        -520,
        60
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "c764e57c-9936-48ad-a496-f6c9fc0e89b8",
              "name": "influx_url",
              "type": "string",
              "value": "https://example.com"
            },
            {
              "id": "a92bc5cc-0a87-4dd7-a49d-5c2584eaa57f",
              "name": "influx_org",
              "type": "string",
              "value": "myorg"
            },
            {
              "id": "c2f8fb92-64a5-4993-97ee-8c69a8c9865a",
              "name": "influx_bucket",
              "type": "string",
              "value": "n8n"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "38b364a6-7d0a-4f63-bbd8-d6bab99515a8",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -560,
        -120
      ],
      "parameters": {
        "color": 4,
        "width": 260,
        "height": 500,
        "content": "## Influx Vars\nYou will need 3 variables:\n- InfluxDB URL\n- Organization\n- Bucket name\nPut it in here"
      },
      "typeVersion": 1
    },
    {
      "id": "545f2f20-0a55-4960-8455-c4e6323ba198",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -920,
        -120
      ],
      "parameters": {
        "color": 5,
        "width": 340,
        "height": 500,
        "content": "## Schedule Audits\nAudits don't need to be run often, but I would recommend it to be run on regular basis. This way you can see real data series in InfluxDB. I think that once a day should be enough, but it depends on your N8N usage of course"
      },
      "typeVersion": 1
    },
    {
      "id": "2beef8e7-7e88-4778-9e54-09dd9c6efca1",
      "name": "Once a Day",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -780,
        60
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 5
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "a3408974-4c32-4900-86cf-111dd3e5f9c6",
      "name": "Get Active Workflows",
      "type": "n8n-nodes-base.n8n",
      "position": [
        -200,
        -460
      ],
      "parameters": {
        "filters": {
          "activeWorkflows": true
        },
        "requestOptions": {}
      },
      "credentials": {
        "n8nApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "ef5c8f0c-07ed-447a-a582-0659fad71972",
      "name": "Get Failed Executions",
      "type": "n8n-nodes-base.n8n",
      "position": [
        -200,
        -300
      ],
      "parameters": {
        "filters": {
          "status": "error"
        },
        "options": {},
        "resource": "execution",
        "returnAll": true,
        "requestOptions": {}
      },
      "credentials": {
        "n8nApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "e842c4bd-a335-4144-b580-c92fc343d804",
      "name": "Count Active",
      "type": "n8n-nodes-base.summarize",
      "position": [
        40,
        -460
      ],
      "parameters": {
        "options": {},
        "fieldsToSummarize": {
          "values": [
            {
              "field": "active"
            }
          ]
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "e0dda14c-6d80-42fe-ae2e-1e79c8b8733b",
      "name": "Count Failed",
      "type": "n8n-nodes-base.summarize",
      "position": [
        40,
        -300
      ],
      "parameters": {
        "options": {},
        "fieldsToSummarize": {
          "values": [
            {
              "field": "id"
            }
          ]
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "a2189f25-d741-434b-bf1d-acf4567239d2",
      "name": "Merge Into One Reporting Line",
      "type": "n8n-nodes-base.merge",
      "position": [
        300,
        -440
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineByPosition"
      },
      "typeVersion": 3.2
    },
    {
      "id": "104c9d98-1d76-44c6-962e-433761e8a14f",
      "name": "Adjust Field Name",
      "type": "n8n-nodes-base.set",
      "position": [
        540,
        -440
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "a7e43bc0-7e7a-4095-855f-3d9c885180c6",
              "name": "title_key_count",
              "type": "string",
              "value": "=active_workflows={{ $json.count_active }},failed_executions={{ $json.count_id }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "006dbe41-daab-46b4-bdf7-17af73878f80",
      "name": "Send Workflows and Fails to InfluxDB",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        800,
        -440
      ],
      "parameters": {
        "url": "={{ $('Influx Globals').item.json.influx_url }}/api/v2/write?org={{ $('Influx Globals').item.json.influx_org }}&bucket={{ $('Influx Globals').item.json.influx_bucket }}&precision=ms",
        "body": "=audit,operational=workflows_and_failed {{ $json.title_key_count }} {{ $now.toMillis() }}",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "raw",
        "sendHeaders": true,
        "authentication": "genericCredentialType",
        "rawContentType": "text/plain; charset=utf-8",
        "genericAuthType": "httpHeaderAuth",
        "headerParameters": {
          "parameters": [
            {
              "name": "Accept",
              "value": "application/json"
            }
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "260f51c8-f69b-4b09-96ee-23a9c83b5ac3",
      "name": "Send Audit to InfluxDB",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1200,
        200
      ],
      "parameters": {
        "url": "={{ $('Influx Globals').item.json.influx_url }}/api/v2/write?org={{ $('Influx Globals').item.json.influx_org }}&bucket={{ $('Influx Globals').item.json.influx_bucket }}&precision=ms",
        "body": "=audit,risk={{ $('Split Report Data').first().json.risk }} {{ $json.concatenated_title_key_count }} {{ $now.toMillis() }}",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "raw",
        "sendHeaders": true,
        "authentication": "genericCredentialType",
        "rawContentType": "text/plain; charset=utf-8",
        "genericAuthType": "httpHeaderAuth",
        "headerParameters": {
          "parameters": [
            {
              "name": "Accept",
              "value": "application/json"
            }
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "4830f6e4-efbc-4476-a515-1c4afaf6d5ec",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -280,
        -580
      ],
      "parameters": {
        "color": 3,
        "width": 1280,
        "height": 440,
        "content": "## Active Worfklows and Failed Executions\nIf you are feeling advanterous, you can also send data about workflows and executions to Influx. Since there can be a lot of executions, keep in mind to rather count one group (\"failed\") in this example"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "ca8f70df-803e-4b9b-921d-2f2e65a961bb",
  "connections": {
    "Once a Day": {
      "main": [
        [
          {
            "node": "Influx Globals",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Nodes Audit": {
      "main": [
        [
          {
            "node": "Pull Report Data and Risk Nodes",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Count Active": {
      "main": [
        [
          {
            "node": "Merge Into One Reporting Line",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Count Failed": {
      "main": [
        [
          {
            "node": "Merge Into One Reporting Line",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Database Audit": {
      "main": [
        [
          {
            "node": "Pull Report Data and Risk Database",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Influx Globals": {
      "main": [
        [
          {
            "node": "Credentials Audit",
            "type": "main",
            "index": 0
          },
          {
            "node": "Nodes Audit",
            "type": "main",
            "index": 0
          },
          {
            "node": "Database Audit",
            "type": "main",
            "index": 0
          },
          {
            "node": "Filesystem Audit",
            "type": "main",
            "index": 0
          },
          {
            "node": "Instance Audit",
            "type": "main",
            "index": 0
          },
          {
            "node": "Get Failed Executions",
            "type": "main",
            "index": 0
          },
          {
            "node": "Get Active Workflows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Instance Audit": {
      "main": [
        [
          {
            "node": "Pull Report Data and Risk Instance",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filesystem Audit": {
      "main": [
        [
          {
            "node": "Pull Report Data and Risk Filesystem",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Adjust Field Name": {
      "main": [
        [
          {
            "node": "Send Workflows and Fails to InfluxDB",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Credentials Audit": {
      "main": [
        [
          {
            "node": "Pull Report Data and Risk Credentials",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Report Data": {
      "main": [
        [
          {
            "node": "Prepare Influx Input Strings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Active Workflows": {
      "main": [
        [
          {
            "node": "Count Active",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Failed Executions": {
      "main": [
        [
          {
            "node": "Count Failed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Audit to InfluxDB": {
      "main": [
        []
      ]
    },
    "Contactenate with Commas": {
      "main": [
        [
          {
            "node": "Send Audit to InfluxDB",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Influx Input Strings": {
      "main": [
        [
          {
            "node": "Contactenate with Commas",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge Into One Reporting Line": {
      "main": [
        [
          {
            "node": "Adjust Field Name",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Pull Report Data and Risk Nodes": {
      "main": [
        [
          {
            "node": "Split Report Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Pull Report Data and Risk Database": {
      "main": [
        [
          {
            "node": "Split Report Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Pull Report Data and Risk Instance": {
      "main": [
        [
          {
            "node": "Split Report Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Pull Report Data and Risk Filesystem": {
      "main": [
        [
          {
            "node": "Split Report Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking \u2018Execute workflow\u2019": {
      "main": [
        [
          {
            "node": "Influx Globals",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Pull Report Data and Risk Credentials": {
      "main": [
        [
          {
            "node": "Split Report Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}