Aller au contenu

Prometheus federation concepts#

Prometheus federation is documented here

Test and connect to /federate endpoint with Curl#

With port-forward#

Connect to the pod or the service with kubectl port-forward.

Run curl :

curl -G --data-urlencode 'match[]={job=~".+"}' "http://localhost:9090/federate"

With Rancher#

Fill these variables :

NAMESPACE="caascad-monitoring" # or "monitoring" or whatever
RANCHER=https://rancher.ocb-xxxx.caascad.com/k8s/clusters/c-xxxxx
TOKEN="kubeconfig-x-xxxxx:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

Note

You can get the Rancher cluster c-xxxxx and token by connecting to Rancher (http://rancher..caascad.com) : select the cluster, then retrive the cluster and token from the Kubeconfig File.

Tip

This should work for cloud and client zones :

ZONE=<zone name>
eval $(rswitch login "${ZONE}" -e)
RANCHER=$(cat "${KUBECONFIG}" | yq -r '.clusters[] | select(.name=="rswitch-'${ZONE}'") | .cluster.server')
CLOUD_ZONE=$(echo $RANCHER | cut -d. -f 2)
TOKEN=$(cat "${HOME}/.config/rswitch/.token" | jq -r '."'$CLOUD_ZONE'".token')

Run curl :

curl -G --data-urlencode 'match[]={job=~".+"}' -H "Authorization: Bearer  ${TOKEN}" ${RANCHER}/api/v1/namespaces/${NAMESPACE}/services/prometheus-operated:web/proxy/federate