cxf-prometheus-metrics

Lib to collect prometheus statistics for spring boot actuator

License

License

Categories

Categories

Metrics Application Testing & Monitoring Monitoring Prometheus
GroupId

GroupId

io.github.ddk-prog
ArtifactId

ArtifactId

cxf-prometheus-metrics
Last Version

Last Version

1.1.1
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-prometheus-metrics

How to add to project

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

Dependencies

runtime (2)

Group / Artifact Type Version
org.apache.cxf : cxf-core jar 3.3.6
io.prometheus : simpleclient_pushgateway jar 0.8.1

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.1.1
1.0.0