Hi 👋,
I have a valid json log messages in my container.
I would like to get a last log message:
from kubernetes import client, config
config.load_kube_config()
v1 = client.CoreV1Api()
namespace = "namespacename"
pod = "podname"
ret = v1.read_namespaced_pod_log(
name=pod,
namespace=namespace,
tail_lines=1,
)
print(ret)
It returns:
{'time': '2024-02-19T13:32:53.08943787Z', 'level': 'INFO', 'msg': 'some msg'}
This is incorrect. There is single quotes in return. It should be:
{"time": "2024-02-19T13:32:53.08943787Z", "level": "INFO", "msg": "some msg"}
I think, that the reason for this in https://github.com/kubernetes-client/python/blob/master/kubernetes/client/api_client.py#L260.
Eventually, for valid json we have this transformation (after deserialization):
str(json.loads(response))
Environment:
- Kubernetes version (
kubectl version): 1.23
- OS (e.g., MacOS 10.13.6): linux (fedora)
- Python version (
python --version): 3.11.7
- Python client version (
pip list | grep kubernetes): 29.0.0
Hi 👋,
I have a valid
jsonlog messages in my container.I would like to get a last log message:
It returns:
{'time': '2024-02-19T13:32:53.08943787Z', 'level': 'INFO', 'msg': 'some msg'}This is incorrect. There is single quotes in return. It should be:
{"time": "2024-02-19T13:32:53.08943787Z", "level": "INFO", "msg": "some msg"}I think, that the reason for this in https://github.com/kubernetes-client/python/blob/master/kubernetes/client/api_client.py#L260.
Eventually, for valid
jsonwe have this transformation (after deserialization):str(json.loads(response))Environment:
kubectl version): 1.23python --version): 3.11.7pip list | grep kubernetes): 29.0.0