Statistics Service

The Statistics Service provides usage statistics about a Keptn installation. You can access the service using the Keptn API and view the results using the Swagger UI.

Generate Swagger doc from source

First, install the go modules with the following commands:

go get -u
go get -u
go get -u

To generate new source that updates the swagger.yaml file with new endpoints or models, execute the following:

swag init

How to use the service

Access the Statistics Service through the Keptn API under the statistics path. For example:

Use the following URL to view the swagger UI for the service:

To browse the API docs, open the Swagger docs in your browser, e.g. ${KEPTN_URL}/swagger-ui/index.html.

Specifying time frames

To retrieve usage statistics for a certain time frame, you need to provide the Unix timestamps for the start and end of the time frame. Use the EpochConverter to generate timestamps.

A Keptn API example using a timestamp is:

A cURL example using a timestamp is:

curl -X GET "" -H "accept: application/json" -H "x-token: <keptn-api-token>"

Configuring the aggregating interval

By default, the service aggregates data every 30 minutes. When this period has passed, the service creates a new entry in the Keptn-MongoDB within the Keptn cluster. To change how often statistics are stored, set the AGGREGATION_INTERVAL_SECONDS variable to your desired value.