Spring Boot Starter - API Statistics

A spring boot starter configuration for publishing API statistics.

License

License

Categories

Categories

Spring Boot Container Microservices KeY Data Data Formats Formal Verification
GroupId

GroupId

com.keyholesoftware
ArtifactId

ArtifactId

khs-spring-boot-api-statistics-starter
Last Version

Last Version

1.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

Spring Boot Starter - API Statistics
A spring boot starter configuration for publishing API statistics.
Project URL

Project URL

http://keyholesoftware.com
Project Organization

Project Organization

Keyhole Software
Source Code Management

Source Code Management

https://github.com/in-the-keyhole/khs-spring-boot-api-statistics-starter

Download khs-spring-boot-api-statistics-starter

How to add to project

<!-- https://jarcasting.com/artifacts/com.keyholesoftware/khs-spring-boot-api-statistics-starter/ -->
<dependency>
    <groupId>com.keyholesoftware</groupId>
    <artifactId>khs-spring-boot-api-statistics-starter</artifactId>
    <version>1.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.keyholesoftware/khs-spring-boot-api-statistics-starter/
implementation 'com.keyholesoftware:khs-spring-boot-api-statistics-starter:1.0.1'
// https://jarcasting.com/artifacts/com.keyholesoftware/khs-spring-boot-api-statistics-starter/
implementation ("com.keyholesoftware:khs-spring-boot-api-statistics-starter:1.0.1")
'com.keyholesoftware:khs-spring-boot-api-statistics-starter:jar:1.0.1'
<dependency org="com.keyholesoftware" name="khs-spring-boot-api-statistics-starter" rev="1.0.1">
  <artifact name="khs-spring-boot-api-statistics-starter" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.keyholesoftware', module='khs-spring-boot-api-statistics-starter', version='1.0.1')
)
libraryDependencies += "com.keyholesoftware" % "khs-spring-boot-api-statistics-starter" % "1.0.1"
[com.keyholesoftware/khs-spring-boot-api-statistics-starter "1.0.1"]

Dependencies

compile (3)

Group / Artifact Type Version
org.springframework.boot : spring-boot-starter-web jar
org.springframework.boot : spring-boot-configuration-processor Optional jar
org.codehaus.jackson : jackson-core-asl jar 1.9.13

Project Modules

There are no modules declared in this project.

khs-spring-boot-api-statistics-starter

A Spring Boot starter for publishing api statistics.

Description

This Spring Boot starter can be used to POST API usage statistics to a publishing target (url) on a configurable interval. The body of the request will be a JSON array of statistics (see schema below), and a security token can be applied to ensure that only authorized clients have access.

Installation

Add this dependency to your pom.xml:

<dependency>
	<groupId>com.keyholesoftware</groupId>
	<artifactId>khs-spring-api-statistics-starter</artifactId>
	<version>1.0.1</version>
</dependency>	

Annotate your Spring Boot main class:

@SpringBootApplication
@EnableApiStatistics
public class MySpringBootApp {

	public static void main(String[] args) {
		SpringApplication.run(MySpringBootApp.class, args);
	}
}

Configurable Properties: api.statistics.name - The name under which to group the published statistics api.statistics.pattern-match: A regex expression to filter API's in/out api.statistics.publish-url: The url to POST the statistics to api.statistics.token: A security token to prevent unwanted clients from POSTing stats to the publish-url

Example Configuration(s):

(i.e. application.yml)

api:
  statistics:
    name: apigateway
    pattern-match: /api/.*
    publish-url: http://beta.grokola.com/sherpa/api/stats/308
    token: 9x019749-XXXX-XXXX-XXXX-38090a0ea9g9

Example Payload:

[
  {
    uri: "/api/projects/1",
    method: "GET",
    duration: "19",
    service: "apigateway"
  },
  {
    uri: "/api/projects/1",
    method: "GET",
    duration: "16",
    service: "apigateway"
  },
  {
    uri: "/api/projects/2",
    method: "GET",
    duration: "14",
    service: "apigateway"
  }
  ...
]
com.keyholesoftware

Keyhole Software

Software dev team providing consulting, development & education services with Java, JavaScript & .NET technologies.

Versions

Version
1.0.1