Search code examples
amazon-web-serviceskubernetesamazon-eksgrafana-loki

Is it possible to retrieve logs from kubernetes pods through API endpoint from AWS EKS?


I have a kubernetes running on EKS AWS. I want to know it if its possible to access the pods logs through the API endpoint AWS offers for the cluster.

I want to send the logs to a serverless loki running in a different service. I'm not allowed to install nor loki neither promtail inside the kubernetes for company reasons, that's why I want to access the logs through the API endpoint.


Solution

  • Here's a complete guide how to do that using a service account token. To follow the log append ?follow=true like:

    curl -s $APISERVER/api/v1/namespaces/<namespace>/pods/<pod name>/log?follow=true --header "Authorization: Bearer $TOKEN"
    --cacert ca.crt