Java Code Examples for io.prometheus.client.GaugeMetricFamily#addMetric()

The following examples show how to use io.prometheus.client.GaugeMetricFamily#addMetric() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VersionInfoExports.java    From client_java with Apache License 2.0 6 votes vote down vote up
public List<MetricFamilySamples> collect() {
    List<MetricFamilySamples> mfs = new ArrayList<MetricFamilySamples>();

    GaugeMetricFamily jvmInfo = new GaugeMetricFamily(
            "jvm_info",
            "JVM version info",
            Arrays.asList("version", "vendor", "runtime"));
    jvmInfo.addMetric(
            Arrays.asList(
                System.getProperty("java.runtime.version", "unknown"),
                System.getProperty("java.vm.vendor", "unknown"),
                System.getProperty("java.runtime.name", "unknown")),
                1L);
    mfs.add(jvmInfo);

    return mfs;
}
 
Example 2
Source File: MetaCollector.java    From canal with Apache License 2.0 6 votes vote down vote up
@Override
public List<MetricFamilySamples> collect() {
    List<MetricFamilySamples> mfs = new ArrayList<MetricFamilySamples>();
    GaugeMetricFamily instanceInfo = new GaugeMetricFamily(INSTANCE,
            INSTANCE_HELP, INFO_LABELS_LIST);
    GaugeMetricFamily subsInfo = new GaugeMetricFamily(SUBSCRIPTION,
            SUBSCRIPTION_HELP, DEST_LABELS_LIST);
    for (Map.Entry<String, MetaMetricsHolder> nme : instances.entrySet()) {
        final String destination = nme.getKey();
        final MetaMetricsHolder nmh = nme.getValue();
        instanceInfo.addMetric(nmh.infoLabelValues, 1);
        List<ClientIdentity> subs = nmh.metaManager.listAllSubscribeInfo(destination);
        int count = subs == null ? 0 : subs.size();
        subsInfo.addMetric(nmh.destLabelValues, count);
    }
    mfs.add(instanceInfo);
    mfs.add(subsInfo);
    return mfs;
}
 
Example 3
Source File: BotCollector.java    From FlareBot with MIT License 6 votes vote down vote up
@Override
public List<MetricFamilySamples> collect() {

    List<MetricFamilySamples> familySamples = new ArrayList<>();

    GaugeMetricFamily jdaEntities = new GaugeMetricFamily("flarebot_jda_entities_total", "Amount of JDA entities",
            Collections.singletonList("entity"));
    familySamples.add(jdaEntities);

    GaugeMetricFamily playerInfo = new GaugeMetricFamily("flarebot_player_info",
            "Amount of players, playing players and songs queued", Collections.singletonList("amount"));
    familySamples.add(playerInfo);

    if (botMetrics.count()) {
        jdaEntities.addMetric(Collections.singletonList("guilds"), botMetrics.getGuildCount());
        jdaEntities.addMetric(Collections.singletonList("users"), botMetrics.getUserCount());
        jdaEntities.addMetric(Collections.singletonList("text_channels"), botMetrics.getTextChannelCount());
        jdaEntities.addMetric(Collections.singletonList("voice_channels"), botMetrics.getVoiceChannelCount());

        playerInfo.addMetric(Collections.singletonList("connected_voice_channels"), Getters.getConnectedVoiceChannels());
        playerInfo.addMetric(Collections.singletonList("active_voice_channels"), Getters.getActiveVoiceChannels());
        playerInfo.addMetric(Collections.singletonList("songs_queued"), Getters.getSongsQueued());
    }

    return familySamples;
}
 
Example 4
Source File: EntryCollector.java    From canal-1.1.3 with Apache License 2.0 6 votes vote down vote up
@Override
public List<MetricFamilySamples> collect() {
    List<MetricFamilySamples> mfs = new ArrayList<MetricFamilySamples>();
    GaugeMetricFamily delay = new GaugeMetricFamily(DELAY,
            DELAY_HELP, DEST_LABELS_LIST);
    CounterMetricFamily transactions = new CounterMetricFamily(TRANSACTION,
            TRANSACTION_HELP, DEST_LABELS_LIST);
    for (EntryMetricsHolder emh : instances.values()) {
        long now = System.currentTimeMillis();
        long latest = emh.latestExecTime.get();
        // execTime > now,delay显示为0
        long d = (now >= latest) ? (now - latest) : 0;
        delay.addMetric(emh.destLabelValues, d);
        transactions.addMetric(emh.destLabelValues, emh.transactionCounter.doubleValue());
    }
    mfs.add(delay);
    mfs.add(transactions);
    return mfs;
}
 
Example 5
Source File: PingInfo.java    From maestro-java with Apache License 2.0 6 votes vote down vote up
public List<MetricFamilySamples> collect() {
    List<MetricFamilySamples> mfs = new ArrayList<>();

    GaugeMetricFamily labeledGauge = new GaugeMetricFamily("maestro_ping",
            "Ping", Arrays.asList("peer", "type"));

    logger.trace("Number of values to process: {}", records.values().size());
    for (PingResponse pingResponse : records.values()) {

        logger.trace("Adding record for {}/{}", pingResponse.getPeerInfo().prettyName(), pingResponse.getId());
        labeledGauge.addMetric(Arrays.asList(pingResponse.getPeerInfo().peerName(), pingResponse.getPeerInfo().peerHost()),
                pingResponse.getElapsed());
    }

    mfs.add(labeledGauge);
    records.clear();
    return mfs;
}
 
Example 6
Source File: MetaCollector.java    From canal-1.1.3 with Apache License 2.0 6 votes vote down vote up
@Override
public List<MetricFamilySamples> collect() {
    List<MetricFamilySamples> mfs = new ArrayList<MetricFamilySamples>();
    GaugeMetricFamily instanceInfo = new GaugeMetricFamily(INSTANCE,
            INSTANCE_HELP, INFO_LABELS_LIST);
    GaugeMetricFamily subsInfo = new GaugeMetricFamily(SUBSCRIPTION,
            SUBSCRIPTION_HELP, DEST_LABELS_LIST);
    for (Map.Entry<String, MetaMetricsHolder> nme : instances.entrySet()) {
        final String destination = nme.getKey();
        final MetaMetricsHolder nmh = nme.getValue();
        instanceInfo.addMetric(nmh.infoLabelValues, 1);
        List<ClientIdentity> subs = nmh.metaManager.listAllSubscribeInfo(destination);
        int count = subs == null ? 0 : subs.size();
        subsInfo.addMetric(nmh.destLabelValues, count);
    }
    mfs.add(instanceInfo);
    mfs.add(subsInfo);
    return mfs;
}
 
Example 7
Source File: ConnectionCount.java    From maestro-java with Apache License 2.0 6 votes vote down vote up
public List<MetricFamilySamples> collect() {
    List<MetricFamilySamples> mfs = new ArrayList<>();

    GaugeMetricFamily labeledGauge = new GaugeMetricFamily("maestro_connection_count",
            "Connection count", Arrays.asList("peer", "type"));

    logger.trace("Number of values to process: {}", records.values().size());

    for (StatsResponse stats : records.values()) {
        labeledGauge.addMetric(Arrays.asList(stats.getPeerInfo().peerName(), stats.getPeerInfo().peerHost()), stats.getChildCount());

    }

    mfs.add(labeledGauge);
    records.clear();
    return mfs;
}
 
Example 8
Source File: BuildInfoCollector.java    From soul with Apache License 2.0 5 votes vote down vote up
@Override
public List<MetricFamilySamples> collect() {
    List<MetricFamilySamples> mfs = new ArrayList<>();
    GaugeMetricFamily artifactInfo = new GaugeMetricFamily(
            "jmx_exporter_build_info",
            "A metric with a constant '1' value labeled with the version of the JMX exporter.",
            Arrays.asList("version", "name"));
    Package pkg = this.getClass().getPackage();
    String version = pkg.getImplementationVersion();
    String name = pkg.getImplementationTitle();
    artifactInfo.addMetric(Arrays.asList(version != null ? version : "unknown", name != null ? name : "unknown"), 1L);
    mfs.add(artifactInfo);
    return mfs;
}
 
Example 9
Source File: BufferPoolCollector.java    From Mycat2 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public List<MetricFamilySamples> collect() {
    try {
        GaugeMetricFamily gaugeMetricFamily = new GaugeMetricFamily("buffer_pool_counter",
                "buffer_pool",
                ImmutableList.of("name",  "chunkSize","capacity"));
        for (MycatReactorThread mycatReactorThread : Optional.ofNullable(MycatCore.INSTANCE.getReactorManager())
                .map(i -> i.getList()).orElse(Collections.emptyList())) {
            BufferPool bufPool = mycatReactorThread.getBufPool();

            if (bufPool != null) {
                String name = bufPool.getClass().getName();
                long capacity = bufPool.capacity();
                int chunkSize = bufPool.chunkSize();
                int trace = bufPool.trace();
                gaugeMetricFamily.addMetric(ImmutableList.of(String.valueOf(name),
                        String.valueOf(chunkSize),
                        String.valueOf(capacity)),
                        trace);
            }
        }

        return ImmutableList.of(gaugeMetricFamily);
    } catch (Throwable e) {
        LOGGER.error("", e);
        throw e;
    }
}
 
Example 10
Source File: ConnectionCounterCollector.java    From Mycat2 with GNU General Public License v3.0 5 votes vote down vote up
private static GaugeMetricFamily countTotalBackend() {
    GaugeMetricFamily gaugeMetricFamily = new GaugeMetricFamily("instance_connection",
            "jdbc + native_mysql backend connection",
            ImmutableList.of("type", "datasource"));

    Map<String, PhysicsInstance> physicsInstanceMap = Optional.ofNullable(ReplicaSelectorRuntime.INSTANCE.getPhysicsInstanceMap())
            .orElse(Collections.emptyMap());
    for (Map.Entry<String, PhysicsInstance> entry : physicsInstanceMap.entrySet()) {
        String key = entry.getKey();
        PhysicsInstance value = entry.getValue();
        gaugeMetricFamily.addMetric(ImmutableList.of(Type.TOTAL.getName(), key), value.getSessionCounter());
    }
    return gaugeMetricFamily;
}
 
Example 11
Source File: BufferPoolsExports.java    From client_java with Apache License 2.0 5 votes vote down vote up
@Override
public List<MetricFamilySamples> collect() {
    List<MetricFamilySamples> mfs = new ArrayList<MetricFamilySamples>();
    GaugeMetricFamily used = new GaugeMetricFamily(
            "jvm_buffer_pool_used_bytes",
            "Used bytes of a given JVM buffer pool.",
            Collections.singletonList("pool"));
    mfs.add(used);
    GaugeMetricFamily capacity = new GaugeMetricFamily(
            "jvm_buffer_pool_capacity_bytes",
            "Bytes capacity of a given JVM buffer pool.",
            Collections.singletonList("pool"));
    mfs.add(capacity);
    GaugeMetricFamily buffers = new GaugeMetricFamily(
            "jvm_buffer_pool_used_buffers",
            "Used buffers of a given JVM buffer pool.",
            Collections.singletonList("pool"));
    mfs.add(buffers);
    for (final Object pool : bufferPoolMXBeans) {
        used.addMetric(
                Collections.singletonList(getName(pool)),
                callLongMethond(getMemoryUsed,pool));
        capacity.addMetric(
                Collections.singletonList(getName(pool)),
                callLongMethond(getTotalCapacity,pool));
        buffers.addMetric(
                Collections.singletonList(getName(pool)),
                callLongMethond(getCount,pool));
    }
    return mfs;
}
 
Example 12
Source File: TomcatGenericExports.java    From tomcat_exporter with Apache License 2.0 5 votes vote down vote up
private void addVersionInfo(List<MetricFamilySamples> mfs) {
    GaugeMetricFamily tomcatInfo = new GaugeMetricFamily(
            "tomcat_info",
            "tomcat version info",
            Arrays.asList("version", "build"));
    tomcatInfo.addMetric(Arrays.asList(ServerInfo.getServerNumber(), ServerInfo.getServerBuilt()), 1);
    mfs.add(tomcatInfo);
}
 
Example 13
Source File: SqlStatCollector.java    From Mycat2 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public List<MetricFamilySamples> collect() {
    try {
        GaugeMetricFamily gaugeMetricFamily = new GaugeMetricFamily("sql_stat",
                "sql_stat",
                ImmutableList.of("statement", "time_type"));
        Map<String, List<SqlRecord>> recordList = SqlRecorderRuntime.INSTANCE.getRecordList();
        for (Map.Entry<String, List<SqlRecord>> entry : recordList.entrySet()) {
            String sql = normalie(entry.getKey());
            for (SqlRecord record : entry.getValue()) {
                if (record.getStatement() != null) {
                    double v = record.getEndTime() - record.getStartTime();
                    if (v > 0) {
                        gaugeMetricFamily.addMetric(ImmutableList.of(sql, "TOTAL_TIME"), v);
                        gaugeMetricFamily.addMetric(ImmutableList.of(sql, "COMPILE_TIME"), record.getCompileTime());
                        gaugeMetricFamily.addMetric(ImmutableList.of(sql, "RBO_TIME"), record.getCboTime());
                        gaugeMetricFamily.addMetric(ImmutableList.of(sql, "CBO_TIME"), record.getRboTime());
                        gaugeMetricFamily.addMetric(ImmutableList.of(sql, "CONNECTION_POOL_TIME"), record.getConnectionPoolTime());
                        gaugeMetricFamily.addMetric(ImmutableList.of(sql, "CONNECTION_QUERY_TIME"), record.getConnectionQueryTime());
                        gaugeMetricFamily.addMetric(ImmutableList.of(sql, "EXECUTION_TIME"), record.getExecutionTime());
                    }
                }
            }
        }
        return ImmutableList.of(gaugeMetricFamily);
    } catch (Throwable e) {
        LOGGER.error("", e);
        throw e;
    }
}
 
Example 14
Source File: RMQMetricsCollector.java    From rocketmq-exporter with Apache License 2.0 5 votes vote down vote up
private static <T extends Number> void loadBrokerRuntimeStatsMetric(GaugeMetricFamily family, Map.Entry<BrokerRuntimeMetric, T> entry) {
    family.addMetric(Arrays.asList(
            entry.getKey().getClusterName(),
            entry.getKey().getBrokerAddress(),
            entry.getKey().getBrokerHost(),
            entry.getKey().getBrokerDes(),
            String.valueOf(entry.getKey().getBootTimestamp()),
            String.valueOf(entry.getKey().getBrokerVersion())
    ), entry.getValue().doubleValue());
}
 
Example 15
Source File: RMQMetricsCollector.java    From rocketmq-exporter with Apache License 2.0 5 votes vote down vote up
private void loadTopicNumsMetric(GaugeMetricFamily family, Map.Entry<TopicPutNumMetric, Double> entry) {
    family.addMetric(
            Arrays.asList(
                    entry.getKey().getClusterName(),
                    entry.getKey().getBrokerName(),
                    entry.getKey().getTopicName()
            ),
            entry.getValue()
    );
}
 
Example 16
Source File: RMQMetricsCollector.java    From rocketmq-exporter with Apache License 2.0 5 votes vote down vote up
private static <T extends Number> void loadGroupNumsMetric(GaugeMetricFamily family, Map.Entry<ConsumerMetric, T> entry) {
    family.addMetric(Arrays.asList(
            entry.getKey().getClusterName(),
            entry.getKey().getBrokerName(),
            entry.getKey().getTopicName(),
            entry.getKey().getConsumerGroupName()),
            entry.getValue().doubleValue()
    );
}
 
Example 17
Source File: MemoryPoolsExports.java    From client_java with Apache License 2.0 5 votes vote down vote up
void addMemoryPoolMetrics(List<MetricFamilySamples> sampleFamilies) {
  GaugeMetricFamily used = new GaugeMetricFamily(
      "jvm_memory_pool_bytes_used",
      "Used bytes of a given JVM memory pool.",
      Collections.singletonList("pool"));
  sampleFamilies.add(used);
  GaugeMetricFamily committed = new GaugeMetricFamily(
      "jvm_memory_pool_bytes_committed",
      "Committed bytes of a given JVM memory pool.",
      Collections.singletonList("pool"));
  sampleFamilies.add(committed);
  GaugeMetricFamily max = new GaugeMetricFamily(
      "jvm_memory_pool_bytes_max",
      "Max bytes of a given JVM memory pool.",
      Collections.singletonList("pool"));
  sampleFamilies.add(max);
  GaugeMetricFamily init = new GaugeMetricFamily(
      "jvm_memory_pool_bytes_init",
      "Initial bytes of a given JVM memory pool.",
      Collections.singletonList("pool"));
  sampleFamilies.add(init);
  for (final MemoryPoolMXBean pool : poolBeans) {
    MemoryUsage poolUsage = pool.getUsage();
    used.addMetric(
        Collections.singletonList(pool.getName()),
        poolUsage.getUsed());
    committed.addMetric(
        Collections.singletonList(pool.getName()),
        poolUsage.getCommitted());
    max.addMetric(
        Collections.singletonList(pool.getName()),
        poolUsage.getMax());
    init.addMetric(
        Collections.singletonList(pool.getName()),
        poolUsage.getInit());
  }
}
 
Example 18
Source File: LavalinkCollector.java    From Lavalink-Client with MIT License 4 votes vote down vote up
@Override
public List<MetricFamilySamples> collect() {

    List<MetricFamilySamples> mfs = new ArrayList<>();
    List<String> labelNames = Collections.singletonList("node");


    GaugeMetricFamily players = new GaugeMetricFamily("lavalink_players_current",
            "Amount of players", labelNames);
    mfs.add(players);
    GaugeMetricFamily playingPlayers = new GaugeMetricFamily("lavalink_playing_players_current",
            "Amount of playing players", labelNames);
    mfs.add(playingPlayers);
    GaugeMetricFamily uptimeSeconds = new GaugeMetricFamily("lavalink_uptime_seconds",
            "Uptime of the node", labelNames);
    mfs.add(uptimeSeconds);


    GaugeMetricFamily memFree = new GaugeMetricFamily("lavalink_mem_free_bytes",
            "Amount of free memory", labelNames);
    mfs.add(memFree);
    GaugeMetricFamily memUsed = new GaugeMetricFamily("lavalink_mem_used_bytes",
            "Amount of used memory", labelNames);
    mfs.add(memUsed);
    GaugeMetricFamily memAllocated = new GaugeMetricFamily("lavalink_mem_allocated_bytes",
            "Amount of allocated memory", labelNames);
    mfs.add(memAllocated);
    GaugeMetricFamily memReservable = new GaugeMetricFamily("lavalink_mem_reservable_bytes",
            "Amount of reservable memory", labelNames);
    mfs.add(memReservable);

    GaugeMetricFamily cpuCores = new GaugeMetricFamily("lavalink_cpu_cores",
            "Amount of cpu cores", labelNames);
    mfs.add(cpuCores);
    GaugeMetricFamily systemLoad = new GaugeMetricFamily("lavalink_load_system",
            "Total load of the system", labelNames);
    mfs.add(systemLoad);
    GaugeMetricFamily lavalinkLoad = new GaugeMetricFamily("lavalink_load_lavalink",
            "Load caused by Lavalink", labelNames);
    mfs.add(lavalinkLoad);


    GaugeMetricFamily averageFramesSentPerMinute = new GaugeMetricFamily("lavalink_average_frames_sent_per_minute",
            "Average frames sent per minute", labelNames);
    mfs.add(averageFramesSentPerMinute);
    GaugeMetricFamily averageFramesNulledPerMinute = new GaugeMetricFamily("lavalink_average_frames_nulled_per_minute",
            "Average frames nulled per minute", labelNames);
    mfs.add(averageFramesNulledPerMinute);
    GaugeMetricFamily averageFramesDeficitPerMinute = new GaugeMetricFamily("lavalink_average_frames_deficit_per_minute",
            "Average frames deficit per minute", labelNames);
    mfs.add(averageFramesDeficitPerMinute);


    //noinspection unchecked
    List<LavalinkSocket> nodes = lavalink.getNodes();
    for (LavalinkSocket node : nodes) {
        List<String> labels = Collections.singletonList(node.getName());
        RemoteStats stats = node.getStats();
        if (stats == null) {
            continue;
        }

        players.addMetric(labels, stats.getPlayers());
        playingPlayers.addMetric(labels, stats.getPlayingPlayers());
        uptimeSeconds.addMetric(labels, stats.getUptime() / 1000);

        memFree.addMetric(labels, stats.getMemFree());
        memUsed.addMetric(labels, stats.getMemUsed());
        memAllocated.addMetric(labels, stats.getMemAllocated());
        memReservable.addMetric(labels, stats.getMemReservable());

        cpuCores.addMetric(labels, stats.getCpuCores());
        systemLoad.addMetric(labels, stats.getSystemLoad());
        lavalinkLoad.addMetric(labels, stats.getLavalinkLoad());

        averageFramesSentPerMinute.addMetric(labels, stats.getAvgFramesSentPerMinute());
        averageFramesNulledPerMinute.addMetric(labels, stats.getAvgFramesNulledPerMinute());
        averageFramesDeficitPerMinute.addMetric(labels, stats.getAvgFramesDeficitPerMinute());
    }

    return mfs;
}
 
Example 19
Source File: ThreadExports.java    From client_java with Apache License 2.0 4 votes vote down vote up
void addThreadMetrics(List<MetricFamilySamples> sampleFamilies) {
  sampleFamilies.add(
      new GaugeMetricFamily(
        "jvm_threads_current",
        "Current thread count of a JVM",
        threadBean.getThreadCount()));

  sampleFamilies.add(
      new GaugeMetricFamily(
        "jvm_threads_daemon",
        "Daemon thread count of a JVM",
        threadBean.getDaemonThreadCount()));

  sampleFamilies.add(
      new GaugeMetricFamily(
        "jvm_threads_peak",
        "Peak thread count of a JVM",
        threadBean.getPeakThreadCount()));

  sampleFamilies.add(
      new CounterMetricFamily(
        "jvm_threads_started_total",
        "Started thread count of a JVM",
        threadBean.getTotalStartedThreadCount()));

  sampleFamilies.add(
      new GaugeMetricFamily(
      "jvm_threads_deadlocked",
      "Cycles of JVM-threads that are in deadlock waiting to acquire object monitors or ownable synchronizers",
      nullSafeArrayLength(threadBean.findDeadlockedThreads())));

  sampleFamilies.add(
      new GaugeMetricFamily(
      "jvm_threads_deadlocked_monitor",
      "Cycles of JVM-threads that are in deadlock waiting to acquire object monitors",
      nullSafeArrayLength(threadBean.findMonitorDeadlockedThreads())));

  GaugeMetricFamily threadStateFamily = new GaugeMetricFamily(
    "jvm_threads_state",
    "Current count of threads by state",
    Collections.singletonList("state"));

  Map<Thread.State, Integer> threadStateCounts = getThreadStateCountMap();
  for (Map.Entry<Thread.State, Integer> entry : threadStateCounts.entrySet()) {
    threadStateFamily.addMetric(
      Collections.singletonList(entry.getKey().toString()),
      entry.getValue()
    );
  }
  sampleFamilies.add(threadStateFamily);
}
 
Example 20
Source File: TomcatGenericExports.java    From tomcat_exporter with Apache License 2.0 4 votes vote down vote up
private void addRequestProcessorMetrics(List<MetricFamilySamples> mfs) {
    try {
        final MBeanServer server = ManagementFactory.getPlatformMBeanServer();
        ObjectName filterName = new ObjectName(jmxDomain + ":type=GlobalRequestProcessor,name=*");
        Set<ObjectInstance> mBeans = server.queryMBeans(filterName, null);

        if (mBeans.size() > 0) {
            List<String> labelNameList = Collections.singletonList("name");

            GaugeMetricFamily requestProcessorBytesReceivedGauge = new GaugeMetricFamily(
                    "tomcat_requestprocessor_received_bytes",
                    "Number of bytes received by this request processor",
                    labelNameList);

            GaugeMetricFamily requestProcessorBytesSentGauge = new GaugeMetricFamily(
                    "tomcat_requestprocessor_sent_bytes",
                    "Number of bytes sent by this request processor",
                    labelNameList);

            GaugeMetricFamily requestProcessorProcessingTimeGauge = new GaugeMetricFamily(
                    "tomcat_requestprocessor_time_seconds",
                    "The total time spend by this request processor",
                    labelNameList);

            CounterMetricFamily requestProcessorErrorCounter = new CounterMetricFamily(
                    "tomcat_requestprocessor_error_count",
                    "The number of error request served by this request processor",
                    labelNameList);

            CounterMetricFamily requestProcessorRequestCounter = new CounterMetricFamily(
                    "tomcat_requestprocessor_request_count",
                    "The number of request served by this request processor",
                    labelNameList);

            for (final ObjectInstance mBean : mBeans) {
                List<String> labelValueList = Collections.singletonList(mBean.getObjectName().getKeyProperty("name").replaceAll("[\"\\\\]", ""));

                requestProcessorBytesReceivedGauge.addMetric(
                        labelValueList,
                        ((Long) server.getAttribute(mBean.getObjectName(), "bytesReceived")).doubleValue());

                requestProcessorBytesSentGauge.addMetric(
                        labelValueList,
                        ((Long) server.getAttribute(mBean.getObjectName(), "bytesSent")).doubleValue());

                requestProcessorProcessingTimeGauge.addMetric(
                        labelValueList,
                        ((Long) server.getAttribute(mBean.getObjectName(), "processingTime")).doubleValue() / 1000.0);

                requestProcessorErrorCounter.addMetric(
                        labelValueList,
                        ((Integer) server.getAttribute(mBean.getObjectName(), "errorCount")).doubleValue());

                requestProcessorRequestCounter.addMetric(
                        labelValueList,
                        ((Integer) server.getAttribute(mBean.getObjectName(), "requestCount")).doubleValue());
            }

            mfs.add(requestProcessorBytesReceivedGauge);
            mfs.add(requestProcessorBytesSentGauge);
            mfs.add(requestProcessorProcessingTimeGauge);
            mfs.add(requestProcessorRequestCounter);
            mfs.add(requestProcessorErrorCounter);
        }
    } catch (Exception e) {
        log.error("Error retrieving metric.", e);
    }
}