statful-micrometer-registry

Statful registry configuration for Micrometer.

License

License

Categories

Categories

CLI User Interface
GroupId

GroupId

com.statful.client.framework
ArtifactId

ArtifactId

statful-micrometer-registry
Last Version

Last Version

1.0.5
Release Date

Release Date

Type

Type

jar
Description

Description

statful-micrometer-registry
Statful registry configuration for Micrometer.
Project URL

Project URL

http://www.statful.com
Source Code Management

Source Code Management

https://github.com/statful/statful-micrometer-registry.git

Download statful-micrometer-registry

How to add to project

<!-- https://jarcasting.com/artifacts/com.statful.client.framework/statful-micrometer-registry/ -->
<dependency>
    <groupId>com.statful.client.framework</groupId>
    <artifactId>statful-micrometer-registry</artifactId>
    <version>1.0.5</version>
</dependency>
// https://jarcasting.com/artifacts/com.statful.client.framework/statful-micrometer-registry/
implementation 'com.statful.client.framework:statful-micrometer-registry:1.0.5'
// https://jarcasting.com/artifacts/com.statful.client.framework/statful-micrometer-registry/
implementation ("com.statful.client.framework:statful-micrometer-registry:1.0.5")
'com.statful.client.framework:statful-micrometer-registry:jar:1.0.5'
<dependency org="com.statful.client.framework" name="statful-micrometer-registry" rev="1.0.5">
  <artifact name="statful-micrometer-registry" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.statful.client.framework', module='statful-micrometer-registry', version='1.0.5')
)
libraryDependencies += "com.statful.client.framework" % "statful-micrometer-registry" % "1.0.5"
[com.statful.client.framework/statful-micrometer-registry "1.0.5"]

Dependencies

compile (3)

Group / Artifact Type Version
org.springframework.boot : spring-boot-starter-actuator jar 2.1.0.RELEASE
org.springframework.boot : spring-boot-configuration-processor Optional jar 2.1.0.RELEASE
com.google.guava : guava jar 23.0

provided (2)

Group / Artifact Type Version
com.statful.client : http-client jar 2.3.1
com.statful.client : udp-client jar 2.3.1

test (2)

Group / Artifact Type Version
org.mockito : mockito-all jar 1.10.19
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

statful-micrometer-registry

Configuration for gathering metrics from springboot actuator and send them to Statful.

Table of Contents

Supported Versions

Statful client version Tested Java versions Tested Spring Boot versions
2.x.x Java 8 2.1.0.RELEASE

Requirements

This client has the following requirements:

Quick start

To use this simply add the maven dependency:

<dependency>
   <groupId>com.statful.client.framework</groupId>
   <artifactId>statful-micrometer-registry</artifactId>
   <version>${statful-micrometer-registry.version}</version>
</dependency>

And then config a StatfulMetricRegistry bean in a @Configuration class. Keep in mind than you need to enable StatfulMetricsProperties using @EnableConfigurationProperties:

@Configuration
@EnableConfigurationProperties(value = StatfulMetricsProperties.class)
public class StatfulRegistryConfiguration {

    @Resource
    private StatfulMetricRegistryConfig statfulMetricRegistryConfig;

    @Resource
    private StatfulClient statfulClient;

    @Bean
    public MeterRegistry metricRegistry(StatfulMetricsProperties properties) {
        return new StatfulMetricRegistry(statfulMetricRegistryConfig, statfulClient, Clock.SYSTEM, properties);
    }
}

And enable @ComponentScan for the configuration package.

Enable metric collection by setting the following property:

statful.client.springboot.metrics.enabled=true

Examples

You can see the metrics output by running the client in dry-run mode, it will look similar to:

5:33:28.455 [pool-3-thread-1] DEBUG c.s.c.c.sender.BufferedMetricsSender - Dry metric: application.gauge.cache.entry.memory,app=tel,environment=development,cache=rate-limit-account-buckets-state,ownership=owned,name=rate-limit-account-buckets-state,cacheManager=cacheManager 0.0 1563892408 last,10 100
15:33:28.457 [pool-3-thread-1] DEBUG c.s.c.c.sender.BufferedMetricsSender - Dry metric: application.gauge.jvm.memory.max,app=tel,area=heap,environment=development,id=PS\ Old\ Gen 2.772434944E9 1563892408 last,10 100
15:33:28.488 [pool-3-thread-1] DEBUG c.s.c.c.sender.BufferedMetricsSender - Dry metric: application.timer.jvm.gc.pause,app=tel,action=end\ of\ minor\ GC,cause=Metadata\ GC\ Threshold,unit=ms,environment=development 0 1563892408 avg,p90,count,10 100
15:33:28.488 [pool-3-thread-1] DEBUG c.s.c.c.sender.BufferedMetricsSender - Dry metric: application.gauge.jvm.buffer.memory.used,app=tel,environment=development,id=direct 1.0 1563892408 last,10 100
15:33:28.489 [pool-3-thread-1] DEBUG c.s.c.c.sender.BufferedMetricsSender - Dry metric: application.gauge.jvm.memory.max,app=tel,area=nonheap,environment=development,id=Metaspace -1.0 1563892408 last,10 100
15:33:28.494 [pool-3-thread-1] DEBUG c.s.c.c.sender.BufferedMetricsSender - Dry metric: application.gauge.jvm.memory.used,app=tel,area=heap,environment=development,id=PS\ Eden\ Space 1.25688704E8 1563892408 last,10 100
15:33:28.495 [pool-3-thread-1] DEBUG c.s.c.c.sender.BufferedMetricsSender - Dry metric: application.gauge.jvm.threads.daemon,app=tel,environment=development 19.0 1563892408 last,10 100
15:33:28.496 [pool-3-thread-1] DEBUG c.s.c.c.sender.BufferedMetricsSender - Dry metric: application.gauge.system.cpu.usage,app=tel,environment=development 0.851063829787234 1563892408 last,10 100
15:33:28.501 [pool-3-thread-1] DEBUG c.s.c.c.sender.BufferedMetricsSender - Dry metric: application.gauge.jvm.threads.states,app=tel,environment=development,state=blocked 1.0 1563892408 last,10 100
15:33:28.502 [pool-3-thread-1] DEBUG c.s.c.c.sender.BufferedMetricsSender - Dry metric: application.gauge.jvm.threads.states,app=tel,environment=development,state=new 0.0 1563892408 last,10 100
15:33:28.503 [pool-3-thread-1] DEBUG c.s.c.c.sender.BufferedMetricsSender - Dry metric: application.counter.jvm.gc.memory.allocated,app=tel,environment=development 0 1563892408 count,sum,10 100
15:33:28.503 [pool-3-thread-1] DEBUG c.s.c.c.sender.BufferedMetricsSender - Dry metric: application.gauge.hikaricp.connections.idle,app=tel,pool=HikariPool-1,environment=development 2.0 1563892408 last,10 100

Extra Configuration

There are a few ways that you can customize your metrics by simply setting some application properties.

Global metric prefix

This will set a prefix for all your metrics

statful.client.springboot.metrics.prefix=springboot
Metric alias

This will replace every metric that contains the prefix with the chosen alias:

statful.metrics.properties.alias.system.cpu=cpu
statful.metrics.properties.alias.jvm.memory=memory
Metric tags

A list of tags to be added to the metrics that contain the prefix:

statful.metrics.properties.tags.system.cpu=environment=prod
statful.metrics.properties.tags.jvm.memory=unit=Gb

To add multiple tags use ';' as the separator:

statful.metrics.properties.tags.jvm.memory=unit=Gb;environment=prod
Filter Metrics

Using Spring Boot's Per-meter properties it's possible to filter out certain metrics:

application.yml
management: 
  metrics:
    enable:
      cpu: false
      memory: false
      jvm: true
      logback: false
      http: true
      process: false
application.properties
management.metrics.enable.cpu=false
management.metrics.enable.memory=false
management.metrics.enable.jvm=true
management.metrics.enable.logback=false
management.metrics.enable.http=true
management.metrics.enable.proccess=false

With the configuration:

statful.metrics.properties.alias.jvm.memory=memory
statful.metrics.properties.tags.jvm.memory=environment=prod

An example of the output this configuration would generate is:

15:06:03.519 [pool-3-thread-1] DEBUG c.s.c.c.sender.BufferedMetricsSender - Dry metric: application.gauge.memory,app=tel,area=heap,environment=prod,id=PS\ Survivor\ Space 2.883584E7 1563890763 last,10 100
15:06:03.519 [pool-3-thread-1] DEBUG c.s.c.c.sender.BufferedMetricsSender - Dry metric: application.timer.jvm.gc.pause,app=tel,action=end\ of\ minor\ GC,cause=Allocation\ Failure,unit=ms,environment=development 0 1563890763 avg,p90,count,10 100
15:06:03.519 [pool-3-thread-1] DEBUG c.s.c.c.sender.BufferedMetricsSender - Dry metric: application.counter.jvm.classes.unloaded,app=tel,environment=development 0 1563890763 count,sum,10 100
15:06:03.520 [pool-3-thread-1] DEBUG c.s.c.c.sender.BufferedMetricsSender - Dry metric: application.gauge.memory,app=tel,area=nonheap,environment=prod,id=Metaspace -1.0 1563890763 last,10 100
15:06:03.520 [pool-3-thread-1] DEBUG c.s.c.c.sender.BufferedMetricsSender - Dry metric: application.gauge.memory,app=tel,area=heap,environment=prod,id=PS\ Eden\ Space 2.15711232E8 1563890763 last,10 100
15:06:03.520 [pool-3-thread-1] DEBUG c.s.c.c.sender.BufferedMetricsSender - Dry metric: application.gauge.jvm.gc.live.data.size,app=tel,environment=development 0.0 1563890763 last,10 100
15:06:03.521 [pool-3-thread-1] DEBUG c.s.c.c.sender.BufferedMetricsSender - Dry metric: application.gauge.memory,app=tel,area=nonheap,environment=prod,id=Metaspace 1.02457344E8 1563890763 last,10 100
15:06:03.522 [pool-3-thread-1] DEBUG c.s.c.c.sender.BufferedMetricsSender - Dry metric: application.gauge.jvm.threads.states,app=tel,environment=development,state=timed-waiting 61.0 1563890763 last,10 100
15:06:03.522 [pool-3-thread-1] DEBUG c.s.c.c.sender.BufferedMetricsSender - Dry metric: application.gauge.memory,app=tel,area=heap,environment=prod,id=PS\ Old\ Gen 6.3446216E7 1563890763 last,10 100
15:06:03.523 [pool-3-thread-1] DEBUG c.s.c.c.sender.BufferedMetricsSender - Dry metric: application.gauge.memory,app=tel,area=heap,environment=prod,id=PS\ Survivor\ Space 2.8820288E7 1563890763 last,10 100
15:06:03.523 [pool-3-thread-1] DEBUG c.s.c.c.sender.BufferedMetricsSender - Dry metric: application.gauge.jvm.buffer.count,app=tel,environment=development,id=direct 2.0 1563890763 last,10 100
15:06:03.523 [pool-3-thread-1] DEBUG c.s.c.c.sender.BufferedMetricsSender - Dry metric: application.gauge.jvm.buffer.total.capacity,app=tel,environment=development,id=direct 8192.0 1563890763 last,10 100
15:06:03.524 [pool-3-thread-1] DEBUG c.s.c.c.sender.BufferedMetricsSender - Dry metric: application.gauge.jvm.buffer.count,app=tel,environment=development,id=mapped 0.0 1563890763 last,10 100
15:06:03.524 [pool-3-thread-1] DEBUG c.s.c.c.sender.BufferedMetricsSender - Dry metric: application.gauge.jvm.buffer.total.capacity,app=tel,environment=development,id=mapped 0.0 1563890763 last,10 100
15:06:03.524 [pool-3-thread-1] DEBUG c.s.c.c.sender.BufferedMetricsSender - Dry metric: application.gauge.memory,app=tel,area=nonheap,environment=prod,id=Compressed\ Class\ Space 1.441792E7 1563890763 last,10 100
15:06:03.525 [pool-3-thread-1] DEBUG c.s.c.c.sender.BufferedMetricsSender - Dry metric: application.gauge.memory,app=tel,area=nonheap,environment=prod,id=Code\ Cache 2.1168128E7 1563890763 last,10 100

In order to be able to define metric tags as above the springboot configuration-metadata-annotation-processor is used. If you're using AspectJ in your project please refer to the documentation on the expected annotation processor behaviour.

Reference

Collected Metrics

Metrics are collected according to what's described in the Spring Boot documentation and modelled into Statful format with the following considerations:

  • The type of metric is inferred by the metric's meaning with is decided both from the Spring Boot documentation and the actual code that exports data
  • Timer values are calculated by applying a mean to the values collected in the specified interval
  • Metrics that represent a value aggregated over a period of time are sent to Statful as previously aggregated

Authors

Mindera - Software Craft

License

Statful Spring Boot Client is available under the MIT license. See the LICENSE file for more information.

com.statful.client.framework

Statful

customizable metrics. real-time data.

Versions

Version
1.0.5
1.0.4
1.0.3
1.0.2