Apache NiFi
repository·main·Indexed 11 days ago
https://github.com/apache/nifiA scalable system for automating and managing data flows, used for cybersecurity, observability, and generative AI pipelines. Includes MiNiFi, a lightweight data collection agent for resource-constrained environments, and a C2 Protocol client for centralized configuration and heartbeat management. Supports Docker deployment, mTLS security, and integration with NiFi 2.0.0.
What's inside NiFi
- Apache NiFi Registry is a subproject of Apache NiFi that serves as a central location for the storage and management of shared resources. It is designed to work across one or more instances of Apache NiFi and/or MiNiFi, enabling version control and resource sharing for dataflow components.
Overview of Apache NiFi MiNiFi Command and Control (C2) Client
mainThe
c2-client-bundleimplements the client-side of the C2 Protocol. Its primary functions are constructing heartbeats and communicating with a C2 server viaC2HttpClient.Key Capabilities
- Heartbeat Management: Periodically sends heartbeats to the C2 server.
- Configuration Updates: Processes and acknowledges
UPDATEconfiguration operations received from the server. Once exposed, new configurations are downloaded and passed back to the system via the C2 protocol. - Centralized Control: Enables configuration changes and operations to be triggered centrally from the C2 server.
- Security: Supports bidirectional TLS authentication.
Operational Model
When C2 is enabled, a
C2ClientServiceis scheduled to send heartbeats at a defined frequency. This allows the C2 server to notify the client of protocol-defined operations that must be executed on the client side.Overview of the NiFi Toolkit
mainThe NiFi Toolkit provides command-line utilities to set up and support NiFi in both standalone and clustered environments. The primary utility is theclitool, which allows administrators to automate tasks such as deploying versioned flows, managing process groups, and managing cluster nodes via NiFi and NiFi Registry APIs.Overview of Apache NiFi capabilities
mainApache NiFi is a platform for managing directed graphs of data routing, transformation, and system mediation logic. It provides a web-based user interface for designing, controlling, and monitoring dataflows.
Key features include:
- Configurability: Supports tuning for loss tolerance vs. guaranteed delivery, low latency vs. high throughput, dynamic prioritization, runtime flow modifications, and back pressure.
- Data Provenance: Provides the ability to track dataflow from beginning to end.
- Extensibility: Designed to allow developers to build custom processors and other extensions.
- Security: Supports SSL, SSH, HTTPS, and encrypted content, along with multi-tenant and internal authorization/policy management.
Overview of Apache NiFi MiNiFi
mainApache NiFi MiNiFi is a subproject of Apache NiFi designed as a lightweight data collection agent. It is intended to be deployed at the source of data creation (e.g., on sensors, systems, or servers) to supplement core NiFi dataflow management.
Key characteristics include:
- Small and lightweight footprint: Optimized for resource-constrained environments.
- Central management: Designed to allow for the central management of agents.
- Data Provenance: Generates provenance information for data tracking.
- NiFi Integration: Integrates with Apache NiFi for follow-on dataflow management and to maintain a full chain of custody for information.
Overview of the MergeRecord Processor
mainThe
MergeRecordprocessor combines multiple FlowFiles containing record-oriented data (using any available Record Reader) into a single, larger FlowFile.Key Benefits:
- Downstream Efficiency: Prepares data for systems that prefer large batches (e.g., HDFS).
- Performance Optimization: Reduces the total number of FlowFiles in the system, decreasing contention on the FlowFile, Provenance, and Content Repositories, as well as FlowFile Queues.
Use QueryNiFiReportingTask for SQL-based NiFi metrics reporting
mainThe
QueryNiFiReportingTaskallows you to execute SQL queries against NiFi metrics, which are modeled as virtual tables. The results of these queries are then transmitted to a destination via a configuredRecord Sinkservice (e.g.,SiteToSiteReportingRecordSinkorDatabaseRecordSink).Key features:
- Apache Calcite Integration: Supports standard SQL features including
JOINs and aggregate functions. - Non-materialized Views: The tables are not persistent; they are re-queried from their sources at every execution.
- Unique Processing: For
BULLETINSandPROVENANCEtables, you can ensure items are only processed once by using special SQL placeholders to define a time window. This prevents duplicate reporting of the same event across different task executions.
- Apache Calcite Integration: Supports standard SQL features including
Use GetSNMP to poll SNMP agents
mainThe
GetSNMPprocessor polls an SNMP agent to retrieve information using two strategies:- GET Strategy: Retrieves information for a specific OID or a set of OIDs.
- WALK Strategy: Retrieves all information for the entire subtree associated with a given OID.
This processor supports SNMPv1, SNMPv2c, and SNMPv3 and is built on the SNMP4J library.
Output Behavior
- FlowFile Content: The outgoing FlowFile content is always empty.
- FlowFile Attributes: All retrieved information is written to FlowFile attributes.
- GET Request Output: For a single GET request, the properties from the received PDU are transferred directly into FlowFile attributes.
- WALK Request Output: For a WALK request, only "OID/value" pairs are transferred into FlowFile attributes.
Use YamlTreeReader to parse YAML data
mainThe
YamlTreeReaderController Service converts YAML objects into NiFi Record objects.Behavioral Rules:
- Root Element as Array: If the YAML root is an array, each object in the array becomes a separate Record.
- Root Element as Object: If the YAML root is an object, the entire YAML structure is treated as a single Record.
- Schema Matching: The service must be configured with a schema.
- Fields in YAML but not in the schema are skipped.
- Fields in the schema but not in the YAML are populated with null (or the schema's default value).
- Subparts: You can use 'Starting Field Strategies' (detailed in other documentation) to read only specific sub-sections of the YAML tree as records.
Understand the Apache NiFi Frontend Design System
mainThe NiFi frontend uses Angular Material Design 3 (MD3) with a custom teal-based color palette and a specialized canvas environment for the flow designer.
Key Implementation Details:
- Theming: Uses Angular Material's
--md-ref-palette-*system mapped to NiFi's palette inlibs/shared/src/assets/themes/material.scss. - Custom Tokens: Uses
--nf-*CSS custom properties for canvas and status semantics that fall outside standard MD3. - Stack: Angular (NgModule and standalone), Angular Material (MD3), Tailwind CSS v4, and Font Awesome 4.7.
- Layout: Uses Tailwind CSS for spacing and flex/grid utilities. Avoid custom spacing SCSS.
- Icons: Uses Font Awesome 4.7 via
<i class="fa fa-*">syntax.
- Theming: Uses Angular Material's
Use the ConsumeJMS processor to ingest JMS messages
mainThe
ConsumeJMSprocessor consumes messages from any JMS-compliant messaging system and converts them into NiFi FlowFiles.When a message is consumed:
- The message body is written to the FlowFile content.
- Standard JMS Headers and Properties are extracted and set as FlowFile attributes.
Use JsonTreeReader to parse JSON data
mainThe
JsonTreeReaderController Service converts JSON objects into NiFi Record objects.Behavioral Rules:
- Root Element as Array: If the JSON root is an array, each object in the array is treated as a separate Record.
- Root Element as Object: If the JSON root is an object, the entire JSON is treated as a single Record.
- Schema Matching: The service uses a configured schema to define the Record structure.
- Fields in JSON but not in the schema are skipped.
- Fields in the schema but not in the JSON are populated with null (or the schema's default value).
- Subpart Parsing: You can configure the reader to create a Record for the entire JSON tree or just a specific subpart (refer to 'Starting Field Strategies' in the full documentation).