cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

What is the correct IP Address of Kubernetes Node coming from the payload?

mango_byte
Visitor

Hi, 

I am trying to fetch KUBERNETES_NODE from Dynatrace v2 API, and I am getting the below payload, I want to use the IP Address value for the Node, but as you can see inside properties there is an array of internalIPAddresses which I am not confident to use as it is an array, so can contain more values in future, can you tell me which JSON key is correct here to fetch the value.

{
"totalCount": 1,
"pageSize": 50,
"entities": [
{
"entityId": "KUBERNETES_NODE-6C3263148CCF0B35",
"type": "KUBERNETES_NODE",
"displayName": "ip-10-2-0-116.us-east-2.compute.internal",
"properties": {
"kubernetesNodeConditions": {
"Ready": "NODE_CONDITION_TRUE",
"MemoryPressure": "NODE_CONDITION_FALSE",
"DiskPressure": "NODE_CONDITION_FALSE",
"PIDPressure": "NODE_CONDITION_FALSE"
},
"detectedName": "ip-10-2-0-116.us-east-2.compute.internal",
"internalIpAddresses": [
"10.2.0.116"
],
"kubernetesProviderType": "PROVIDER_TYPE_UNKNOWN",
"kubeletVersion": "v1.28.6+k3s2",
"kubernetesLabels": {
"kubernetes.io/hostname": "ip-10-2-0-116.us-east-2.compute.internal",
"kubernetes.io/arch": "amd64",
"kubernetes.io/os": "linux",
"beta.kubernetes.io/arch": "amd64",
"beta.kubernetes.io/instance-type": "k3s",
"beta.kubernetes.io/os": "linux",
"node-role.kubernetes.io/master": "true",
"node-role.kubernetes.io/control-plane": "true",
"node.kubernetes.io/instance-type": "k3s"
},
"kubernetesNodeUid": "61174194-cbad-4e74-bfed-10d54f21280f",
"ipAddress": [],
"osArchitecture": "X86",
"kubernetesNodeRoles": [
"control-plane",
"master"
],
"resourceCreationTimestamp": 1709231820000,
"osInfo": "Red Hat Enterprise Linux 8.9 (Ootpa)",
"kubernetesNodeStates": [
"NODE_STATE_READY"
],
"osVersion": "4.18.0-513.24.1.el8_9.x86_64",
"osType": "LINUX",
"kubernetesNodeCordoned": false,
"kubernetesConditions": [
{
"type": "MemoryPressure",
"status": "False",
"reason": "KubeletHasSufficientMemory",
"message": "kubelet has sufficient memory available",
"lastTransitionTimestamp": 1709231820000
},
{
"type": "DiskPressure",
"status": "False",
"reason": "KubeletHasNoDiskPressure",
"message": "kubelet has no disk pressure",
"lastTransitionTimestamp": 1709231820000
},
{
"type": "PIDPressure",
"status": "False",
"reason": "KubeletHasSufficientPID",
"message": "kubelet has sufficient PID available",
"lastTransitionTimestamp": 1709231820000
},
{
"type": "Ready",
"status": "True",
"reason": "KubeletReady",
"message": "kubelet is posting ready status",
"lastTransitionTimestamp": 1713564532000
}
],
"kubernetesAnnotations": {
"flannel.alpha.coreos.com/kube-subnet-manager": "true",
"flannel.alpha.coreos.com/public-ip": "10.2.0.116",
"flannel.alpha.coreos.com/backend-data": "{\"VNI\":1,\"VtepMAC\":\"4a:d8:f9:b1:13:b5\"}",
"k3s.io/node-env": "{\"K3S_DATA_DIR\":\"/var/lib/rancher/k3s/data/13f9723ffde84ba41d08658d407a523bcf32698f179c9ab30cc0534e1e5d2c1a\"}",
"alpha.kubernetes.io/provided-node-ip": "10.2.0.116",
"csi.volume.kubernetes.io/nodeid": "{\"csi.oneagent.dynatrace.com\":\"ip-10-2-0-116.us-east-2.compute.internal\"}",
"k3s.io/internal-ip": "10.2.0.116",
"k3s.io/node-config-hash": "BJHH2XQGHLYI42QVGO2SCCACG6GVKD3ZJOPRCC2BAMYZKNGH5ZRA====",
"k3s.io/node-args": "[\"server\",\"--write-kubeconfig-mode\",\"644\"]",
"node.alpha.kubernetes.io/ttl": "0",
"volumes.kubernetes.io/controller-managed-attach-detach": "true",
"k3s.io/hostname": "ip-10-2-0-116.us-east-2.compute.internal",
"flannel.alpha.coreos.com/backend-type": "vxlan"
},
"kubernetesNodeSystemUuid": "ec2d527e-261a-3d17-96d6-5c792a6d9a61"
},
"tags": [],
"managementZones": [],
"fromRelationships": {},
"toRelationships": {
"isClusterOfNode": [
{
"id": "KUBERNETES_CLUSTER-DFDB0908FE53A2C5",
"type": "KUBERNETES_CLUSTER"
}
],
"runsOn": [
{
"id": "CLOUD_APPLICATION_INSTANCE-2C3937ABC0B41D2A",
"type": "CLOUD_APPLICATION_INSTANCE"
},
{
"id": "CLOUD_APPLICATION_INSTANCE-79F69884F8AAFB0E",
"type": "CLOUD_APPLICATION_INSTANCE"
},
{
"id": "CLOUD_APPLICATION_INSTANCE-9D35DD4552C5DC83",
"type": "CLOUD_APPLICATION_INSTANCE"
},
{
"id": "CLOUD_APPLICATION_INSTANCE-506D8FAC97BBE08E",
"type": "CLOUD_APPLICATION_INSTANCE"
},
{
"id": "CLOUD_APPLICATION_INSTANCE-125BFE8FFFC86409",
"type": "CLOUD_APPLICATION_INSTANCE"
},
{
"id": "CLOUD_APPLICATION_INSTANCE-E0E37E101508CCEE",
"type": "CLOUD_APPLICATION_INSTANCE"
},
{
"id": "CLOUD_APPLICATION_INSTANCE-FDC6DEE3AD5BBFE4",
"type": "CLOUD_APPLICATION_INSTANCE"
},
{
"id": "CLOUD_APPLICATION_INSTANCE-5FE59D4583F0A96B",
"type": "CLOUD_APPLICATION_INSTANCE"
},
{
"id": "CLOUD_APPLICATION_INSTANCE-1D02284EB35AC46A",
"type": "CLOUD_APPLICATION_INSTANCE"
},
{
"id": "CLOUD_APPLICATION_INSTANCE-B32BF387BA0C6D78",
"type": "CLOUD_APPLICATION_INSTANCE"
},
{
"id": "CLOUD_APPLICATION_INSTANCE-19F737A539EB610C",
"type": "CLOUD_APPLICATION_INSTANCE"
},
{
"id": "CLOUD_APPLICATION_INSTANCE-F978924A90C0138C",
"type": "CLOUD_APPLICATION_INSTANCE"
},
{
"id": "CLOUD_APPLICATION_INSTANCE-F74F861AB05E4CB5",
"type": "CLOUD_APPLICATION_INSTANCE"
},
{
"id": "CLOUD_APPLICATION_INSTANCE-841A8A74FDE79430",
"type": "CLOUD_APPLICATION_INSTANCE"
},
{
"id": "CLOUD_APPLICATION_INSTANCE-8AF32F066F9DE375",
"type": "CLOUD_APPLICATION_INSTANCE"
},
{
"id": "CLOUD_APPLICATION_INSTANCE-4C91BE3F109E384E",
"type": "CLOUD_APPLICATION_INSTANCE"
},
{
"id": "CLOUD_APPLICATION_INSTANCE-EE59E94601FCC08F",
"type": "CLOUD_APPLICATION_INSTANCE"
},
{
"id": "CLOUD_APPLICATION_INSTANCE-1F0BA2D056DB1FAE",
"type": "CLOUD_APPLICATION_INSTANCE"
}
],
"isRuntimeComponentOf": [
{
"id": "RUNTIME_COMPONENT-FCC80119E6ABADE6",
"type": "RUNTIME_COMPONENT"
}
]
}
}
]
}
Thanks!
1 REPLY 1

mark_bley
Dynatrace Pro
Dynatrace Pro

 

You need to pass it in the entitySelector e.g.:

type(kubernetes_node),internalIpAddresses("10.1.0.2")
type(kubernetes_node),ipAddress("35.232.10.123")

 Full example

curl -X 'GET' \
  'https://xxxxxxxx.dynatrace.com/api/v2/entities?entitySelector=type%28kubernetes_node%29%2CinternalIpAddresses%28%2210.1.0.2%22%29' \
  -H 'accept: application/json; charset=utf-8' \
  -H 'Authorization: Api-Token dt0c01.KWAU4Z77M7ZBIKIBRW6MZLIB.'

 

Featured Posts