Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/zabbix/zabbix.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgenii Gordymov <evgenii.gordymov@zabbix.com>2022-11-10 13:31:16 +0300
committerEvgenii Gordymov <evgenii.gordymov@zabbix.com>2022-11-10 13:31:16 +0300
commit34495a3c0dd27ed8dbce87068a258dfb9099da43 (patch)
tree15b1f21f83b07216da005295470224feca429895
parent3ef0650c4fd5b05cc6b36d0257249488c281b73e (diff)
.........T [ZBX-21588] optimized template k8s nodes by http
-rw-r--r--templates/app/kubernetes_http/kubernetes_nodes_http/README.md4
-rw-r--r--templates/app/kubernetes_http/kubernetes_nodes_http/template_kubernetes_nodes.yaml12
2 files changed, 3 insertions, 13 deletions
diff --git a/templates/app/kubernetes_http/kubernetes_nodes_http/README.md b/templates/app/kubernetes_http/kubernetes_nodes_http/README.md
index 582b34e5a0c..f1f83f25f09 100644
--- a/templates/app/kubernetes_http/kubernetes_nodes_http/README.md
+++ b/templates/app/kubernetes_http/kubernetes_nodes_http/README.md
@@ -119,7 +119,7 @@ There are no template links in this template.
|Kubernetes |Kubernetes: Get nodes |<p>Collecting and processing cluster nodes data via Kubernetes API.</p> |SCRIPT |kube.nodes<p>**Expression**:</p>`The text is too long. Please see the template.` |
|Kubernetes |Get nodes check |<p>Data collection check.</p> |DEPENDENT |kube.nodes.check<p>**Preprocessing**:</p><p>- JSONPATH: `$.error`</p><p>⛔️ON_FAIL: `CUSTOM_VALUE -> `</p><p>- DISCARD_UNCHANGED_HEARTBEAT: `3h`</p> |
|Kubernetes |Node LLD |<p>Generation of data for node discovery rules.</p> |DEPENDENT |kube.nodes.lld<p>**Preprocessing**:</p><p>- JAVASCRIPT: `function parseFilters(filter) { var pairs = {}; filter.split(/\s*,\s*/).forEach(function (kv) { if (/([\w\.-]+\/[\w\.-]+):\s*.+/.test(kv)) { var pair = kv.split(/\s*:\s*/); pairs[pair[0]] = pair[1]; } }); return pairs; } function filter(name, data, filters) { var filtered = true; if (typeof data === 'object') { Object.keys(filters).some(function (filter) { var exclude = filter.match(/^!(.+)/); if (filter in data || (exclude && exclude[1] in data)) { if ((exclude && new RegExp(filters[filter]).test(data[exclude[1]])) || (!exclude && !(new RegExp(filters[filter]).test(data[filter])))) { Zabbix.log(4, '[ Kubernetes discovery ] Discarded "' + name + '" by filter "' + filter + ': ' + filters[filter] + '"'); filtered = false; return true; } }; }); } return filtered; } try { var input = JSON.parse(value), output = []; api_url = '{$KUBE.API.ENDPOINT.URL}', hostname = api_url.match(/\/\/(.+):/); if (typeof hostname[1] === 'undefined') { Zabbix.log(4, '[ Kubernetes ] Received incorrect Kubernetes API url: ' + api_url + '. Expected format: <scheme>://<host>:<port>'); throw 'Cannot get hostname from Kubernetes API url. Check debug log for more information.'; }; if (typeof input !== 'object' || typeof input.items === 'undefined') { Zabbix.log(4, '[ Kubernetes ] Received incorrect JSON: ' + value); throw 'Incorrect JSON. Check debug log for more information.'; } var filterLabels = parseFilters('{$KUBE.NODE.FILTER.LABELS}'), filterAnnotations = parseFilters('{$KUBE.NODE.FILTER.ANNOTATIONS}'); input.items.forEach(function (node) { if (filter(node.metadata.name, node.metadata.labels, filterLabels) && filter(node.metadata.name, node.metadata.annotations, filterAnnotations)) { Zabbix.log(4, '[ Kubernetes discovery ] Filtered node "' + node.metadata.name + '"'); var internalIPs = node.status.addresses.filter(function (addr) { return addr.type === 'InternalIP'; }); var internalIP = internalIPs.length && internalIPs[0].address; if (internalIP in input.endpointIPs) { output.push({ '{#NAME}': node.metadata.name, '{#IP}': internalIP, '{#ROLES}': node.status.roles, '{#ARCH}': node.metadata.labels['kubernetes.io/arch'] || '', '{#OS}': node.metadata.labels['kubernetes.io/os'] || '', '{#CLUSTER_HOSTNAME}': hostname[1] }); } else { Zabbix.log(4, '[ Kubernetes discovery ] Node "' + node.metadata.name + '" is not included in the list of endpoint IPs'); } } }); return JSON.stringify(output); } catch (error) { error += (String(error).endsWith('.')) ? '' : '.'; Zabbix.log(3, '[ Kubernetes discovery ] ERROR: ' + error); throw 'Discovery error: ' + error; } `</p><p>- DISCARD_UNCHANGED_HEARTBEAT: `3h`</p> |
-|Kubernetes |Node [{#NAME}]: Get data |<p>Collecting and processing cluster by node [{#NAME}] data via Kubernetes API.</p> |DEPENDENT |kube.node.get[{#NAME}]<p>**Preprocessing**:</p><p>- JSONPATH: `$.items[?(@.metadata.name == "{#NAME}")].first()`</p><p>⛔️ON_FAIL: `DISCARD_VALUE -> `</p><p>- DISCARD_UNCHANGED_HEARTBEAT: `3h`</p> |
+|Kubernetes |Node [{#NAME}]: Get data |<p>Collecting and processing cluster by node [{#NAME}] data via Kubernetes API.</p> |DEPENDENT |kube.node.get[{#NAME}]<p>**Preprocessing**:</p><p>- JSONPATH: `$.items[?(@.metadata.name == "{#NAME}")].first()`</p> |
|Kubernetes |Node [{#NAME}] Addresses: External IP |<p>Typically the IP address of the node that is externally routable (available from outside the cluster).</p> |DEPENDENT |kube.node.addresses.external_ip[{#NAME}]<p>**Preprocessing**:</p><p>- JSONPATH: `$.status.addresses[?(@.type == "ExternalIP")].address.first()`</p><p>⛔️ON_FAIL: `DISCARD_VALUE -> `</p><p>- DISCARD_UNCHANGED_HEARTBEAT: `3h`</p> |
|Kubernetes |Node [{#NAME}] Addresses: Internal IP |<p>Typically the IP address of the node that is routable only within the cluster.</p> |DEPENDENT |kube.node.addresses.internal_ip[{#NAME}]<p>**Preprocessing**:</p><p>- JSONPATH: `$.status.addresses[?(@.type == "InternalIP")].address.first()`</p><p>⛔️ON_FAIL: `DISCARD_VALUE -> `</p><p>- DISCARD_UNCHANGED_HEARTBEAT: `3h`</p> |
|Kubernetes |Node [{#NAME}] Allocatable: CPU |<p>Allocatable CPU.</p><p>'Allocatable' on a Kubernetes node is defined as the amount of compute resources that are available for pods. The scheduler does not over-subscribe 'Allocatable'. 'CPU', 'memory' and 'ephemeral-storage' are supported as of now.</p> |DEPENDENT |kube.node.allocatable.cpu[{#NAME}]<p>**Preprocessing**:</p><p>- JSONPATH: `$.status.allocatable.cpu`</p> |
@@ -147,7 +147,7 @@ There are no template links in this template.
|Kubernetes |Node [{#NAME}] Requests: Memory |<p>Node Memory requests.</p><p>https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/</p> |DEPENDENT |kube.node.requests.memory[{#NAME}]<p>**Preprocessing**:</p><p>- JSONPATH: `$.pods[*].containers.requests.memory.sum()`</p> |
|Kubernetes |Node [{#NAME}] Uptime |<p>Node uptime.</p> |DEPENDENT |kube.node.uptime[{#NAME}]<p>**Preprocessing**:</p><p>- JSONPATH: `$.metadata.creationTimestamp`</p><p>⛔️ON_FAIL: `DISCARD_VALUE -> `</p><p>- JAVASCRIPT: `return Math.floor((Date.now() - new Date(value)) / 1000);`</p> |
|Kubernetes |Node [{#NAME}] Used: Pods |<p>Current number of pods on the node.</p> |DEPENDENT |kube.node.used.pods[{#NAME}]<p>**Preprocessing**:</p><p>- JSONPATH: `$.status.podsCount`</p> |
-|Kubernetes |Node [{#NODE}] Pod [{#POD}]: Get data |<p>Collecting and processing cluster by node [{#NODE}] data via Kubernetes API.</p> |DEPENDENT |kube.pod.get[{#POD}]<p>**Preprocessing**:</p><p>- JSONPATH: `$.items[?(@.metadata.name == "{#NODE}")].pods[?(@.name == "{#POD}")].first()`</p><p>⛔️ON_FAIL: `DISCARD_VALUE -> `</p><p>- DISCARD_UNCHANGED_HEARTBEAT: `3h`</p> |
+|Kubernetes |Node [{#NODE}] Pod [{#POD}]: Get data |<p>Collecting and processing cluster by node [{#NODE}] data via Kubernetes API.</p> |DEPENDENT |kube.pod.get[{#POD}]<p>**Preprocessing**:</p><p>- JSONPATH: `$.items[?(@.metadata.name == "{#NODE}")].pods[?(@.name == "{#POD}")].first()`</p> |
|Kubernetes |Node [{#NODE}] Pod [{#POD}] Conditions: Containers ready |<p>All containers in the Pod are ready.</p><p>https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-conditions</p> |DEPENDENT |kube.pod.conditions.containers_ready[{#POD}]<p>**Preprocessing**:</p><p>- JSONPATH: `$.conditions[?(@.type == "ContainersReady")].status.first()`</p><p>⛔️ON_FAIL: `DISCARD_VALUE -> `</p><p>- JAVASCRIPT: `return ['True', 'False', 'Unknown'].indexOf(value) + 1 || 'Problem with status processing in JS'; `</p> |
|Kubernetes |Node [{#NODE}] Pod [{#POD}] Conditions: Initialized |<p>All init containers have started successfully.</p><p>https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-conditions</p> |DEPENDENT |kube.pod.conditions.initialized[{#POD}]<p>**Preprocessing**:</p><p>- JSONPATH: `$.conditions[?(@.type == "Initialized")].status.first()`</p><p>⛔️ON_FAIL: `DISCARD_VALUE -> `</p><p>- JAVASCRIPT: `return ['True', 'False', 'Unknown'].indexOf(value) + 1 || 'Problem with status processing in JS'; `</p> |
|Kubernetes |Node [{#NODE}] Pod [{#POD}] Conditions: Ready |<p>The Pod is able to serve requests and should be added to the load balancing pools of all matching Services.</p><p>https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-conditions</p> |DEPENDENT |kube.pod.conditions.ready[{#POD}]<p>**Preprocessing**:</p><p>- JSONPATH: `$.conditions[?(@.type == "Ready")].status.first()`</p><p>⛔️ON_FAIL: `DISCARD_VALUE -> `</p><p>- JAVASCRIPT: `return ['True', 'False', 'Unknown'].indexOf(value) + 1 || 'Problem with status processing in JS'; `</p> |
diff --git a/templates/app/kubernetes_http/kubernetes_nodes_http/template_kubernetes_nodes.yaml b/templates/app/kubernetes_http/kubernetes_nodes_http/template_kubernetes_nodes.yaml
index 83a235ee487..7957c135b04 100644
--- a/templates/app/kubernetes_http/kubernetes_nodes_http/template_kubernetes_nodes.yaml
+++ b/templates/app/kubernetes_http/kubernetes_nodes_http/template_kubernetes_nodes.yaml
@@ -1,6 +1,6 @@
zabbix_export:
version: '6.4'
- date: '2022-10-28T14:15:00Z'
+ date: '2022-11-10T10:19:26Z'
template_groups:
-
uuid: a571c0d144b14fd4a87a9d9b2aa9fcd6
@@ -899,11 +899,6 @@ zabbix_export:
type: JSONPATH
parameters:
- '$.items[?(@.metadata.name == "{#NAME}")].first()'
- error_handler: DISCARD_VALUE
- -
- type: DISCARD_UNCHANGED_HEARTBEAT
- parameters:
- - 3h
master_item:
key: kube.nodes
tags:
@@ -1757,11 +1752,6 @@ zabbix_export:
type: JSONPATH
parameters:
- '$.items[?(@.metadata.name == "{#NODE}")].pods[?(@.name == "{#POD}")].first()'
- error_handler: DISCARD_VALUE
- -
- type: DISCARD_UNCHANGED_HEARTBEAT
- parameters:
- - 3h
master_item:
key: kube.nodes
tags: