Search in sources :

Example 1 with GaugeMetricFamily

use of io.prometheus.client.GaugeMetricFamily in project FlareBot by FlareBot.

the class BotCollector method collect.

@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;
}
Also used : ArrayList(java.util.ArrayList) GaugeMetricFamily(io.prometheus.client.GaugeMetricFamily)

Example 2 with GaugeMetricFamily

use of io.prometheus.client.GaugeMetricFamily in project FredBoat by Frederikam.

the class GuildSizesCollector method collect.

@Override
public List<MetricFamilySamples> collect() {
    List<MetricFamilySamples> mfs = new ArrayList<>();
    List<String> labelNames = Collections.singletonList("bucket");
    GaugeMetricFamily guildSizes = new GaugeMetricFamily("fredboat_guild_sizes", "Guilds by size", labelNames);
    mfs.add(guildSizes);
    guildSizes.addMetric(Collections.singletonList("1-10"), botMetrics.getGuildSizes().getBucket1to10());
    guildSizes.addMetric(Collections.singletonList("10-100"), botMetrics.getGuildSizes().getBucket10to100());
    guildSizes.addMetric(Collections.singletonList("100-1k"), botMetrics.getGuildSizes().getBucket100to1k());
    guildSizes.addMetric(Collections.singletonList("1k-10k"), botMetrics.getGuildSizes().getBucket1kto10k());
    guildSizes.addMetric(Collections.singletonList("10k-100k"), botMetrics.getGuildSizes().getBucket10kto100k());
    guildSizes.addMetric(Collections.singletonList("100k+"), botMetrics.getGuildSizes().getBucket100kAndUp());
    return mfs;
}
Also used : ArrayList(java.util.ArrayList) GaugeMetricFamily(io.prometheus.client.GaugeMetricFamily)

Example 3 with GaugeMetricFamily

use of io.prometheus.client.GaugeMetricFamily in project resilience4j by resilience4j.

the class RateLimiterExports method collect.

/**
 * {@inheritDoc}
 */
@Override
public List<MetricFamilySamples> collect() {
    final GaugeMetricFamily stats = new GaugeMetricFamily(name, "Rate Limiter Stats", asList("name", "param"));
    for (RateLimiter rateLimiter : rateLimitersSupplier.get()) {
        final RateLimiter.Metrics metrics = rateLimiter.getMetrics();
        stats.addMetric(asList(rateLimiter.getName(), "available_permissions"), metrics.getAvailablePermissions());
        stats.addMetric(asList(rateLimiter.getName(), "waiting_threads"), metrics.getNumberOfWaitingThreads());
    }
    return singletonList(stats);
}
Also used : RateLimiter(io.github.resilience4j.ratelimiter.RateLimiter) GaugeMetricFamily(io.prometheus.client.GaugeMetricFamily)

Example 4 with GaugeMetricFamily

use of io.prometheus.client.GaugeMetricFamily in project HikariCP by brettwooldridge.

the class HikariCPCollector method createGauge.

private GaugeMetricFamily createGauge(String metric, String help, Function<PoolStats, Integer> metricValueFunction) {
    GaugeMetricFamily metricFamily = new GaugeMetricFamily(metric, help, LABEL_NAMES);
    poolStatsMap.forEach((k, v) -> metricFamily.addMetric(Collections.singletonList(k), metricValueFunction.apply(v)));
    return metricFamily;
}
Also used : GaugeMetricFamily(io.prometheus.client.GaugeMetricFamily)

Example 5 with GaugeMetricFamily

use of io.prometheus.client.GaugeMetricFamily in project FredBoat by Frederikam.

the class FredBoatCollector method collect.

@Override
public List<MetricFamilySamples> collect() {
    List<MetricFamilySamples> mfs = new ArrayList<>();
    List<String> labelNames = Arrays.asList("shard", "entity");
    GaugeMetricFamily jdaEntities = new GaugeMetricFamily("fredboat_jda_entities", "Amount of JDA entities", labelNames);
    mfs.add(jdaEntities);
    GaugeMetricFamily playersPlaying = new GaugeMetricFamily("fredboat_playing_music_players", "Currently playing music players", labelNames);
    mfs.add(playersPlaying);
    CounterMetricFamily dockerPulls = new CounterMetricFamily("fredboat_docker_pulls", "Total fredboat docker image pulls as reported by the docker hub.", labelNames);
    mfs.add(dockerPulls);
    // global stats
    jdaEntities.addMetric(Arrays.asList("total", "User"), botMetrics.getTotalUniqueUsersCount());
    jdaEntities.addMetric(Arrays.asList("total", "Guild"), botMetrics.getTotalGuildsCount());
    jdaEntities.addMetric(Arrays.asList("total", "TextChannel"), botMetrics.getTotalTextChannelsCount());
    jdaEntities.addMetric(Arrays.asList("total", "VoiceChannel"), botMetrics.getTotalVoiceChannelsCount());
    jdaEntities.addMetric(Arrays.asList("total", "Category"), botMetrics.getTotalCategoriesCount());
    jdaEntities.addMetric(Arrays.asList("total", "Emote"), botMetrics.getTotalEmotesCount());
    jdaEntities.addMetric(Arrays.asList("total", "Role"), botMetrics.getTotalRolesCount());
    playersPlaying.addMetric(Arrays.asList("total", "Players"), playerRegistry.playingCount());
    // docker stats
    int dockerPullsBotCount = botMetrics.getDockerPullsBot();
    if (dockerPullsBotCount > 0) {
        dockerPulls.addMetric(Arrays.asList("total", "Bot"), dockerPullsBotCount);
    }
    int dockerPullsDbCount = botMetrics.getDockerPullsDb();
    if (dockerPullsDbCount > 0) {
        dockerPulls.addMetric(Arrays.asList("total", "Db"), dockerPullsDbCount);
    }
    // per shard stats
    shardProvider.streamShards().forEach(shard -> {
        String shardId = Integer.toString(shard.getShardInfo().getShardId());
        jdaEntities.addMetric(Arrays.asList(shardId, "User"), shard.getUserCache().size());
        jdaEntities.addMetric(Arrays.asList(shardId, "Guild"), shard.getGuildCache().size());
        jdaEntities.addMetric(Arrays.asList(shardId, "TextChannel"), shard.getTextChannelCache().size());
        jdaEntities.addMetric(Arrays.asList(shardId, "VoiceChannel"), shard.getVoiceChannelCache().size());
        jdaEntities.addMetric(Arrays.asList(shardId, "Category"), shard.getCategoryCache().size());
        jdaEntities.addMetric(Arrays.asList(shardId, "Emote"), shard.getEmoteCache().size());
        jdaEntities.addMetric(Arrays.asList(shardId, "Role"), shard.getRoleCache().size());
    });
    return mfs;
}
Also used : ArrayList(java.util.ArrayList) CounterMetricFamily(io.prometheus.client.CounterMetricFamily) GaugeMetricFamily(io.prometheus.client.GaugeMetricFamily)

Aggregations

GaugeMetricFamily (io.prometheus.client.GaugeMetricFamily)7 ArrayList (java.util.ArrayList)4 CounterMetricFamily (io.prometheus.client.CounterMetricFamily)2 CircuitBreaker (io.github.resilience4j.circuitbreaker.CircuitBreaker)1 RateLimiter (io.github.resilience4j.ratelimiter.RateLimiter)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)1