Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions nifi-docs/src/main/asciidoc/administration-guide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2922,6 +2922,15 @@ The Flow Action Reporter is a framework interface that supports exporting flow c
|`nifi.flow.action.reporter.implementation` | The class implementing `org.apache.nifi.action.FlowActionReporter` from `nifi-framework-api`. The default value is not specified.
|====

=== Component Metric Reporter

The Component Metric Reporter is a framework interface that supports exporting processing metrics including Counters and Gauges using a custom implementation class.

|====
|*Property* | *Description*
|`nifi.component.metric.reporter.implementation` | The class implementing `org.apache.nifi.controller.metrics.ComponentMetricReporter` from `nifi-framework-api`. The default value is not specified.
|====

=== FlowFile Repository

The FlowFile repository keeps track of the attributes and current state of each FlowFile in the system. By default,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.nifi.controller.metrics;

import java.util.Map;

/**
* Context associated with Component Metric records
*
* @param id Component Identifier
* @param name Component Name
* @param componentType Component Type
* @param attributes Map of additional attributes containing Process Group and related information
*/
public record ComponentMetricContext(
String id,
String name,
String componentType,
Map<String, String> attributes
) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.nifi.controller.metrics;

import java.io.Closeable;

/**
* Framework abstraction for reporting metrics emitted from processing components
*/
public interface ComponentMetricReporter extends Closeable {
/**
* Configuration lifecycle method that the application invokes after instantiating the class
*
* @param context Configuration Context properties
*/
default void onConfigured(ComponentMetricReporterConfigurationContext context) {

}

/**
* Close resources created during Reporter configuration and processing
*/
@Override
default void close() {
}

/**
* Record Gauge Record
*
* @param gaugeRecord Gauge Record required
*/
void recordGauge(GaugeRecord gaugeRecord);

/**
* Record Counter Record
*
* @param counterRecord Counter Record required
*/
void recordCounter(CounterRecord counterRecord);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.nifi.controller.metrics;

import java.util.Optional;
import javax.net.ssl.SSLContext;
import javax.net.ssl.X509TrustManager;

/**
* Configuration Context with properties provided to Component Metric Reporter on initial configuration
*/
public interface ComponentMetricReporterConfigurationContext {
/**
* Get SSL Context when configured in application properties
*
* @return SSLContext or empty when not configured
*/
Optional<SSLContext> getSSLContext();

/**
* Get Trust Manager when configured in application properties
*
* @return X509TrustManager or empty when not configured
*/
Optional<X509TrustManager> getTrustManager();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.nifi.controller.metrics;

import java.time.Instant;

/**
* Single measurement for a named Counter recorded during processing
*
* @param name Counter Name
* @param value Counter Value
* @param recorded Timestamp when the Component recorded the Counter value
* @param componentMetricContext Context for Component Metric record
*/
public record CounterRecord(
String name,
long value,
Instant recorded,
ComponentMetricContext componentMetricContext
) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.nifi.controller.metrics;

import java.time.Instant;

/**
* Single measurement for a named Gauge recorded during processing
*
* @param name Gauge Name
* @param value Gauge Value
* @param recorded Timestamp when the Processor recorded the Gauge value
* @param componentMetricContext Context for Component Metric record
*/
public record GaugeRecord(
String name,
double value,
Instant recorded,
ComponentMetricContext componentMetricContext
) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.nifi.controller.metrics;

/**
* Default implementation of Component Metric Reporter with empty method implementations
*/
public class DefaultComponentMetricReporter implements ComponentMetricReporter {
@Override
public void recordGauge(final GaugeRecord gaugeRecord) {

}

@Override
public void recordCounter(final CounterRecord counterRecord) {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.nifi.controller.metrics;

import java.util.Optional;
import javax.net.ssl.SSLContext;
import javax.net.ssl.X509TrustManager;

/**
* Standard implementation of Configuration Context properties for Component Metric Reporter
*/
public class StandardComponentMetricReporterConfigurationContext implements ComponentMetricReporterConfigurationContext {
private final SSLContext sslContext;
private final X509TrustManager trustManager;

public StandardComponentMetricReporterConfigurationContext(final SSLContext sslContext, final X509TrustManager trustManager) {
this.sslContext = sslContext;
this.trustManager = trustManager;
}

@Override
public Optional<SSLContext> getSSLContext() {
return Optional.ofNullable(sslContext);
}

@Override
public Optional<X509TrustManager> getTrustManager() {
return Optional.ofNullable(trustManager);
}
}
Loading
Loading