cxf-prometheus-metrics

Lib to collect prometheus statistics for spring boot actuator

License

License

Categories

Categories

Metrics Application Testing & Monitoring Monitoring
GroupId

GroupId

io.github.kdprog
ArtifactId

ArtifactId

cxf-micrometer-metrics
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

cxf-prometheus-metrics
Lib to collect prometheus statistics for spring boot actuator
Project URL

Project URL

https://github.com/ddk-prog/prometheus/
Source Code Management

Source Code Management

https://github.com/ddk-prog/prometheus/

Download cxf-micrometer-metrics

How to add to project

<!-- https://jarcasting.com/artifacts/io.github.kdprog/cxf-micrometer-metrics/ -->
<dependency>
    <groupId>io.github.kdprog</groupId>
    <artifactId>cxf-micrometer-metrics</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/io.github.kdprog/cxf-micrometer-metrics/
implementation 'io.github.kdprog:cxf-micrometer-metrics:1.0.0'
// https://jarcasting.com/artifacts/io.github.kdprog/cxf-micrometer-metrics/
implementation ("io.github.kdprog:cxf-micrometer-metrics:1.0.0")
'io.github.kdprog:cxf-micrometer-metrics:jar:1.0.0'
<dependency org="io.github.kdprog" name="cxf-micrometer-metrics" rev="1.0.0">
  <artifact name="cxf-micrometer-metrics" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.github.kdprog', module='cxf-micrometer-metrics', version='1.0.0')
)
libraryDependencies += "io.github.kdprog" % "cxf-micrometer-metrics" % "1.0.0"
[io.github.kdprog/cxf-micrometer-metrics "1.0.0"]

Dependencies

runtime (3)

Group / Artifact Type Version
org.apache.cxf : cxf-core jar 3.3.6
io.micrometer : micrometer-core jar 1.5.0
org.apache.commons : commons-lang3 jar 3.10

Project Modules

There are no modules declared in this project.

CXF metrics for prometheus

Collects the following metrics for each endpoint and operation

cxf_requests_total       - total number of incoming cxf requests,
cxf_requests_success     - total number of successfully processed cxf requests,
cxf_requests_failed      - total number of failed cxf requests,
cxf_requests_seconds_sum - total execution time of cxf requests.

Besides, histograms are reported for execution time statistics. For example, for configuration bellow

@Bean
public Endpoint server1(final Bus bus, final MyFirstWebService service) {
    final EndpointImpl endpoint = new EndpointImpl(bus, service);
    endpoint.setEndpointName(new QName("server1"));
    endpoint.publish("/server1");
    return endpoint;
}

@Bean
public Endpoint server2(final Bus bus, final MySecondWebService service) {
    final EndpointImpl endpoint = new EndpointImpl(bus, service);
    endpoint.setEndpointName(new QName("server2"));
    endpoint.publish("/server2");
    return endpoint;
}

@Bean
public MyCxfClient client(final @Value("${my.cxf.client.url}") String url) {
    final JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.setAddress(url);
    factory.setEndpointName(new QName("client"));
    return factory.create(MyCxfClient.class);
}

the cxf_requests_total metric will be available for 'server1' endpoint as 'cxf_requests_total{endpoint="server1",operation="server1Method"}' for each web service method of MyFirstWebService.
And the same for other metrics of MyFirstWebService, MySecondWebService and MyCxfClient.

To enable cxf metrics for prometheus add dependency to your pom.xml.

<dependency>
    <groupId>io.github.ddk-prog</groupId>
    <artifactId>cxf-prometheus-metrics</artifactId>
    <version>1.1.1</version>
</dependency>

Add the following bean to your application configuration.

@Bean
public FactoryBeanListener cxfPrometheusFeatureBean(final CollectorRegistry registry) {
    return new PrometheusFactoryBeanListener(registry);
}

Versions

Version
1.0.0