[question] <title>use jsonpath parse k8s api reponse error
Is there an existing issue for this?
- [x] I have searched the existing issues
Current Behavior
when i use $.status.containerStatuses[0].restartCount to monito k8s pods restart_count i can't get any reponse
Expected Behavior
i can get restart_count = 3
Steps To Reproduce
1、i update kubernate yaml to monitor pods restartCount
2、here is response to parse
{ "metadata": { }, "spec": { }, "status": { "phase": "Running", "conditions": [ { "type": "PodReadyToStartContainers", "status": "True", "lastProbeTime": null, "lastTransitionTime": "2025-04-13T04:23:42Z" }, { "type": "Initialized", "status": "True", "lastProbeTime": null, "lastTransitionTime": "2025-01-22T02:01:01Z" }, { "type": "Ready", "status": "True", "lastProbeTime": null, "lastTransitionTime": "2025-04-13T04:23:42Z" }, { "type": "ContainersReady", "status": "True", "lastProbeTime": null, "lastTransitionTime": "2025-04-13T04:23:42Z" }, { "type": "PodScheduled", "status": "True", "lastProbeTime": null, "lastTransitionTime": "2025-01-22T02:01:01Z" } ], "hostIP": "100.100.100.31", "hostIPs": [ { "ip": "100.100.100.31" } ], "podIP": "10.42.0.92", "podIPs": [ { "ip": "10.42.0.92" } ], "startTime": "2025-01-22T02:01:01Z", "containerStatuses": [ { "name": "local-path-provisioner", "state": { "running": { "startedAt": "2025-04-13T04:23:39Z" } }, "lastState": { "terminated": { "exitCode": 137, "reason": "Error", "startedAt": "2025-03-16T12:11:13Z", "finishedAt": "2025-04-11T07:46:31Z", "containerID": "docker://fefaa267dcec7a13f200d1a25c033bc870bdbf9d142672b85f71f2e9ac70e32d" } }, "ready": true, "restartCount": 3, "image": "rancher/local-path-provisioner:v0.0.27", "imageID": "docker://sha256:c451116631150877804885d6195d011eec2666388f9668097dc598be9326959e", "containerID": "docker://1a705ffde1a5ec10e3c589fec94183661c1b8842a1dc7238727a2fecc52a0e8c", "started": true } ], "qosClass": "BestEffort" } }
3、when i use $.status.containerStatuses[0] i can get data, but when i use $.status.containerStatuses[0].restartCount i can't get data
Environment
HertzBeat version(s):1.7.0
Debug logs
No response
Anything else?
No response
{ "metadata": { }, "spec": { }, "status": { "phase": "Running", "conditions": [ { "type": "PodReadyToStartContainers", "status": "True", "lastProbeTime": null, "lastTransitionTime": "2025-04-13T04:23:42Z" }, { "type": "Initialized", "status": "True", "lastProbeTime": null, "lastTransitionTime": "2025-01-22T02:01:01Z" }, { "type": "Ready", "status": "True", "lastProbeTime": null, "lastTransitionTime": "2025-04-13T04:23:42Z" }, { "type": "ContainersReady", "status": "True", "lastProbeTime": null, "lastTransitionTime": "2025-04-13T04:23:42Z" }, { "type": "PodScheduled", "status": "True", "lastProbeTime": null, "lastTransitionTime": "2025-01-22T02:01:01Z" } ], "hostIP": "100.100.100.31", "hostIPs": [ { "ip": "100.100.100.31" } ], "podIP": "10.42.0.92", "podIPs": [ { "ip": "10.42.0.92" } ], "startTime": "2025-01-22T02:01:01Z", "containerStatuses": [ { "name": "local-path-provisioner", "state": { "running": { "startedAt": "2025-04-13T04:23:39Z" } }, "lastState": { "terminated": { "exitCode": 137, "reason": "Error", "startedAt": "2025-03-16T12:11:13Z", "finishedAt": "2025-04-11T07:46:31Z", "containerID": "docker://fefaa267dcec7a13f200d1a25c033bc870bdbf9d142672b85f71f2e9ac70e32d" } }, "ready": true, "restartCount": 3, "image": "rancher/local-path-provisioner:v0.0.27", "imageID": "docker://sha256:c451116631150877804885d6195d011eec2666388f9668097dc598be9326959e", "containerID": "docker://1a705ffde1a5ec10e3c589fec94183661c1b8842a1dc7238727a2fecc52a0e8c", "started": true } ], "qosClass": "BestEffort" } }
hi, the response you gave does not include restart_count
{ "metadata": { }, "spec": { }, "status": { "phase": "Running", "conditions": [ { "type": "PodReadyToStartContainers", "status": "True", "lastProbeTime": null, "lastTransitionTime": "2025-04-13T04:23:42Z" }, { "type": "Initialized", "status": "True", "lastProbeTime": null, "lastTransitionTime": "2025-01-22T02:01:01Z" }, { "type": "Ready", "status": "True", "lastProbeTime": null, "lastTransitionTime": "2025-04-13T04:23:42Z" }, { "type": "ContainersReady", "status": "True", "lastProbeTime": null, "lastTransitionTime": "2025-04-13T04:23:42Z" }, { "type": "PodScheduled", "status": "True", "lastProbeTime": null, "lastTransitionTime": "2025-01-22T02:01:01Z" } ], "hostIP": "100.100.100.31", "hostIPs": [ { "ip": "100.100.100.31" } ], "podIP": "10.42.0.92", "podIPs": [ { "ip": "10.42.0.92" } ], "startTime": "2025-01-22T02:01:01Z", "containerStatuses": [ { "name": "local-path-provisioner", "state": { "running": { "startedAt": "2025-04-13T04:23:39Z" } }, "lastState": { "terminated": { "exitCode": 137, "reason": "Error", "startedAt": "2025-03-16T12:11:13Z", "finishedAt": "2025-04-11T07:46:31Z", "containerID": "docker://fefaa267dcec7a13f200d1a25c033bc870bdbf9d142672b85f71f2e9ac70e32d" } }, "ready": true, "restartCount": 3, "image": "rancher/local-path-provisioner:v0.0.27", "imageID": "docker://sha256:c451116631150877804885d6195d011eec2666388f9668097dc598be9326959e", "containerID": "docker://1a705ffde1a5ec10e3c589fec94183661c1b8842a1dc7238727a2fecc52a0e8c", "started": true } ], "qosClass": "BestEffort" } }hi, the response you gave does not include
restart_count
here is one part of my yml:
- name: pods priority: 2 fields: - field: pod type: 1 i18n: zh-CN: Pod名称 en-US: Pod Name - field: namespace type: 1 i18n: zh-CN: 命名空间 en-US: Namespace - field: status type: 1 i18n: zh-CN: 状态 en-US: Status - field: restart type: 1 i18n: zh-CN: 重启策略 en-US: Restart - field: restart_count type: 1 i18n: zh-CN: 重启次数 en-US: Restart Count - field: host_ip type: 1 i18n: zh-CN: 主机IP en-US: Host IP - field: pod_ip type: 1 i18n: zh-CN: Pod IP en-US: Pod IP - field: creation_time type: 1 i18n: zh-CN: 创建时间 en-US: Creation Time - field: start_time type: 1 i18n: zh-CN: 启动时间 en-US: Start Time aliasFields: - $.metadata.name - $.metadata.namespace - $.status.phase - $.spec.restartPolicy - $.status.hostIP - $.status.podIP - $.metadata.creationTimestamp - $.status.startTime - $.status.containerStatuses[0].restartCount calculates: - pod=$.metadata.name - namespace=$.metadata.namespace - status=$.status.phase - restart=$.spec.restartPolicy - host_ip=$.status.hostIP - pod_ip=$.status.podIP - creation_time=$.metadata.creationTimestamp - start_time=$.status.startTime - restart_count=$.status.containerStatuses[0].restartCount