diff options
author | Yulia Chukina <yulia.chukina@zabbix.com> | 2022-07-08 12:33:45 +0300 |
---|---|---|
committer | Yulia Chukina <yulia.chukina@zabbix.com> | 2022-07-08 12:33:45 +0300 |
commit | 995140d302cbcca48694ef837723a0a15feffea2 (patch) | |
tree | cd7670576ac64b3ff3cc790c829367bdf09125b3 | |
parent | e440ed20cf0134cae8380d4f996d3b3f02acfa0a (diff) | |
parent | 3587222da21b30aa72718f22584f545608903fd5 (diff) |
.........T [ZBXNEXT-7802] added namespaces in templates HashiCorp Consul by HTTP
* commit '3587222da21b30aa72718f22584f545608903fd5':
.........T [ZBXNEXT-7802] fixed typos
.........T [ZBXNEXT-7802] fixed link to Envoy Template in readme
.........T [ZBXNEXT-7802] fixed typo
.........T [ZBXNEXT-7802] fixed typo
.........T [ZBXNEXT-7802] fixed typo
.........T [ZBXNEXT-7802] added namespaces in templates HashiCorp Consul by HTTP
5 files changed, 68 insertions, 22 deletions
diff --git a/ChangeLog.d/feature/ZBXNEXT-7802 b/ChangeLog.d/feature/ZBXNEXT-7802 new file mode 100644 index 00000000000..9322b090137 --- /dev/null +++ b/ChangeLog.d/feature/ZBXNEXT-7802 @@ -0,0 +1 @@ +.........T [ZBXNEXT-7802] added namespaces in templates HashiCorp Consul by HTTP (ychukina) diff --git a/templates/app/consul_http/consul/README.md b/templates/app/consul_http/consul/README.md index 9f0c0ba7543..23cb19cd3b7 100644 --- a/templates/app/consul_http/consul/README.md +++ b/templates/app/consul_http/consul/README.md @@ -28,7 +28,12 @@ Template need to use Authorization via API token. Don't forget to change macros {$CONSUL.NODE.API.URL}, {$CONSUL.TOKEN}. Also, see the Macros section for a list of macros used to set trigger values. + +This template support [Consul namespaces](https://www.consul.io/docs/enterprise/namespaces). You can set macros {$CONSUL.LLD.FILTER.SERVICE_NAMESPACE.MATCHES}, {$CONSUL.LLD.FILTER.SERVICE_NAMESPACE.NOT_MATCHES} if you want to filter discovered services by namespace. +In case of Open Source version service namespace will be set to 'None'. + *NOTE.* Some metrics may not be collected depending on your HashiCorp Consul instance version and configuration. +*NOTE.* You maybe are interested in Envoy Proxy by HTTP [template](../../envoy_proxy_http). ## Zabbix configuration @@ -41,8 +46,8 @@ No specific Zabbix configuration is required. |----|-----------|-------| |{$CONSUL.LLD.FILTER.LOCAL_SERVICE_NAME.MATCHES} |<p>Filter of discoverable discovered services on local node.</p> |`.*` | |{$CONSUL.LLD.FILTER.LOCAL_SERVICE_NAME.NOT_MATCHES} |<p>Filter to exclude discovered services on local node.</p> |`CHANGE IF NEEDED` | -|{$CONSUL.LLD.FILTER.SERVICE_CHECK_NAME.MATCHES} |<p>Filter of discoverable discovered service checks on local node.</p> |`.*` | -|{$CONSUL.LLD.FILTER.SERVICE_CHECK_NAME.NOT_MATCHES} |<p>Filter to exclude discovered service checks on local node.</p> |`CHANGE IF NEEDED` | +|{$CONSUL.LLD.FILTER.SERVICE_NAMESPACE.MATCHES} |<p>Filter of discoverable discovered service by namespace on local node. Enterprise only, in case of Open Source version Namespace will be set to 'None'.</p> |`.*` | +|{$CONSUL.LLD.FILTER.SERVICE_NAMESPACE.NOT_MATCHES} |<p>Filter to exclude discovered service by namespace on local node. Enterprise only, in case of Open Source version Namespace will be set to 'None'.</p> |`CHANGE IF NEEDED` | |{$CONSUL.NODE.API.URL} |<p>Consul instance URL.</p> |`http://localhost:8500` | |{$CONSUL.NODE.HEALTH_SCORE.MAX.HIGH} |<p>Maximum acceptable value of node's health score for AVERAGE trigger expression.</p> |`4` | |{$CONSUL.NODE.HEALTH_SCORE.MAX.WARN} |<p>Maximum acceptable value of node's health score for WARNING trigger expression.</p> |`2` | @@ -58,7 +63,7 @@ There are no template links in this template. |Name|Description|Type|Key and additional info| |----|-----------|----|----| |HTTP API methods discovery |<p>Discovery HTTP API methods specific metrics.</p> |DEPENDENT |consul.http_api_discovery<p>**Preprocessing**:</p><p>- PROMETHEUS_TO_JSON: `consul_api_http{method =~ ".*"}`</p><p>- JAVASCRIPT: `The text is too long. Please see the template.`</p><p>- DISCARD_UNCHANGED_HEARTBEAT: `3h`</p> | -|Local node services discovery |<p>Discover metrics for services that are registered with the local agent.</p> |DEPENDENT |consul.node_services_lld<p>**Preprocessing**:</p><p>- JAVASCRIPT: `The text is too long. Please see the template.`</p><p>- DISCARD_UNCHANGED_HEARTBEAT: `3h`</p><p>**Filter**:</p> <p>- {#SERVICE_NAME} MATCHES_REGEX `{$CONSUL.LLD.FILTER.LOCAL_SERVICE_NAME.MATCHES}`</p><p>- {#SERVICE_NAME} NOT_MATCHES_REGEX `{$CONSUL.LLD.FILTER.LOCAL_SERVICE_NAME.NOT_MATCHES}`</p><p>**Overrides:**</p><p>aggregated status<br> - {#TYPE} MATCHES_REGEX `aggregated_status`<br> - ITEM_PROTOTYPE LIKE `Aggregated status` - DISCOVER</p><br> - ITEM_PROTOTYPE LIKE `State` - DISCOVER</p><p>checks<br> - {#TYPE} MATCHES_REGEX `service_check`<br> - ITEM_PROTOTYPE LIKE `Check` - DISCOVER</p> | +|Local node services discovery |<p>Discover metrics for services that are registered with the local agent.</p> |DEPENDENT |consul.node_services_lld<p>**Preprocessing**:</p><p>- JAVASCRIPT: `The text is too long. Please see the template.`</p><p>- DISCARD_UNCHANGED_HEARTBEAT: `3h`</p><p>**Filter**:</p> <p>- {#SERVICE_NAME} MATCHES_REGEX `{$CONSUL.LLD.FILTER.LOCAL_SERVICE_NAME.MATCHES}`</p><p>- {#SERVICE_NAME} NOT_MATCHES_REGEX `{$CONSUL.LLD.FILTER.LOCAL_SERVICE_NAME.NOT_MATCHES}`</p><p>- {#SERVICE_NAMESPACE} MATCHES_REGEX `{$CONSUL.LLD.FILTER.SERVICE_NAMESPACE.MATCHES}`</p><p>- {#SERVICE_NAMESPACE} NOT_MATCHES_REGEX `{$CONSUL.LLD.FILTER.SERVICE_NAMESPACE.NOT_MATCHES}`</p><p>**Overrides:**</p><p>aggregated status<br> - {#TYPE} MATCHES_REGEX `aggregated_status`<br> - ITEM_PROTOTYPE LIKE `Aggregated status` - DISCOVER</p><br> - ITEM_PROTOTYPE LIKE `State` - DISCOVER</p><p>checks<br> - {#TYPE} MATCHES_REGEX `service_check`<br> - ITEM_PROTOTYPE LIKE `Check` - DISCOVER</p> | |Raft leader metrics discovery |<p>Discover raft metrics for leader nodes.</p> |DEPENDENT |consul.raft.leader.discovery<p>**Preprocessing**:</p><p>- JAVASCRIPT: `The text is too long. Please see the template.`</p><p>- DISCARD_UNCHANGED_HEARTBEAT: `3h`</p> | |Raft server metrics discovery |<p>Discover raft metrics for server nodes.</p> |DEPENDENT |consul.raft.server.discovery<p>**Preprocessing**:</p><p>- JAVASCRIPT: `The text is too long. Please see the template.`</p><p>- DISCARD_UNCHANGED_HEARTBEAT: `3h`</p> | diff --git a/templates/app/consul_http/consul/template_consul_node_http.yaml b/templates/app/consul_http/consul/template_consul_node_http.yaml index 0dedf84416c..366f1c2d968 100644 --- a/templates/app/consul_http/consul/template_consul_node_http.yaml +++ b/templates/app/consul_http/consul/template_consul_node_http.yaml @@ -1,6 +1,6 @@ zabbix_export: version: '6.0' - date: '2022-05-17T15:36:35Z' + date: '2022-07-07T21:30:50Z' groups: - uuid: a571c0d144b14fd4a87a9d9b2aa9fcd6 @@ -19,7 +19,7 @@ zabbix_export: You can discuss this template or leave feedback on our forum https://www.zabbix.com/forum/zabbix-suggestions-and-feedback - Template tooling version used: 0.41 + Template tooling version used: 0.42 groups: - name: Templates/Applications @@ -392,7 +392,8 @@ zabbix_export: 'id': service, 'name': service_stats['Service']['Service'], 'status': service_stats['AggregatedStatus'], - 'checks': service_stats["Checks"] + 'checks': service_stats['Checks'], + 'namespace': typeof service_stats['Service']['Namespace'] === 'undefined' ? 'None' : service_stats['Service']['Namespace'] }); }); @@ -473,7 +474,7 @@ zabbix_export: headers: - name: X-Consul-Token - value: '{$CONSUL.API.TOKEN}' + value: '{$CONSUL.TOKEN}' tags: - tag: component @@ -500,7 +501,7 @@ zabbix_export: headers: - name: X-Consul-Token - value: '{$CONSUL.API.TOKEN}' + value: '{$CONSUL.TOKEN}' tags: - tag: component @@ -1525,6 +1526,7 @@ zabbix_export: uuid: fa78d269c01548a083085a3a98e5a59b expression: 'last(/HashiCorp Consul Node by HTTP/consul.version,#1)<>last(/HashiCorp Consul Node by HTTP/consul.version,#2) and length(last(/HashiCorp Consul Node by HTTP/consul.version))>0' name: 'Consul: Version has been changed' + event_name: 'Consul: Version has changed (new version: {ITEM.VALUE})' priority: INFO description: 'Consul version has changed. Ack to close.' manual_close: 'YES' @@ -1694,6 +1696,15 @@ zabbix_export: value: '{$CONSUL.LLD.FILTER.LOCAL_SERVICE_NAME.NOT_MATCHES}' operator: NOT_MATCHES_REGEX formulaid: B + - + macro: '{#SERVICE_NAMESPACE}' + value: '{$CONSUL.LLD.FILTER.SERVICE_NAMESPACE.MATCHES}' + formulaid: C + - + macro: '{#SERVICE_NAMESPACE}' + value: '{$CONSUL.LLD.FILTER.SERVICE_NAMESPACE.NOT_MATCHES}' + operator: NOT_MATCHES_REGEX + formulaid: D description: 'Discover metrics for services that are registered with the local agent.' item_prototypes: - @@ -1730,6 +1741,9 @@ zabbix_export: tag: component value: service - + tag: namespace + value: '{#SERVICE_NAMESPACE}' + - tag: service value: '{#SERVICE_NAME}' trigger_prototypes: @@ -1786,6 +1800,9 @@ zabbix_export: tag: component value: service - + tag: namespace + value: '{#SERVICE_NAMESPACE}' + - tag: service value: '{#SERVICE_NAME}' - @@ -1825,6 +1842,9 @@ zabbix_export: tag: component value: service - + tag: namespace + value: '{#SERVICE_NAMESPACE}' + - tag: service value: '{#SERVICE_NAME}' master_item: @@ -1846,6 +1866,7 @@ zabbix_export: '{#TYPE}': 'aggregated_status', '{#SERVICE_NAME}': service.name, '{#SERVICE_ID}': service.id, + '{#SERVICE_NAMESPACE}': service.namespace }); if (service['checks'] !== 0) { @@ -1854,6 +1875,7 @@ zabbix_export: '{#TYPE}': 'service_check', '{#SERVICE_NAME}': service.name, '{#SERVICE_ID}': service.id, + '{#SERVICE_NAMESPACE}': service.namespace, '{#SERVICE_CHECK_ID}': check["CheckID"], '{#SERVICE_CHECK_NAME}': check["Name"] }); @@ -2312,13 +2334,13 @@ zabbix_export: value: 'CHANGE IF NEEDED' description: 'Filter to exclude discovered services on local node.' - - macro: '{$CONSUL.LLD.FILTER.SERVICE_CHECK_NAME.MATCHES}' + macro: '{$CONSUL.LLD.FILTER.SERVICE_NAMESPACE.MATCHES}' value: '.*' - description: 'Filter of discoverable discovered service checks on local node.' + description: 'Filter of discoverable discovered service by namespace on local node. Enterprise only, in case of Open Source version Namespace will be set to ''None''.' - - macro: '{$CONSUL.LLD.FILTER.SERVICE_CHECK_NAME.NOT_MATCHES}' + macro: '{$CONSUL.LLD.FILTER.SERVICE_NAMESPACE.NOT_MATCHES}' value: 'CHANGE IF NEEDED' - description: 'Filter to exclude discovered service checks on local node.' + description: 'Filter to exclude discovered service by namespace on local node. Enterprise only, in case of Open Source version Namespace will be set to ''None''.' - macro: '{$CONSUL.NODE.API.URL}' value: 'http://localhost:8500' diff --git a/templates/app/consul_http/consul_cluster/README.md b/templates/app/consul_http/consul_cluster/README.md index b9815517706..e086394e600 100644 --- a/templates/app/consul_http/consul_cluster/README.md +++ b/templates/app/consul_http/consul_cluster/README.md @@ -24,7 +24,12 @@ Template need to use Authorization via API token. Don't forget to change macros {$CONSUL.CLUSTER.URL}, {$CONSUL.TOKEN}. Also, see the Macros section for a list of macros used to set trigger values. + +This template support [Consul namespaces](https://www.consul.io/docs/enterprise/namespaces). You can set macro {$CONSUL.NAMESPACE}, if you are interested in only one service namespace. Do not specify this macro to get all of services. +In case of Open Source version leave this macro empty. + *NOTE.* Some metrics may not be collected depending on your HashiCorp Consul instance version and configuration. +*NOTE.* You maybe are interested in Envoy Proxy by HTTP [template](../../envoy_proxy_http). ## Zabbix configuration @@ -42,6 +47,7 @@ No specific Zabbix configuration is required. |{$CONSUL.LLD.FILTER.NODE_NAME.NOT_MATCHES} |<p>Filter to exclude discovered nodes.</p> |`CHANGE IF NEEDED` | |{$CONSUL.LLD.FILTER.SERVICE_NAME.MATCHES} |<p>Filter of discoverable discovered services.</p> |`.*` | |{$CONSUL.LLD.FILTER.SERVICE_NAME.NOT_MATCHES} |<p>Filter to exclude discovered services.</p> |`CHANGE IF NEEDED` | +|{$CONSUL.NAMESPACE} |<p>Consul service namespace. Enterprise only, in case of Open Source version leave this macro empty. Do not specify this macro to get all of services.</p> |`` | |{$CONSUL.SERVICE_NODES.CRITICAL.MAX.AVG} |<p>Maximum number of service nodes in status 'critical' for trigger expression. Can be used with context.</p> |`0` | |{$CONSUL.TOKEN} |<p>Consul auth token.</p> |`<PUT YOUR AUTH TOKEN>` | @@ -66,7 +72,7 @@ There are no template links in this template. |Consul |Consul: Nodes: warning |<p>Number of agents on current dc with serf health status 'warning'.</p> |DEPENDENT |consul.nodes_warning<p>**Preprocessing**:</p><p>- JSONPATH: `$[?(@.Status == "warning")].length()`</p><p>- DISCARD_UNCHANGED_HEARTBEAT: `3h`</p> | |Consul |Consul: Services: total |<p>Number of services on current dc.</p> |DEPENDENT |consul.services_total<p>**Preprocessing**:</p><p>- JAVASCRIPT: `return Object.keys(JSON.parse(value)).length; `</p><p>- DISCARD_UNCHANGED_HEARTBEAT: `3h`</p> | |Consul |Consul: Node ["{#NODE_NAME}"]: Serf Health |<p>Node Serf Health Status.</p> |DEPENDENT |consul.serf.health["{#NODE_NAME}"]<p>**Preprocessing**:</p><p>- JSONPATH: `$[?(@.Node == "{#NODE_NAME}" && @.CheckID == "serfHealth")].Status.first()`</p><p>- JAVASCRIPT: `The text is too long. Please see the template.`</p><p>- DISCARD_UNCHANGED_HEARTBEAT: `3h`</p> | -|Consul |Consul: Service ["{#SERVICE_NAME}"]: Nodes passing |<p>-</p> |DEPENDENT |consul.service.nodes_passing["{#SERVICE_NAME}"]<p>**Preprocessing**:</p><p>- JSONPATH: `$[?(@.Node == "{#SERVICE_NAME}")].Checks[?(@.CheckID == "serfHealth" && @.Status == 'passing')].length()`</p><p>- DISCARD_UNCHANGED_HEARTBEAT: `3h`</p> | +|Consul |Consul: Service ["{#SERVICE_NAME}"]: Nodes passing |<p>-</p> |DEPENDENT |consul.service.nodes_passing["{#SERVICE_NAME}"]<p>**Preprocessing**:</p><p>- JSONPATH: `$[?(@.Service.Service == "{#SERVICE_NAME}")].Checks[?(@.CheckID == "serfHealth" && @.Status == 'passing')].length()`</p><p>- DISCARD_UNCHANGED_HEARTBEAT: `3h`</p> | |Consul |Consul: Service ["{#SERVICE_NAME}"]: Nodes warning |<p>-</p> |DEPENDENT |consul.service.nodes_warning["{#SERVICE_NAME}"]<p>**Preprocessing**:</p><p>- JSONPATH: `$[?(@.Service.Service == "{#SERVICE_NAME}")].Checks[?(@.CheckID == "serfHealth" && @.Status == 'warning')].length()`</p><p>- DISCARD_UNCHANGED_HEARTBEAT: `3h`</p> | |Consul |Consul: Service ["{#SERVICE_NAME}"]: Nodes critical |<p>-</p> |DEPENDENT |consul.service.nodes_critical["{#SERVICE_NAME}"]<p>**Preprocessing**:</p><p>- JSONPATH: `$[?(@.Service.Service == "{#SERVICE_NAME}")].Checks[?(@.CheckID == "serfHealth" && @.Status == 'critical')].length()`</p><p>- DISCARD_UNCHANGED_HEARTBEAT: `3h`</p> | |Consul cluster |Consul cluster: Cluster leader |<p>Current leader address.</p> |HTTP_AGENT |consul.get_leader<p>**Preprocessing**:</p><p>- CHECK_NOT_SUPPORTED</p><p>⛔️ON_FAIL: `DISCARD_VALUE -> `</p><p>- TRIM: `"`</p><p>- DISCARD_UNCHANGED_HEARTBEAT: `1h`</p> | diff --git a/templates/app/consul_http/consul_cluster/template_consul_cluster_http.yaml b/templates/app/consul_http/consul_cluster/template_consul_cluster_http.yaml index 5256bff93e2..c326bf881ae 100644 --- a/templates/app/consul_http/consul_cluster/template_consul_cluster_http.yaml +++ b/templates/app/consul_http/consul_cluster/template_consul_cluster_http.yaml @@ -1,6 +1,6 @@ zabbix_export: version: '6.0' - date: '2022-05-17T15:36:33Z' + date: '2022-07-07T21:30:47Z' groups: - uuid: a571c0d144b14fd4a87a9d9b2aa9fcd6 @@ -19,7 +19,7 @@ zabbix_export: You can discuss this template or leave feedback on our forum https://www.zabbix.com/forum/zabbix-suggestions-and-feedback - Template tooling version used: 0.41 + Template tooling version used: 0.42 groups: - name: Templates/Applications @@ -43,7 +43,10 @@ zabbix_export: headers: - name: X-Consul-Token - value: '{$CONSUL.API.TOKEN}' + value: '{$CONSUL.TOKEN}' + - + name: X-Consul-Namespace + value: '{$CONSUL.NAMESPACE}' tags: - tag: component @@ -67,7 +70,10 @@ zabbix_export: headers: - name: X-Consul-Token - value: '{$CONSUL.API.TOKEN}' + value: '{$CONSUL.TOKEN}' + - + name: X-Consul-Namespace + value: '{$CONSUL.NAMESPACE}' tags: - tag: component @@ -102,7 +108,7 @@ zabbix_export: headers: - name: X-Consul-Token - value: '{$CONSUL.API.TOKEN}' + value: '{$CONSUL.TOKEN}' tags: - tag: component @@ -142,7 +148,7 @@ zabbix_export: headers: - name: X-Consul-Token - value: '{$CONSUL.API.TOKEN}' + value: '{$CONSUL.TOKEN}' tags: - tag: component @@ -172,7 +178,7 @@ zabbix_export: headers: - name: X-Consul-Token - value: '{$CONSUL.API.TOKEN}' + value: '{$CONSUL.TOKEN}' tags: - tag: component @@ -462,7 +468,10 @@ zabbix_export: headers: - name: X-Consul-Token - value: '{$CONSUL.API.TOKEN}' + value: '{$CONSUL.TOKEN}' + - + name: X-Consul-Namespace + value: '{$CONSUL.NAMESPACE}' tags: - tag: component @@ -518,7 +527,7 @@ zabbix_export: - type: JSONPATH parameters: - - '$[?(@.Node == "{#SERVICE_NAME}")].Checks[?(@.CheckID == "serfHealth" && @.Status == ''passing'')].length()' + - '$[?(@.Service.Service == "{#SERVICE_NAME}")].Checks[?(@.CheckID == "serfHealth" && @.Status == ''passing'')].length()' - type: DISCARD_UNCHANGED_HEARTBEAT parameters: @@ -612,6 +621,9 @@ zabbix_export: value: 'CHANGE IF NEEDED' description: 'Filter to exclude discovered services.' - + macro: '{$CONSUL.NAMESPACE}' + description: 'Consul service namespace. Enterprise only, in case of Open Source version leave this macro empty. Do not specify this macro to get all of services.' + - macro: '{$CONSUL.SERVICE_NODES.CRITICAL.MAX.AVG}' value: '0' description: 'Maximum number of service nodes in status ''critical'' for trigger expression. Can be used with context.' |