Package org.apache.kafka.common.metrics
Class JmxReporter
- java.lang.Object
-
- org.apache.kafka.common.metrics.JmxReporter
-
- All Implemented Interfaces:
AutoCloseable,Configurable,MetricsReporter,Reconfigurable
public class JmxReporter extends Object implements MetricsReporter
Register metrics in JMX as dynamic mbeans based on the metric names
-
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_EXCLUDEstatic StringDEFAULT_INCLUDEstatic StringEXCLUDE_CONFIGstatic StringEXCLUDE_CONFIG_ALIASstatic StringINCLUDE_CONFIGstatic StringINCLUDE_CONFIG_ALIASstatic StringMETRICS_CONFIG_PREFIXstatic Set<String>RECONFIGURABLE_CONFIGS
-
Constructor Summary
Constructors Constructor Description JmxReporter()JmxReporter(String prefix)Deprecated.Since 2.6.0.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Called when the metrics repository is closed.static Predicate<String>compilePredicate(Map<String,?> originalConfig)voidconfigure(Map<String,?> configs)Configure this class with the given key-value pairsbooleancontainsMbean(String mbeanName)voidcontextChange(MetricsContext metricsContext)Sets the context labels for the service or library exposing metrics.voidinit(List<KafkaMetric> metrics)This is called when the reporter is first registered to initially register all existing metricsvoidmetricChange(KafkaMetric metric)This is called whenever a metric is updated or addedvoidmetricRemoval(KafkaMetric metric)This is called whenever a metric is removedSet<String>reconfigurableConfigs()Returns the names of configs that may be reconfigured.voidreconfigure(Map<String,?> configs)Reconfigures this instance with the given key-value pairs.voidvalidateReconfiguration(Map<String,?> configs)Validates the provided configuration.
-
-
-
Field Detail
-
METRICS_CONFIG_PREFIX
public static final String METRICS_CONFIG_PREFIX
- See Also:
- Constant Field Values
-
EXCLUDE_CONFIG
public static final String EXCLUDE_CONFIG
- See Also:
- Constant Field Values
-
EXCLUDE_CONFIG_ALIAS
public static final String EXCLUDE_CONFIG_ALIAS
- See Also:
- Constant Field Values
-
INCLUDE_CONFIG
public static final String INCLUDE_CONFIG
- See Also:
- Constant Field Values
-
INCLUDE_CONFIG_ALIAS
public static final String INCLUDE_CONFIG_ALIAS
- See Also:
- Constant Field Values
-
DEFAULT_INCLUDE
public static final String DEFAULT_INCLUDE
- See Also:
- Constant Field Values
-
DEFAULT_EXCLUDE
public static final String DEFAULT_EXCLUDE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
JmxReporter
public JmxReporter()
-
JmxReporter
@Deprecated public JmxReporter(String prefix)
Deprecated.Since 2.6.0. UseJmxReporter()Initialize JmxReporter withcontextChange(MetricsContext)Populate prefix by adding _namespace/prefix key value pair toMetricsContextCreate a JMX reporter that prefixes all metrics with the given string.
-
-
Method Detail
-
configure
public void configure(Map<String,?> configs)
Description copied from interface:ConfigurableConfigure this class with the given key-value pairs- Specified by:
configurein interfaceConfigurable
-
reconfigurableConfigs
public Set<String> reconfigurableConfigs()
Description copied from interface:ReconfigurableReturns the names of configs that may be reconfigured.- Specified by:
reconfigurableConfigsin interfaceMetricsReporter- Specified by:
reconfigurableConfigsin interfaceReconfigurable
-
validateReconfiguration
public void validateReconfiguration(Map<String,?> configs) throws ConfigException
Description copied from interface:ReconfigurableValidates the provided configuration. The provided map contains all configs including any reconfigurable configs that may be different from the initial configuration. Reconfiguration will be not performed if this method throws any exception.- Specified by:
validateReconfigurationin interfaceMetricsReporter- Specified by:
validateReconfigurationin interfaceReconfigurable- Throws:
ConfigException- if the provided configs are not valid. The exception message from ConfigException will be returned to the client in the AlterConfigs response.
-
reconfigure
public void reconfigure(Map<String,?> configs)
Description copied from interface:ReconfigurableReconfigures this instance with the given key-value pairs. The provided map contains all configs including any reconfigurable configs that may have changed since the object was initially configured usingConfigurable.configure(Map). This method will only be invoked if the configs have passed validation usingReconfigurable.validateReconfiguration(Map).- Specified by:
reconfigurein interfaceMetricsReporter- Specified by:
reconfigurein interfaceReconfigurable
-
init
public void init(List<KafkaMetric> metrics)
Description copied from interface:MetricsReporterThis is called when the reporter is first registered to initially register all existing metrics- Specified by:
initin interfaceMetricsReporter- Parameters:
metrics- All currently existing metrics
-
containsMbean
public boolean containsMbean(String mbeanName)
-
metricChange
public void metricChange(KafkaMetric metric)
Description copied from interface:MetricsReporterThis is called whenever a metric is updated or added- Specified by:
metricChangein interfaceMetricsReporter
-
metricRemoval
public void metricRemoval(KafkaMetric metric)
Description copied from interface:MetricsReporterThis is called whenever a metric is removed- Specified by:
metricRemovalin interfaceMetricsReporter
-
close
public void close()
Description copied from interface:MetricsReporterCalled when the metrics repository is closed.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceMetricsReporter
-
contextChange
public void contextChange(MetricsContext metricsContext)
Description copied from interface:MetricsReporterSets the context labels for the service or library exposing metrics. This will be called beforeMetricsReporter.init(List)and may be called anytime after that.- Specified by:
contextChangein interfaceMetricsReporter- Parameters:
metricsContext- the metric context
-
-