zabbix_export: version: '6.0' date: '2021-11-21T22:08:33Z' groups: - uuid: 8b9bda7136894833ad9e910b5795a6a7 name: Harbor templates: - uuid: 8b9bda7136894833ad9e910b5795a6a7 template: Harbor name: Harbor description: | ## Overview ``` # Zabbix Template for Harbor This template uses http agent to get informations from [Harbor](https://goharbor.io/) API, such as: 1. Monitor Items 1. Health of services: Core, Jobservice, Redis, Database, Portal, ..., etc 1. System information: Version, Regitstry URL, Has CA Root, ..., etc 1. Statistic: Public/Private Project and Repository count 1. Storage usage 1. Triggers 1. Unhealthy Services 1. Every operations on Harbor (excluding pulling images `PULL\_ARTIFACT`) 1. Insufficient storage size ## Tested version - Harbor: `2.0.1` - Zabbix: `5.0.1` ## Useage 1. Import Templates: Zabbix Web Page --> [Configuration] --> [Templates] --> [Import] this xml file 1. Link this template to an existing host or a new host 1. Update the Macro to specify your Harbor info: [Configuration] --> your host --> [Macros] --> [Inherited and host macros] - {$HARBOR\_PASSWORD} - {$HARBOR\_URL} - {$HARBOR\_USERNAME} ## Reference - [View and Test the Harbor REST API via Swagger](https://goharbor.io/docs/1.10/build-customize-contribute/configure-swagger/) - [Zabbix - HTTP AGENT](https://www.zabbix.com/documentation/current/manual/config/items/itemtypes/http) ``` ## Author Yioda groups: - name: Harbor items: - uuid: 8d98eeef155c464ba08df58b0290aab1 name: 'System Status Information' type: HTTP_AGENT key: harbor.allstatus delay: 30s history: '0' trends: '0' value_type: TEXT authtype: BASIC username: '{$HARBOR_USERNAME}' password: '{$HARBOR_PASSWORD}' preprocessing: - type: JSONPATH parameters: - $.body url: '{$HARBOR_URL}/api/v2.0/health' follow_redirects: 'NO' output_format: JSON verify_peer: 'YES' verify_host: 'YES' tags: - tag: Application value: Harbor - uuid: 8545f3b25bc34893a93cbfd1d2165591 name: Statistics type: HTTP_AGENT key: harbor.statistics history: '0' trends: '0' value_type: TEXT authtype: BASIC username: '{$HARBOR_USERNAME}' password: '{$HARBOR_PASSWORD}' preprocessing: - type: JSONPATH parameters: - $.body url: '{$HARBOR_URL}/api/v2.0/statistics' follow_redirects: 'NO' output_format: JSON verify_peer: 'YES' verify_host: 'YES' tags: - tag: Application value: Harbor - uuid: 844b00a4ed2149f0a1eea5724681fd44 name: 'Private Project Count' type: DEPENDENT key: harbor.statistics.private_project_count delay: '0' preprocessing: - type: JSONPATH parameters: - $.private_project_count master_item: key: harbor.statistics tags: - tag: Application value: Harbor - uuid: f99a9ec967fc45d69b1b889dc1cc4429 name: 'Private Repository Count' type: DEPENDENT key: harbor.statistics.private_repo_count delay: '0' preprocessing: - type: JSONPATH parameters: - $.private_repo_count master_item: key: harbor.statistics tags: - tag: Application value: Harbor - uuid: a9d416b6bea74df8a8b878bf79b4b587 name: 'Public Project Count' type: DEPENDENT key: harbor.statistics.public_project_count delay: '0' preprocessing: - type: JSONPATH parameters: - $.public_project_count master_item: key: harbor.statistics tags: - tag: Application value: Harbor - uuid: df40d8a4db794e10b3aa887c57a770a0 name: 'Public Repository Count' type: DEPENDENT key: harbor.statistics.public_repo_count delay: '0' trends: 356d preprocessing: - type: JSONPATH parameters: - $.public_repo_count master_item: key: harbor.statistics tags: - tag: Application value: Harbor - uuid: 976dbed2e2ee4c649d0a00357dec200e name: Status type: DEPENDENT key: harbor.status delay: '0' description: | 1: healthy 0: unhealthy preprocessing: - type: JSONPATH parameters: - $.status - type: JAVASCRIPT parameters: - | if(value == "healthy"){ return 1; } else { return 0; } master_item: key: harbor.allstatus tags: - tag: Application value: Harbor triggers: - uuid: 6d4bc42920b545d1bd7c8de0ce3e65e7 expression: 'last(/Harbor/harbor.status,#1:now-1s)=0' name: 'Harbor services is unhealthy' status: DISABLED priority: AVERAGE - uuid: 6fe1bd541ae841a2b884a27d975ec1b6 name: 'Status of Core' type: DEPENDENT key: harbor.status.core delay: '0' description: | 1: healthy 0: unhealthy preprocessing: - type: JSONPATH parameters: - '$.components[?(@.name == ''core'')].status.first()' - type: JAVASCRIPT parameters: - | if(value == "healthy"){ return 1; } else { return 0; } master_item: key: harbor.allstatus tags: - tag: Application value: Harbor triggers: - uuid: 8fb0c1d590824066989753faa2d80d76 expression: 'last(/Harbor/harbor.status.core,#1:now-1s)=0' name: 'Harbor service: Core is unhealthy' priority: AVERAGE - uuid: a44d27c720c7478b9d08a05a9064039f name: 'Status of Database' type: DEPENDENT key: harbor.status.database delay: '0' description: | 1: healthy 0: unhealthy preprocessing: - type: JSONPATH parameters: - '$.components[?(@.name == ''database'')].status.first()' - type: JAVASCRIPT parameters: - | if(value == "healthy"){ return 1; } else { return 0; } master_item: key: harbor.allstatus tags: - tag: Application value: Harbor triggers: - uuid: 1930332d00534a61b396e14af7c77545 expression: 'last(/Harbor/harbor.status.database,#1:now-1s)=0' name: 'Harbor service: Database is unhealthy' priority: AVERAGE - uuid: 9893cb60fa994277bd730f099c92456c name: 'Status of Jobservice' type: DEPENDENT key: harbor.status.jobservice delay: '0' description: | 1: healthy 0: unhealthy preprocessing: - type: JSONPATH parameters: - '$.components[?(@.name == ''jobservice'')].status.first()' - type: JAVASCRIPT parameters: - | if(value == "healthy"){ return 1; } else { return 0; } master_item: key: harbor.allstatus tags: - tag: Application value: Harbor triggers: - uuid: a460a2e7ab01448c8ab415a9253aba9d expression: 'last(/Harbor/harbor.status.jobservice,#1:now-1s)=0' name: 'Harbor service: Jobservice is unhealthy' priority: AVERAGE - uuid: 90408bc7571744cf96c778c06cfb71b4 name: 'Status of Notary' type: DEPENDENT key: harbor.status.notary delay: '0' description: | 1: healthy 0: unhealthy preprocessing: - type: JSONPATH parameters: - '$.components[?(@.name == ''notary'')].status.first()' - type: JAVASCRIPT parameters: - | if(value == "healthy"){ return 1; } else { return 0; } master_item: key: harbor.allstatus tags: - tag: Application value: Harbor - uuid: 05456140e6c643bfbdc78d2fe3e66182 name: 'Status of Portal' type: DEPENDENT key: harbor.status.portal delay: '0' description: | 1: healthy 0: unhealthy preprocessing: - type: JSONPATH parameters: - '$.components[?(@.name == ''portal'')].status.first()' - type: JAVASCRIPT parameters: - | if(value == "healthy"){ return 1; } else { return 0; } master_item: key: harbor.allstatus tags: - tag: Application value: Harbor triggers: - uuid: 2f891ca657114cd38b1114e49b9f727f expression: 'last(/Harbor/harbor.status.portal,#1:now-1s)=0' name: 'Harbor service: Portal is unhealthy' priority: AVERAGE - uuid: d80720725c5f400987c641713657067f name: 'Status of Redis' type: DEPENDENT key: harbor.status.redis delay: '0' description: | 1: healthy 0: unhealthy preprocessing: - type: JSONPATH parameters: - '$.components[?(@.name == ''redis'')].status.first()' - type: JAVASCRIPT parameters: - | if(value == "healthy"){ return 1; } else { return 0; } master_item: key: harbor.allstatus tags: - tag: Application value: Harbor triggers: - uuid: 3162064f8d4e48aa883c5478cb4babe1 expression: 'last(/Harbor/harbor.status.redis,#1:now-1s)=0' name: 'Harbor service: Redis is unhealthy' priority: AVERAGE - uuid: 866f069ebfed46ecb4342af7e49583ac name: 'Status of Registry' type: DEPENDENT key: harbor.status.registry delay: '0' description: | 1: healthy 0: unhealthy preprocessing: - type: JSONPATH parameters: - '$.components[?(@.name == ''registry'')].status.first()' - type: JAVASCRIPT parameters: - | if(value == "healthy"){ return 1; } else { return 0; } master_item: key: harbor.allstatus tags: - tag: Application value: Harbor triggers: - uuid: 416bbca793e84fb4a4335dd19b312a7d expression: 'last(/Harbor/harbor.status.registry,#1:now-1s)=0' name: 'Harbor service: Registry is unhealthy' priority: AVERAGE - uuid: 88356686f7884c4c8bcd2203c3cfae02 name: 'Status of Registryctl' type: DEPENDENT key: harbor.status.registryctl delay: '0' description: | 1: healthy 0: unhealthy preprocessing: - type: JSONPATH parameters: - '$.components[?(@.name == ''registryctl'')].status.first()' - type: JAVASCRIPT parameters: - | if(value == "healthy"){ return 1; } else { return 0; } master_item: key: harbor.allstatus tags: - tag: Application value: Harbor triggers: - uuid: 95350233ffd44f8cb512e2bcfcbce89a expression: 'last(/Harbor/harbor.status.registryctl,#1:now-1s)=0' name: 'Harbor service: RegistryCtl is unhealthy' priority: AVERAGE - uuid: 792142c18ae7442b9704e5313ffe329f name: 'System Information' type: HTTP_AGENT key: harbor.system.info delay: 5m history: '0' trends: '0' value_type: TEXT authtype: BASIC username: '{$HARBOR_USERNAME}' password: '{$HARBOR_PASSWORD}' preprocessing: - type: JSONPATH parameters: - $.body url: '{$HARBOR_URL}/api/v2.0/systeminfo' follow_redirects: 'NO' output_format: JSON verify_peer: 'YES' verify_host: 'YES' tags: - tag: Application value: Harbor - uuid: 678998ad064242f3b53f5050fdff0bc9 name: 'Auth mode' type: DEPENDENT key: harbor.system.info.auth_mode delay: '0' trends: '0' value_type: TEXT preprocessing: - type: JSONPATH parameters: - $.auth_mode master_item: key: harbor.system.info tags: - tag: Application value: Harbor - uuid: 00ac40fcb490430abc425362219cb207 name: 'External URL' type: DEPENDENT key: harbor.system.info.external_url delay: '0' trends: '0' value_type: TEXT preprocessing: - type: JSONPATH parameters: - $.external_url master_item: key: harbor.system.info tags: - tag: Application value: Harbor - uuid: fc19c20f673f40b29b453bf1ed44498b name: 'Has CA Root' type: DEPENDENT key: harbor.system.info.has_ca_root delay: '0' trends: '0' value_type: TEXT preprocessing: - type: JSONPATH parameters: - $.has_ca_root master_item: key: harbor.system.info tags: - tag: Application value: Harbor - uuid: 2a9fd8748fb648f2a413a36351c14951 name: 'Notification Enable' type: DEPENDENT key: harbor.system.info.notification_enable delay: '0' trends: '0' value_type: TEXT preprocessing: - type: JSONPATH parameters: - $.notification_enable master_item: key: harbor.system.info tags: - tag: Application value: Harbor - uuid: 17abe6ba92b642bfa3d83a34e2f5818b name: 'Project Creation Restriction' type: DEPENDENT key: harbor.system.info.project_creation_restriction delay: '0' trends: '0' value_type: TEXT preprocessing: - type: JSONPATH parameters: - $.project_creation_restriction master_item: key: harbor.system.info tags: - tag: Application value: Harbor - uuid: 7162a713b99c4f0996b1ec6920b29e47 name: 'Read Only' type: DEPENDENT key: harbor.system.info.read_only delay: '0' trends: '0' value_type: TEXT preprocessing: - type: JSONPATH parameters: - $.read_only master_item: key: harbor.system.info tags: - tag: Application value: Harbor - uuid: f02bb719823e4c00936247963a6088a4 name: 'Registry Storage Provider Name' type: DEPENDENT key: harbor.system.info.registry_storage_provider_name delay: '0' trends: '0' value_type: TEXT preprocessing: - type: JSONPATH parameters: - $.registry_storage_provider_name master_item: key: harbor.system.info tags: - tag: Application value: Harbor - uuid: 8b87dc1e12444ccbb50875a71acad291 name: 'Registry URL' type: DEPENDENT key: harbor.system.info.registry_url delay: '0' trends: '0' value_type: TEXT preprocessing: - type: JSONPATH parameters: - $.registry_url master_item: key: harbor.system.info tags: - tag: Application value: Harbor - uuid: 48826467e5404d59947ae93597b70052 name: 'Self Restriction' type: DEPENDENT key: harbor.system.info.self_registration delay: '0' trends: '0' value_type: TEXT preprocessing: - type: JSONPATH parameters: - $.self_registration master_item: key: harbor.system.info tags: - tag: Application value: Harbor - uuid: 8a2eaaccddd6490da384b287b9fb222a name: Version type: DEPENDENT key: harbor.system.info.version delay: '0' trends: '0' value_type: TEXT preprocessing: - type: JSONPATH parameters: - $.harbor_version master_item: key: harbor.system.info tags: - tag: Application value: Harbor - uuid: db0ea5e0508d478d8dc7b211e6f9601c name: 'System Volume Information' type: HTTP_AGENT key: harbor.system.info.volume delay: 30s history: '0' trends: '0' value_type: TEXT authtype: BASIC username: '{$HARBOR_USERNAME}' password: '{$HARBOR_PASSWORD}' preprocessing: - type: JSONPATH parameters: - $.body url: '{$HARBOR_URL}/api/v2.0/systeminfo/volumes' follow_redirects: 'NO' output_format: JSON verify_peer: 'YES' verify_host: 'YES' tags: - tag: Application value: Harbor - uuid: e0cb4a1b0b1a41d39db8cb1931cb7df1 name: 'Free volume storage size' type: DEPENDENT key: harbor.system.info.volume.storage.free delay: '0' units: B preprocessing: - type: JSONPATH parameters: - $.storage.free master_item: key: harbor.system.info.volume tags: - tag: Application value: Harbor - uuid: 424e198ec2f34457974b93ba4b45858a name: 'Free volume storage size (percent)' type: CALCULATED key: harbor.system.info.volume.storage.free.percent value_type: FLOAT units: '%' params: '100*last(//harbor.system.info.volume.storage.free)/last(//harbor.system.info.volume.storage.total)' tags: - tag: Application value: Harbor triggers: - uuid: bd6b6cc699dd43cb8f921c86e264f295 expression: last(/Harbor/harbor.system.info.volume.storage.free.percent)<10 name: 'Free Harbor volume storage size < 10 %' priority: HIGH - uuid: 23844bb7f99a4485b68c746cb8e91034 expression: last(/Harbor/harbor.system.info.volume.storage.free.percent)<20 name: 'Free Harbor volume storage size < 20 %' priority: AVERAGE - uuid: e65e52e68e074294a3e4daa396c127d0 name: 'Total volume storage size' type: DEPENDENT key: harbor.system.info.volume.storage.total delay: '0' units: B preprocessing: - type: JSONPATH parameters: - $.storage.total master_item: key: harbor.system.info.volume tags: - tag: Application value: Harbor - uuid: 6a2d48b19e214176a8eb3dc42eacf5a4 name: 'With Chatmuseum' type: DEPENDENT key: harbor.system.info.with_chartmuseum delay: '0' trends: '0' value_type: TEXT preprocessing: - type: JSONPATH parameters: - $.with_chartmuseum master_item: key: harbor.system.info tags: - tag: Application value: Harbor - uuid: 1b7d5b33bca846ca8ac2c5edd781b8aa name: 'With Notary' type: DEPENDENT key: harbor.system.info.with_notary delay: '0' trends: '0' value_type: TEXT preprocessing: - type: JSONPATH parameters: - $.with_notary master_item: key: harbor.system.info tags: - tag: Application value: Harbor - uuid: 17c91e3bfd434f39a599f22aff41665b name: 'Core log watch' type: ZABBIX_ACTIVE key: 'log[/var/log/harbor/core.log,"Handle notification with Handler ''AuditLog'' on topic (.*)",,,,\1]' delay: 20s history: 7d trends: '0' value_type: LOG description: 'Core log monitoring' tags: - tag: Application value: Harbor triggers: - uuid: 3d1318144e804ecf8f34b661432f8410 expression: 'find(/Harbor/log[/var/log/harbor/core.log,"Handle notification with Handler ''AuditLog'' on topic (.*)",,,,\1],,"like","PULL")=0' name: 'Harbor Operation on {HOST.NAME}' priority: INFO description: 'Excluding image pulling actions.' type: MULTIPLE manual_close: 'YES' macros: - macro: '{$HARBOR_PASSWORD}' type: SECRET_TEXT - macro: '{$HARBOR_URL}' value: 127.0.0.1 - macro: '{$HARBOR_USERNAME}' type: SECRET_TEXT triggers: - uuid: 028340cd13c043b4add68bf670e1cf43 expression: 'last(/Harbor/harbor.status.notary,#1:now-1s)=0 and last(/Harbor/harbor.system.info.with_notary)="true"' name: 'Harbor service: Notary is unhealthy' priority: AVERAGE