Hi,
I have an issue on MetricBeat v8.4.2.
I use it to collect Kubernetes (v1.22.2) metrics.
But i always have kubernetes.container.memory.usage.bytes
and kubernetes.pod.memory.usage.bytes
at 0
Here are my clusterRoles:
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: metricbeat
labels:
k8s-app: metricbeat
rules:
- apiGroups: [""]
resources:
- nodes
- namespaces
- events
- pods
- services
verbs: ["get", "list", "watch"]
# Enable this rule only if planing to use Kubernetes keystore
#- apiGroups: [""]
# resources:
# - secrets
# verbs: ["get"]
- apiGroups: ["extensions"]
resources:
- replicasets
verbs: ["get", "list", "watch"]
- apiGroups: ["apps"]
resources:
- statefulsets
- deployments
- replicasets
verbs: ["get", "list", "watch"]
- apiGroups: ["batch"]
resources:
- jobs
- cronjobs
verbs: ["get", "list", "watch"]
- apiGroups:
- ""
resources:
- nodes/stats
verbs:
- get
- nonResourceURLs:
- "/metrics"
verbs:
- get
If i run this cmd under the metricbeat daemonset pod:
curl -k https://${NODE_NAME}:10250/stats/summary --header "Authorization: Bearer $TOKEN"
I have my pod memory usage:
{
"podRef": {
"name": "my-pod",
"namespace": "default",
"uid": "7be45b82-0395-4ae9-a0ab-7c275c121565"
},
"startTime": "2022-10-27T15:42:12Z",
"containers": [
{
"name": "postgres",
"startTime": "2022-10-27T15:42:15Z",
"cpu": {
"time": "2022-10-27T16:02:59Z",
"usageNanoCores": 3272512,
"usageCoreNanoSeconds": 19228071000
},
"memory": {
"time": "2022-10-27T16:02:59Z",
"workingSetBytes": 148652032
},
"rootfs": {
"time": "2022-10-27T16:02:52Z",
"availableBytes": 110666403840,
"capacityBytes": 135102586880,
"usedBytes": 196608,
"inodesFree": 8147061,
"inodes": 8380416,
"inodesUsed": 60
},
"logs": {
"time": "2022-10-27T16:02:59Z",
"availableBytes": 110666403840,
"capacityBytes": 135102586880,
"usedBytes": 45056,
"inodesFree": 8147061,
"inodes": 8380416,
"inodesUsed": 1
}
}
],
"cpu": {
"time": "2022-10-27T16:02:58Z",
"usageNanoCores": 3221979,
"usageCoreNanoSeconds": 19417139000
},
"memory": {
"time": "2022-10-27T16:02:58Z",
"availableBytes": 7367151616,
"usageBytes": 190943232,
"workingSetBytes": 149041152,
"rssBytes": 41623552,
"pageFaults": 803187,
"majorPageFaults": 0
},
After small investigation container memory and CPU usage are removed from kubelet here
But on metricbeat, we calculate the pod memory usage based on the container memory usage here.
That's an issue for me to calculate the pod.memory.usageBytes with a non existing metrics. we have to reuse the provided values from kubelet
Related issue: We are not seeing metrics for cpu, memory and network · Issue #31124 · elastic/beats · GitHub