Skip to content

Push strategy: Direct Sending (2.0)

A flow running inside NiFi calls NiFi's own API and sends the result straight to Splunk's HTTP Event Collector (HEC) — nothing on Splunk's side has to reach NiFi. Not sure this is the strategy you need? See Choosing a collection strategy, which also draws the architecture of both.

Requires both apps already installed (see Install NIFI Monitoring): Nifi Monitoring TA parses the events this flow sends, even though you configure no input inside it for this strategy.

The flow comes in two files, one per NiFi line, because NiFi 2.0 removed the variables the 1.x flow is configured with. The steps are the same for both; where they differ, pick the tab of the NiFi you monitor. For version 1.2 of the apps, see Push strategy (1.2).

1. Configure the HTTP Event Collector (HEC) in Splunk

An HTTP Event Collector (HEC) receives events from NiFi over HTTP or HTTPS.

From the Splunk menu, go to Settings > Data Inputs > HTTP Event Collector and add a new one:

  • Name the data input.
  • Set the sourcetype to Automatic.
  • Set App Context to NIFI Monitoring.
  • Select the index — use a dedicated one, and create it first if it does not exist.

Finishing this creates a Token Value, needed later to configure NiFi's flow.

image image image

Match the HEC's TLS setting, don't turn it off

Splunk ships every new HEC token with Enable SSL on. The flow's InvokeHTTP processors send plain HTTP, so unless one side changes, the mismatch fails as a TCP-level "Connection reset" -- not a clear certificate or authentication error.

Keep the HEC on HTTPS and configure NiFi for it instead: set splunk_hec (below) to https://<host>:8088, and give the Send2Splunk-HEC processor (an InvokeHTTP) under SendHEC an SSL Context Service that trusts Splunk's certificate: a StandardSSLContextService with only Truststore Filename, Truststore Password and Truststore Type filled in.

Turning Enable SSL off under Settings > Data Inputs > HTTP Event Collector > Global Settings is an instance-wide change: it affects every HEC token on this Splunk instance, not only this one, and sends every event and every token in plain text. Only consider it in an isolated test environment you control, never on a shared or production Splunk instance.

2. Import the Flow Definition into NiFi

Import flow_definition/nifi-2.x/NiFiMonitoring.json — not the 1.x one: it loads into a 2.x instance without an error, but several processors come up invalid or fail silently once started.

Drag a process group box onto the canvas. In the Create Process Group dialog, name it and click the small icon next to Name to upload the flow file:

image

Once a file is selected, Parameter Context is replaced by a note that parameters will come from the uploaded flow, and the filename shows under File to upload:

image

Click Add. The process group is created with every processor that needs a still-empty parameter showing invalid — expected until you set them in the next step:

image

Import flow_definition/nifi-1.x/NiFiMonitoring.json.

Drag a process group box onto the canvas, select the import icon in the pop-up, and choose the file.

image

Either way, the process group contains:

  • Monitoring - API
  • Monitoring - Logs
  • Monitoring - ReportingTask
  • SendHEC

3. Configure the flow's settings

The two flows take the same settings:

Setting What it is
instance_name The host the nifi:api:* and nifi:reporting:* events are sent with: the host of this NiFi's row in the instance lookup. Empty uses the node's hostname, which is right for a single NiFi. On a cluster, set it to the cluster's host: the API is polled from one node, the primary, so left empty each event carries whichever node is primary, which changes on every failover and does not match the lookup. The reporting tasks' bulletins and metrics have the same problem: they arrive on whichever node Site-to-Site picks. Logs always carry the node's name
nifi_api_url This instance's REST API, e.g. http://127.0.0.1:8080/nifi-api, with no trailing slash. On a cluster, an address the node's web server listens on (nifi.web.http.host), which is often not 127.0.0.1
nifi_path NiFi's install directory, used to tail its logs. It must end in /, e.g. /opt/nifi/nifi-current/: the flow appends logs to it. On a cluster, the same path on every node
process_groups_list Ids of the process groups to monitor, one per line
processors_list Ids of the processors to monitor, one per line
splunk_hec The Splunk server with the HEC input, e.g. http://<host>:8088, with no trailing slash
splunk_hec_token The token from step 1

Where you set them is what differs:

Importing the 2.x flow creates a parameter context named NiFi Monitoring and attaches it to the process group. Open it with right-click on the process group > Parameters, or from the top-right menu > Parameter Contexts. splunk_hec_token is a sensitive parameter, so NiFi never writes it into an exported flow.

processors_list and process_groups_list ship empty on purpose, and until they have values the two GenerateFlowFile processors stay invalid. That's intended: NiFi refusing to start a processor with an empty required property beats starting one pointed at another installation's component ids.

Right-click on the NiFiMonitoring box > Variables.

image

On a cluster, make the API sources primary-only

The 2.x flow polls the API from the primary node by itself; the 1.x flow runs every processor on every node, so each node polls the cluster-wide API and sends its own copy: N nodes mean N times the nifi:api:* events and N times the licence. Open Monitoring - API and set Execution to Primary node on GetHTTP-flow_status, GetHTTP-system_diagnostics and the GenerateFlowFile inside each GetHTTP-*_history group — only those sources, since a processor fed by a connection would strand what is queued on the other nodes. Leave the logs branch on all nodes.

If NiFi serves HTTPS

Use the pull strategy instead. A NiFi serving HTTPS always requires its users to authenticate, and this flow calls NiFi's API without credentials, so every call is refused — see Choosing a collection strategy.

4. Configure the NiFi components

From the menu > Controller Settings, add the JsonRecordSetWriter controller service — it parses the reporting tasks' output for indexing in Splunk — and enable it. Then add three reporting tasks: MonitorDiskUsage, SiteToSiteBulletinReportingTask and SiteToSiteMetricsReportingTask.

image

The service goes in the Management Controller Services tab. It comes in Disabled — enable it:

image

The reporting tasks go in the Reporting Tasks tab of the same window:

image

image

The service goes in the Reporting Task Controller Services tab: click (+), filter for it, select it and add it.

image

Enable it: click the lightning bolt icon (ϟ) and confirm.

image

The reporting tasks go in the Reporting Task tab of the same window:

image

Configure each reporting task the same way on both lines:

  • MonitorDiskUsage: reports when a filesystem crosses the usage threshold you set.

    • Threshold: e.g. 80%
    • Directory Location: the filesystem to watch, e.g. /
    • Directory Display Name: a label for it, e.g. NifiFileSystem
  • SiteToSiteBulletinReportingTask: sends every bulletin as it happens.

    • Destination URL: http://${hostname(true)}:8080/nifi
    • Input Port Name: bulletin_report
    • Instance URL: same as Destination URL
    • Transport Protocol: HTTP
    • Record Writer: JsonRecordSetWriter
  • SiteToSiteMetricsReportingTask: sends flow and JVM metrics.

    • Destination URL: http://${hostname(true)}:8080/nifi
    • Input Port Name: reporting_task
    • Instance URL: same as Destination URL
    • Transport Protocol: HTTP
    • Record Writer: JsonRecordSetWriter
    • Output Format: Record Format

Then start each one (►):

image

image

5. Start the flow

Right-click the process group and select Start. Every component inside comes up running, with no invalid ones left:

image

image

Data now flows to Splunk. For it to appear in the app's panels, also configure the Instance Lookup.