keptn-contrib / prometheus-sli-service

Apache License 2.0
6 stars 2 forks source link

:warning: The prometheus-sli-service has been merged into the prometheus-service maintained here: https://github.com/keptn-contrib/prometheus-service Please visit the prometheus-service for further developing the functionality of the prometheus-sli-service.

:warning: Due to the merge, this repository will be set to read-only on 9th of July, 2021, and will be archived in the future.

Prometheus SLI Service

GitHub release (latest by date) Build Status Go Report Card

This service is used for retrieving Service Level Indicators (SLIs) from a Prometheus API endpoint. Per default, it fetches metrics from the prometheus instance set up by Keptn (prometheus-service.monitoring.svc.cluster.local:8080), but it can also be configured to use any reachable Prometheus endpoint using basic authentication by providing the credentials via a secret in the keptn namespace of the cluster.

The supported default SLIs are:

The provided SLIs are based on the RED metrics

Compatibility Matrix

Please always double check the version of Keptn you are using compared to the version of this service, and follow the compatibility matrix below.

Keptn Version Prometheus SLI Service Image
0.6.1 keptncontrib/prometheus-sli-service:0.2.1
0.6.2 keptncontrib/prometheus-sli-service:0.2.2
0.7.0 keptncontrib/prometheus-sli-service:0.2.2
0.7.1 keptncontrib/prometheus-sli-service:0.2.2
0.7.2 keptncontrib/prometheus-sli-service:0.2.3
0.7.3 keptncontrib/prometheus-sli-service:0.2.3
0.8.0-alpha keptncontrib/prometheus-sli-service:0.3.0-alpha
0.8.0 - 0.8.2 keptncontrib/prometheus-sli-service:0.3.0

Basic Usage

Per default, the service works with the following assumptions regarding the setup of the Prometheus instance:

Advanced Usage

Using an external Prometheus instance

To use a Prometheus instance other than the one that is being managed by Keptn for a certain project, a secret containing the URL and the access credentials has to be deployed into the keptn namespace. The secret must have the following format:

user: test
password: test
url: http://prometheus-service.monitoring.svc.cluster.local:8080

If this information is stored in a file, e.g. prometheus-creds.yaml, it can be stored with the following command (don't forget to replace the <project> placeholder with the name of your project:

kubectl create secret -n keptn generic prometheus-credentials-<project> --from-file=prometheus-credentials=./mock_secret.yaml

Please note that there is a naming convention for the secret, because this can be configured per project. Therefore, the secret has to have the name prometheus-credentials-<project>

Custom SLI queries

Users can override the predefined queries, as well as add custom queries by creating a SLI configuration.


Within the user-defined queries, the following variables can be used to dynamically build the query, depending on the project/stage/service, and the time frame:

For example, if an evaluation for the service carts in the stage production of the project sockshop is triggered, and the tests ran for 30s these will be the resulting queries:

rate(my_custom_metric{job='$SERVICE-$PROJECT-$STAGE',handler=~'$handler'}[$DURATION_SECONDS]) => rate(my_custom_metric{job='carts-sockshop-production',handler=~'$handler'}[30s])

Deploy in your Kubernetes cluster

To deploy the current version of the prometheus-sli-service in your Keptn Kubernetes cluster, use the file deploy/service.yaml from this repository and apply it:

KEPTN_NAMESPACE=<your keptn namespace>
kubectl apply -f deploy/service.yaml -n $KEPTN_NAMESPACE

Delete in your Kubernetes cluster

To delete a deployed prometheus-sli-service, use the file deploy/service.yaml from this repository and delete the Kubernetes resources:

KEPTN_NAMESPACE=<your keptn namespace>
kubectl delete -f deploy/service.yaml -n $KEPTN_NAMESPACE