zabbix_export: version: '6.0' date: '2021-11-21T21:58:54Z' groups: - uuid: cec0a59074054ddebfef4981adbc9439 name: 'Templates App' templates: - uuid: 0d4a0202e2f04f3184b2e169b574e9b0 template: 'App Nutcracker' name: 'App Nutcracker' description: | ## Overview Template for collecting [nutcracker (twemproxy)](https://github.com/twitter/twemproxy) metrics. By default template use system.run to collect metrics from (can be altered via macro) via zabbix-agent, but it can be changed to userparameter or http agent if remote commands are forbidden. Some of the features: * Pool and server discovery. * Single request for LLD and metrics. * Minimum host dependencies - only curl needed if system.run used. No host dependencies with http agent. * No host scripts, utilizing Zabbix features: dependent items and JavaScript preprocessing. ## Author Oleg Morozov aka zigmund groups: - name: 'Templates App' items: - uuid: e68bbe4cb60342e69fe9834686d4f12f name: 'Nutcracker current connections' type: DEPENDENT key: 'nutcracker[stats,curr_connections]' delay: '0' history: 7d trends: 90d description: 'Number of all active connections (client + server)' preprocessing: - type: JSONPATH parameters: - $.curr_connections - type: DISCARD_UNCHANGED_HEARTBEAT parameters: - 10m master_item: key: 'system.run[curl -s {$NUTCRACKER_URL}]' tags: - tag: Application value: Nutcracker - uuid: 9d397bb48d8747b1a6767058b6b7f9e0 name: 'Nutcracker connections per second' type: DEPENDENT key: 'nutcracker[stats,total_connections]' delay: '0' history: 7d trends: 90d value_type: FLOAT description: 'Number of new connections per second' preprocessing: - type: JSONPATH parameters: - $.total_connections - type: CHANGE_PER_SECOND parameters: - '' - type: DISCARD_UNCHANGED_HEARTBEAT parameters: - 10m master_item: key: 'system.run[curl -s {$NUTCRACKER_URL}]' tags: - tag: Application value: Nutcracker - uuid: 0c7f0683b9894f51b60b8aeb50a473ac name: 'Number of nutcracker processes' type: ZABBIX_ACTIVE key: 'proc.num[nutcracker]' history: '0' trends: '0' tags: - tag: Application value: Nutcracker triggers: - uuid: ef4d304929cc415bb54c8021e632fc24 expression: 'last(/App Nutcracker/proc.num[nutcracker])=0' name: 'Nutcracker is dead' priority: HIGH - uuid: 4d2c1739897d4fb59afda9c0b687a7fc name: 'Nutcracker stats' type: ZABBIX_ACTIVE key: 'system.run[curl -s {$NUTCRACKER_URL}]' history: '0' trends: '0' value_type: TEXT description: 'Nutcracker JSON stats' tags: - tag: Application value: Nutcracker discovery_rules: - uuid: c925f45d9af84ba68d513a52e9ec693e name: 'Pool discovery' type: DEPENDENT key: 'nutcracker[stats,pool_discovery]' delay: '0' lifetime: 7d item_prototypes: - uuid: 6cd0d65ed74240f8ac4fb3523180012d name: 'Nutcracker pool {#POOL} client connections' type: DEPENDENT key: 'nutcracker[stats,pools,{#POOL},client_connections]' delay: '0' history: 7d trends: 90d description: 'Number of active client connections' preprocessing: - type: JSONPATH parameters: - '$[''{#POOL}''][''client_connections'']' - type: DISCARD_UNCHANGED_HEARTBEAT parameters: - 10m master_item: key: 'system.run[curl -s {$NUTCRACKER_URL}]' tags: - tag: Application value: Nutcracker - uuid: fe070580558f4d96b6350810be8b4833 name: 'Nutcracker pool {#POOL} client EOF per second' type: DEPENDENT key: 'nutcracker[stats,pools,{#POOL},client_eof]' delay: '0' history: 7d trends: 90d value_type: FLOAT description: 'Number of eof on client connections per second' preprocessing: - type: JSONPATH parameters: - '$[''{#POOL}''][''client_eof'']' - type: CHANGE_PER_SECOND parameters: - '' - type: DISCARD_UNCHANGED_HEARTBEAT parameters: - 10m master_item: key: 'system.run[curl -s {$NUTCRACKER_URL}]' tags: - tag: Application value: Nutcracker - uuid: 5fd7dc10e2384f55becab2ab9770d0af name: 'Nutcracker pool {#POOL} client errors per second' type: DEPENDENT key: 'nutcracker[stats,pools,{#POOL},client_err]' delay: '0' history: 7d trends: 90d value_type: FLOAT description: 'Number of errors on client connections per second' preprocessing: - type: JSONPATH parameters: - '$[''{#POOL}''][''client_err'']' - type: CHANGE_PER_SECOND parameters: - '' - type: DISCARD_UNCHANGED_HEARTBEAT parameters: - 10m master_item: key: 'system.run[curl -s {$NUTCRACKER_URL}]' tags: - tag: Application value: Nutcracker - uuid: 6b42f6d679134db8b41b65aa145ccd6d name: 'Nutcracker pool {#POOL} forward errors per second' type: DEPENDENT key: 'nutcracker[stats,pools,{#POOL},forward_error]' delay: '0' history: 7d trends: 90d value_type: FLOAT description: 'Number of forwarding errors per second' preprocessing: - type: JSONPATH parameters: - '$[''{#POOL}''][''forward_error'']' - type: CHANGE_PER_SECOND parameters: - '' - type: DISCARD_UNCHANGED_HEARTBEAT parameters: - 10m master_item: key: 'system.run[curl -s {$NUTCRACKER_URL}]' tags: - tag: Application value: Nutcracker trigger_prototypes: - uuid: 5850d2289e3f4ff18f08e4e0432d86f4 expression: 'last(/App Nutcracker/nutcracker[stats,pools,{#POOL},forward_error])>0' name: 'Nutcracker pool {#POOL} forward errors' priority: AVERAGE - uuid: 3acf34f97a4d44c6909de5611e04066b name: 'Nutcracker pool {#POOL} fragments per second' type: DEPENDENT key: 'nutcracker[stats,pools,{#POOL},fragments]' delay: '0' history: 7d trends: 90d value_type: FLOAT description: 'Number of fragments created from a multi-vector request per second' preprocessing: - type: JSONPATH parameters: - '$[''{#POOL}''][''fragments'']' - type: CHANGE_PER_SECOND parameters: - '' - type: DISCARD_UNCHANGED_HEARTBEAT parameters: - 10m master_item: key: 'system.run[curl -s {$NUTCRACKER_URL}]' tags: - tag: Application value: Nutcracker - uuid: d225948a133a4e1c8fd02dd964e8f56e name: 'Nutcracker pool {#POOL} server ejects per second' type: DEPENDENT key: 'nutcracker[stats,pools,{#POOL},server_ejects]' delay: '0' history: 7d trends: 90d value_type: FLOAT description: 'Number of times backend server was ejected per second' preprocessing: - type: JSONPATH parameters: - '$[''{#POOL}''][''server_ejects'']' - type: CHANGE_PER_SECOND parameters: - '' - type: DISCARD_UNCHANGED_HEARTBEAT parameters: - 10m master_item: key: 'system.run[curl -s {$NUTCRACKER_URL}]' tags: - tag: Application value: Nutcracker master_item: key: 'system.run[curl -s {$NUTCRACKER_URL}]' preprocessing: - type: JAVASCRIPT parameters: - | var stats = JSON.parse(value), pool_keys = Object.keys(stats), pools = []; for(var i in pool_keys) { if(typeof stats[pool_keys[i]] === 'object') { pools.push({"{#POOL}": pool_keys[i]}); } } return JSON.stringify(pools) - uuid: cd73ede6d6bd44b1b1f7ee4da81c8fc2 name: 'Server discovery' type: DEPENDENT key: 'nutcracker[stats,server_discovery]' delay: '0' lifetime: 7d item_prototypes: - uuid: a7f33ff8859a49909929cc860b991a0a name: 'Nutcracker server {#POOL}/{#SERVER} incoming queue requests' type: DEPENDENT key: 'nutcracker[stats,servers,{#POOL},{#SERVER},in_queue]' delay: '0' history: 7d trends: 90d units: B description: 'Current number of requests in incoming queue' preprocessing: - type: JSONPATH parameters: - '$[''{#POOL}''][''{#SERVER}''][''in_queue'']' - type: DISCARD_UNCHANGED_HEARTBEAT parameters: - 10m master_item: key: 'system.run[curl -s {$NUTCRACKER_URL}]' tags: - tag: Application value: Nutcracker - uuid: 32a41f41977e4cbb94d5639a3451d6dd name: 'Nutcracker server {#POOL}/{#SERVER} incoming queue bytes' type: DEPENDENT key: 'nutcracker[stats,servers,{#POOL},{#SERVER},in_queue_bytes]' delay: '0' history: 7d trends: 90d units: B description: 'Current number of bytes in incoming queue' preprocessing: - type: JSONPATH parameters: - '$[''{#POOL}''][''{#SERVER}''][''in_queue_bytes'']' - type: DISCARD_UNCHANGED_HEARTBEAT parameters: - 10m master_item: key: 'system.run[curl -s {$NUTCRACKER_URL}]' tags: - tag: Application value: Nutcracker - uuid: 042f5562ccff414a9a8205abe3a03df1 name: 'Nutcracker server {#POOL}/{#SERVER} outgoing queue requests' type: DEPENDENT key: 'nutcracker[stats,servers,{#POOL},{#SERVER},out_queue]' delay: '0' history: 7d trends: 90d description: 'Current number of requests in outgoing queue' preprocessing: - type: JSONPATH parameters: - '$[''{#POOL}''][''{#SERVER}''][''out_queue'']' - type: DISCARD_UNCHANGED_HEARTBEAT parameters: - 10m master_item: key: 'system.run[curl -s {$NUTCRACKER_URL}]' tags: - tag: Application value: Nutcracker - uuid: 92e66f6ee230472b896257c6c8ef3ead name: 'Nutcracker server {#POOL}/{#SERVER} outgoing queue bytes' type: DEPENDENT key: 'nutcracker[stats,servers,{#POOL},{#SERVER},out_queue_bytes]' delay: '0' history: 7d trends: 90d units: B description: 'Current number of bytes in outgoing queue' preprocessing: - type: JSONPATH parameters: - '$[''{#POOL}''][''{#SERVER}''][''out_queue_bytes'']' - type: DISCARD_UNCHANGED_HEARTBEAT parameters: - 10m master_item: key: 'system.run[curl -s {$NUTCRACKER_URL}]' tags: - tag: Application value: Nutcracker - uuid: 7d22342c622c4fcf8bf628edbe4e9c62 name: 'Nutcracker server {#POOL}/{#SERVER} requests per second' type: DEPENDENT key: 'nutcracker[stats,servers,{#POOL},{#SERVER},requests]' delay: '0' history: 7d trends: 90d value_type: FLOAT units: rps description: 'Number of requests per second' preprocessing: - type: JSONPATH parameters: - '$[''{#POOL}''][''{#SERVER}''][''requests'']' - type: CHANGE_PER_SECOND parameters: - '' - type: DISCARD_UNCHANGED_HEARTBEAT parameters: - 10m master_item: key: 'system.run[curl -s {$NUTCRACKER_URL}]' tags: - tag: Application value: Nutcracker - uuid: 7d4b0547675847e9b201812607fc9c9e name: 'Nutcracker server {#POOL}/{#SERVER} request bytes per second' type: DEPENDENT key: 'nutcracker[stats,servers,{#POOL},{#SERVER},request_bytes]' delay: '0' history: 7d trends: 90d value_type: FLOAT units: Bps description: 'Number of request bytes per second' preprocessing: - type: JSONPATH parameters: - '$[''{#POOL}''][''{#SERVER}''][''request_bytes'']' - type: CHANGE_PER_SECOND parameters: - '' - type: DISCARD_UNCHANGED_HEARTBEAT parameters: - 10m master_item: key: 'system.run[curl -s {$NUTCRACKER_URL}]' tags: - tag: Application value: Nutcracker - uuid: 4718f0170bbf45fc9d021a29ee3014ab name: 'Nutcracker server {#POOL}/{#SERVER} responses per second' type: DEPENDENT key: 'nutcracker[stats,servers,{#POOL},{#SERVER},responses]' delay: '0' history: 7d trends: 90d value_type: FLOAT units: rps description: 'Number of responses per second' preprocessing: - type: JSONPATH parameters: - '$[''{#POOL}''][''{#SERVER}''][''responses'']' - type: CHANGE_PER_SECOND parameters: - '' - type: DISCARD_UNCHANGED_HEARTBEAT parameters: - 10m master_item: key: 'system.run[curl -s {$NUTCRACKER_URL}]' tags: - tag: Application value: Nutcracker - uuid: ee0fa5424c2d4bb684e3a05d01e6f7e0 name: 'Nutcracker server {#POOL}/{#SERVER} response bytes per second' type: DEPENDENT key: 'nutcracker[stats,servers,{#POOL},{#SERVER},response_bytes]' delay: '0' history: 7d trends: 90d value_type: FLOAT units: Bps description: 'Number of response bytes per second' preprocessing: - type: JSONPATH parameters: - '$[''{#POOL}''][''{#SERVER}''][''response_bytes'']' - type: CHANGE_PER_SECOND parameters: - '' - type: DISCARD_UNCHANGED_HEARTBEAT parameters: - 10m master_item: key: 'system.run[curl -s {$NUTCRACKER_URL}]' tags: - tag: Application value: Nutcracker - uuid: 2aeb691b4fcb4492b5b4949ab5fec047 name: 'Nutcracker server {#POOL}/{#SERVER} connections' type: DEPENDENT key: 'nutcracker[stats,servers,{#POOL},{#SERVER},server_connections]' delay: '0' history: 7d trends: 90d description: 'Number of active server connections' preprocessing: - type: JSONPATH parameters: - '$[''{#POOL}''][''{#SERVER}''][''server_connections'']' - type: DISCARD_UNCHANGED_HEARTBEAT parameters: - 10m master_item: key: 'system.run[curl -s {$NUTCRACKER_URL}]' tags: - tag: Application value: Nutcracker - uuid: 43368090a16447d49a55e686175e1658 name: 'Nutcracker server {#POOL}/{#SERVER} last ejection timestamp' type: DEPENDENT key: 'nutcracker[stats,servers,{#POOL},{#SERVER},server_ejected_at]' delay: '0' history: 7d trends: 90d units: unixtime description: 'Last time when server was ejected at' preprocessing: - type: JSONPATH parameters: - '$[''{#POOL}''][''{#SERVER}''][''server_ejected_at'']' - type: MULTIPLIER parameters: - '0.000001' - type: DISCARD_UNCHANGED_HEARTBEAT parameters: - 10m master_item: key: 'system.run[curl -s {$NUTCRACKER_URL}]' tags: - tag: Application value: Nutcracker trigger_prototypes: - uuid: 0d2147eb948c425fbb01fc8b6992c95e expression: 'change(/App Nutcracker/nutcracker[stats,servers,{#POOL},{#SERVER},server_ejected_at])>1' name: 'Nutcracker server {#POOL}/{#SERVER} was ejected' priority: AVERAGE - uuid: da2c08a3505741e285a4236fd62141ed name: 'Nutcracker server {#POOL}/{#SERVER} EOF per second' type: DEPENDENT key: 'nutcracker[stats,servers,{#POOL},{#SERVER},server_eof]' delay: '0' history: 7d trends: 90d value_type: FLOAT description: 'Number of eof on server connections per second' preprocessing: - type: JSONPATH parameters: - '$[''{#POOL}''][''{#SERVER}''][''server_eof'']' - type: CHANGE_PER_SECOND parameters: - '' - type: DISCARD_UNCHANGED_HEARTBEAT parameters: - 10m master_item: key: 'system.run[curl -s {$NUTCRACKER_URL}]' tags: - tag: Application value: Nutcracker - uuid: d5b3171fcfe24e6791b8e72a4003cb5e name: 'Nutcracker server {#POOL}/{#SERVER} errors per second' type: DEPENDENT key: 'nutcracker[stats,servers,{#POOL},{#SERVER},server_err]' delay: '0' history: 7d trends: 90d value_type: FLOAT description: 'Number of errors on server connections per second' preprocessing: - type: JSONPATH parameters: - '$[''{#POOL}''][''{#SERVER}''][''server_err'']' - type: CHANGE_PER_SECOND parameters: - '' - type: DISCARD_UNCHANGED_HEARTBEAT parameters: - 10m master_item: key: 'system.run[curl -s {$NUTCRACKER_URL}]' tags: - tag: Application value: Nutcracker trigger_prototypes: - uuid: 7addd4303cdb462b9f0a18e385f8fbb7 expression: 'last(/App Nutcracker/nutcracker[stats,servers,{#POOL},{#SERVER},server_err])>0' name: 'Nutcracker server {#POOL}/{#SERVER} errors' priority: AVERAGE - uuid: 06286e40010947089eebbf0fe144e088 name: 'Nutcracker server {#POOL}/{#SERVER} timeouts per second' type: DEPENDENT key: 'nutcracker[stats,servers,{#POOL},{#SERVER},server_timedout]' delay: '0' history: 7d trends: 90d value_type: FLOAT description: 'Number of timeouts on server connections per second' preprocessing: - type: JSONPATH parameters: - '$[''{#POOL}''][''{#SERVER}''][''server_timedout'']' - type: CHANGE_PER_SECOND parameters: - '' - type: DISCARD_UNCHANGED_HEARTBEAT parameters: - 10m master_item: key: 'system.run[curl -s {$NUTCRACKER_URL}]' tags: - tag: Application value: Nutcracker master_item: key: 'system.run[curl -s {$NUTCRACKER_URL}]' preprocessing: - type: JAVASCRIPT parameters: - | var stats = JSON.parse(value), pool_keys = Object.keys(stats), servers = []; for(var i in pool_keys) { if(typeof stats[pool_keys[i]] === 'object') { var server_keys = Object.keys(stats[pool_keys[i]]); for(var j in server_keys) { if(typeof stats[pool_keys[i]][server_keys[j]] === 'object') { servers.push({"{#POOL}": pool_keys[i], "{#SERVER}": server_keys[j]}); } } } } return JSON.stringify(servers) macros: - macro: '{$NUTCRACKER_URL}' value: 'http://localhost:22222' description: 'Nutcracker stats URL'