DevOps Adventures…Log parser – Downloading Logs

Print
Category: IT
Published Date Written by Administrator

 

DevOps Adventures...Log parser – Downloading Logs

 

 

 

When we have plan how to download logs, we can move to downloading itself. For such purpose we will need the following:

 

 

 

1. k8s endpoint

 

2. service account with token

 

3. cluster role + role binding

 

4. reqwest library

 

 

 

To download logs (considering we have everything set up) we simply send GET request for specific endpoint:

 

 

 

https://${CLUSTER_IP}/api/v1/namespaces/${NAMESPACE}/pods/{hostname}/log?&tailLines=10&follow&timestamps=true

 

 

 

Above URL gives us access to logs which additonally consists timestamp. But before we get there, we need something more:

 

 

 

https://${CLUSTER_IP}/api/v1/namespaces/${NAMESPACE}/pods/

 

 

 

Above URL gives us possibility to list pods for specific namespace. We will need this, since in real life scenario, especially in production environments there are more pods than 1 in specific namespace. So in simple terms we will need construction like this: for each pod in specific namespace, download log with timestamp.

 

 

 

For now, this configuration gives us insight into logs in real time, which are printed into console output.

 

Who's online

We have 11 guests and no members online

Statistics

Visitors
1
Articles
56
Articles View Hits
168915
2012. Powered by Morgul 2012-2022
Download Joomla Templates