Search in sources :

Example 11 with JmxReporter

use of com.codahale.metrics.jmx.JmxReporter in project ambry by linkedin.

the class DumpDataTool method main.

public static void main(String[] args) throws Exception {
    VerifiableProperties verifiableProperties = ToolUtils.getVerifiableProperties(args);
    MetricRegistry registry = new MetricRegistry();
    StoreToolsMetrics metrics = new StoreToolsMetrics(registry);
    JmxReporter reporter = null;
    try {
        reporter = JmxReporter.forRegistry(registry).build();
        reporter.start();
        DumpDataTool dumpDataTool = new DumpDataTool(verifiableProperties, metrics);
        dumpDataTool.doOperation();
    } finally {
        if (reporter != null) {
            reporter.stop();
        }
    }
}
Also used : VerifiableProperties(com.github.ambry.config.VerifiableProperties) MetricRegistry(com.codahale.metrics.MetricRegistry) JmxReporter(com.codahale.metrics.jmx.JmxReporter)

Example 12 with JmxReporter

use of com.codahale.metrics.jmx.JmxReporter in project ambry by linkedin.

the class DumpLogTool method main.

public static void main(String[] args) throws Exception {
    VerifiableProperties verifiableProperties = ToolUtils.getVerifiableProperties(args);
    MetricRegistry registry = new MetricRegistry();
    StoreToolsMetrics metrics = new StoreToolsMetrics(registry);
    JmxReporter reporter = null;
    try {
        reporter = JmxReporter.forRegistry(registry).build();
        reporter.start();
        DumpLogTool dumpLogTool = new DumpLogTool(verifiableProperties, metrics);
        dumpLogTool.doOperation();
    } finally {
        if (reporter != null) {
            reporter.stop();
        }
    }
}
Also used : VerifiableProperties(com.github.ambry.config.VerifiableProperties) MetricRegistry(com.codahale.metrics.MetricRegistry) JmxReporter(com.codahale.metrics.jmx.JmxReporter)

Example 13 with JmxReporter

use of com.codahale.metrics.jmx.JmxReporter in project graylog2-server by Graylog2.

the class CmdLineTool method run.

@Override
public void run() {
    final Level logLevel = setupLogger();
    if (isDumpDefaultConfig()) {
        dumpDefaultConfigAndExit();
    }
    // This is holding all our metrics.
    MetricRegistry metricRegistry = MetricRegistryFactory.create();
    featureFlags = getFeatureFlags(metricRegistry);
    installConfigRepositories();
    installCommandConfig();
    beforeStart();
    beforeStart(parseAndGetTLSConfiguration(), parseAndGetPathConfiguration(configFile));
    processConfiguration(jadConfig);
    coreConfigInjector = setupCoreConfigInjector();
    final Set<Plugin> plugins = loadPlugins(getPluginPath(configFile), chainingClassLoader);
    installPluginConfig(plugins);
    processConfiguration(jadConfig);
    if (isDumpConfig()) {
        dumpCurrentConfigAndExit();
    }
    if (!validateConfiguration()) {
        LOG.error("Validating configuration file failed - exiting.");
        System.exit(1);
    }
    final List<String> arguments = ManagementFactory.getRuntimeMXBean().getInputArguments();
    LOG.info("Running with JVM arguments: {}", Joiner.on(' ').join(arguments));
    beforeInjectorCreation(plugins);
    injector = setupInjector(new NamedConfigParametersModule(jadConfig.getConfigurationBeans()), new PluginBindings(plugins), binder -> binder.bind(MetricRegistry.class).toInstance(metricRegistry));
    if (injector == null) {
        LOG.error("Injector could not be created, exiting! (Please include the previous error messages in bug " + "reports.)");
        System.exit(1);
    }
    addInstrumentedAppender(metricRegistry, logLevel);
    // Report metrics via JMX.
    final JmxReporter reporter = JmxReporter.forRegistry(metricRegistry).build();
    reporter.start();
    startCommand();
}
Also used : NamedConfigParametersModule(com.github.joschi.jadconfig.guice.NamedConfigParametersModule) Option(com.github.rvesse.airline.annotations.Option) Module(com.google.inject.Module) Plugin(org.graylog2.plugin.Plugin) Arrays(java.util.Arrays) ParameterException(com.github.joschi.jadconfig.ParameterException) NodeIdPersistenceException(org.graylog2.plugin.system.NodeIdPersistenceException) FeatureFlagsFactory(org.graylog2.featureflag.FeatureFlagsFactory) GuiceInjectorHolder(org.graylog2.shared.bindings.GuiceInjectorHolder) RepositoryException(com.github.joschi.jadconfig.RepositoryException) LoggerContext(org.apache.logging.log4j.core.LoggerContext) Tools(org.graylog2.plugin.Tools) LoggerFactory(org.slf4j.LoggerFactory) Level(org.apache.logging.log4j.Level) Security(java.security.Security) InstrumentedAppender(com.codahale.metrics.log4j2.InstrumentedAppender) Message(com.google.inject.spi.Message) PluginLoaderConfig(org.graylog2.plugin.PluginLoaderConfig) Map(java.util.Map) UnsupportedSearchException(org.graylog2.storage.UnsupportedSearchException) Version(org.graylog2.plugin.Version) PropertiesRepository(com.github.joschi.jadconfig.repositories.PropertiesRepository) Command(com.github.rvesse.airline.annotations.Command) ChainingClassLoader(org.graylog2.shared.plugins.ChainingClassLoader) Path(java.nio.file.Path) TLSProtocolsConfiguration(org.graylog2.configuration.TLSProtocolsConfiguration) ExceptionUtils(org.graylog2.shared.utilities.ExceptionUtils) Slf4JLoggerFactory(io.netty.util.internal.logging.Slf4JLoggerFactory) ImmutableSet(com.google.common.collect.ImmutableSet) JodaTimeConverterFactory(com.github.joschi.jadconfig.jodatime.JodaTimeConverterFactory) Collection(java.util.Collection) Set(java.util.Set) ServerStatus(org.graylog2.plugin.ServerStatus) SearchVersion(org.graylog2.storage.SearchVersion) ValidationException(com.github.joschi.jadconfig.ValidationException) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) Stage(com.google.inject.Stage) List(java.util.List) Stream(java.util.stream.Stream) Configuration(org.graylog2.Configuration) DocsHelper(org.graylog2.plugin.DocsHelper) PluginBindings(org.graylog2.shared.bindings.PluginBindings) PathConfiguration(org.graylog2.configuration.PathConfiguration) PluginMetaData(org.graylog2.plugin.PluginMetaData) ElasticsearchProbeException(org.graylog2.storage.versionprobe.ElasticsearchProbeException) UI(org.graylog2.shared.UI) AccessDeniedException(java.nio.file.AccessDeniedException) GuavaConverterFactory(com.github.joschi.jadconfig.guava.GuavaConverterFactory) Joiner(com.google.common.base.Joiner) EnvironmentRepository(com.github.joschi.jadconfig.repositories.EnvironmentRepository) Strings.nullToEmpty(com.google.common.base.Strings.nullToEmpty) Strings(joptsimple.internal.Strings) HashSet(java.util.HashSet) JmxReporter(com.codahale.metrics.jmx.JmxReporter) Lists(com.google.common.collect.Lists) ImmutableList(com.google.common.collect.ImmutableList) Binder(com.google.inject.Binder) SystemPropertiesRepository(com.github.joschi.jadconfig.repositories.SystemPropertiesRepository) JadConfig(com.github.joschi.jadconfig.JadConfig) ManagementFactory(java.lang.management.ManagementFactory) NamedConfigParametersModule(com.github.joschi.jadconfig.guice.NamedConfigParametersModule) MigrateCmd(org.graylog2.bootstrap.commands.MigrateCmd) FeatureFlags(org.graylog2.featureflag.FeatureFlags) MetricRegistry(com.codahale.metrics.MetricRegistry) Logger(org.slf4j.Logger) Names(com.google.inject.name.Names) PluginLoader(org.graylog2.shared.plugins.PluginLoader) BouncyCastleProvider(org.bouncycastle.jce.provider.BouncyCastleProvider) Injector(com.google.inject.Injector) CreationException(com.google.inject.CreationException) Repository(com.github.joschi.jadconfig.Repository) Guice(com.google.inject.Guice) MetricRegistryFactory(org.graylog2.shared.metrics.MetricRegistryFactory) InternalLoggerFactory(io.netty.util.internal.logging.InternalLoggerFactory) LogManager(org.apache.logging.log4j.LogManager) Collections(java.util.Collections) PluginBindings(org.graylog2.shared.bindings.PluginBindings) MetricRegistry(com.codahale.metrics.MetricRegistry) Level(org.apache.logging.log4j.Level) JmxReporter(com.codahale.metrics.jmx.JmxReporter) Plugin(org.graylog2.plugin.Plugin)

Aggregations

JmxReporter (com.codahale.metrics.jmx.JmxReporter)13 MetricRegistry (com.codahale.metrics.MetricRegistry)9 VerifiableProperties (com.github.ambry.config.VerifiableProperties)5 ObjectNameFactory (com.codahale.metrics.jmx.ObjectNameFactory)4 DefaultObjectNameFactory (com.codahale.metrics.jmx.DefaultObjectNameFactory)3 IOException (java.io.IOException)3 Collections (java.util.Collections)3 Properties (java.util.Properties)3 Function (java.util.function.Function)3 Test (org.junit.Test)3 Mockito (org.mockito.Mockito)3 MockClusterAgentsFactory (com.github.ambry.clustermap.MockClusterAgentsFactory)2 MockClusterMap (com.github.ambry.clustermap.MockClusterMap)2 LoggingNotificationSystem (com.github.ambry.commons.LoggingNotificationSystem)2 SSLFactory (com.github.ambry.commons.SSLFactory)2 NotificationSystem (com.github.ambry.notification.NotificationSystem)2 MalformedObjectNameException (javax.management.MalformedObjectNameException)2 ObjectName (javax.management.ObjectName)2 Assert (org.junit.Assert)2 JCommander (com.beust.jcommander.JCommander)1