openfga / helm-charts

Official Helm charts for the OpenFGA project.
https://openfga.dev
Apache License 2.0
19 stars 35 forks source link

feat(openfga): add servicemonitor to OpenFGA chart #122

Closed cstruck closed 6 months ago

cstruck commented 6 months ago

This PR adds the possibility to use the ServiceMonitor custom resource from the prometheus-operator to scrape the /metrics endpoint

Description

The changes enable an user of the Chart to deploy a ServiceMonitor custom resource. This is needed if the user wants to use the prometheus-operator to scrape the metrics endpoint

References

Review Checklist

linux-foundation-easycla[bot] commented 6 months ago

CLA Signed

The committers listed above are authorized under a signed CLA.

jon-whit commented 6 months ago

I've confirmed it works out of the box with the default install commands 👍 .

Here's how I tested it:

minikube start

git clone https://github.com/prometheus-operator/kube-prometheus.git
cd kube-prometheus

kubectl create -f manifests/setup

# Wait until the "servicemonitors" CRD is created. The message "No resources found" means success in this context.
until kubectl get servicemonitors --all-namespaces ; do date; sleep 1; echo "";

kubectl create -f manifests/

then, install OpenFGA with the service monitor enabled.

cd <openfga-helm-repo>/charts/openfga
helm install openfga . --set telemetry.metrics.serviceMonitor.enabled=true

Port-forward to the Prometheus dashboard:

kubectl --namespace monitoring port-forward svc/prometheus-k8s 9090

Visit the Prometheus Dashboard by going to http://localhost:9090. After the scrape interval you'll see OpenFGA metrics show up.

Screenshot 2024-03-28 at 10 14 50 AM

For those not familiar with the Prometheus Operator, you can find more on their official website: https://prometheus-operator.dev/