5.02021-11-21T22:08:31ZHarborHarborHarbor## 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
HarborHarbor- System Status InformationHTTP_AGENTharbor.allstatus30s00TEXTBASIC{$HARBOR_USERNAME}{$HARBOR_PASSWORD}HarborJSONPATH$.body{$HARBOR_URL}/api/v2.0/healthNOJSONYESYES
- StatisticsHTTP_AGENTharbor.statistics00TEXTBASIC{$HARBOR_USERNAME}{$HARBOR_PASSWORD}HarborJSONPATH$.body{$HARBOR_URL}/api/v2.0/statisticsNOJSONYESYES
- Private Project CountDEPENDENTharbor.statistics.private_project_count0HarborJSONPATH$.private_project_countharbor.statistics
- Private Repository CountDEPENDENTharbor.statistics.private_repo_count0HarborJSONPATH$.private_repo_countharbor.statistics
- Public Project CountDEPENDENTharbor.statistics.public_project_count0HarborJSONPATH$.public_project_countharbor.statistics
- Public Repository CountDEPENDENTharbor.statistics.public_repo_count0356dHarborJSONPATH$.public_repo_countharbor.statistics
- StatusDEPENDENTharbor.status01: healthy
0: unhealthyHarborJSONPATH$.statusJAVASCRIPTif(value == "healthy"){
return 1;
} else {
return 0;
}
harbor.allstatus{last(#1,1)}=0Harbor services is unhealthyDISABLEDAVERAGE
- Status of CoreDEPENDENTharbor.status.core01: healthy
0: unhealthyHarborJSONPATH$.components[?(@.name == 'core')].status.first()JAVASCRIPTif(value == "healthy"){
return 1;
} else {
return 0;
}harbor.allstatus{last(#1,1)}=0Harbor service: Core is unhealthyAVERAGE
- Status of DatabaseDEPENDENTharbor.status.database01: healthy
0: unhealthyHarborJSONPATH$.components[?(@.name == 'database')].status.first()JAVASCRIPTif(value == "healthy"){
return 1;
} else {
return 0;
}harbor.allstatus{last(#1,1)}=0Harbor service: Database is unhealthyAVERAGE
- Status of JobserviceDEPENDENTharbor.status.jobservice01: healthy
0: unhealthyHarborJSONPATH$.components[?(@.name == 'jobservice')].status.first()JAVASCRIPTif(value == "healthy"){
return 1;
} else {
return 0;
}harbor.allstatus{last(#1,1)}=0Harbor service: Jobservice is unhealthyAVERAGE
- Status of NotaryDEPENDENTharbor.status.notary01: healthy
0: unhealthyHarborJSONPATH$.components[?(@.name == 'notary')].status.first()JAVASCRIPTif(value == "healthy"){
return 1;
} else {
return 0;
}harbor.allstatus
- Status of PortalDEPENDENTharbor.status.portal01: healthy
0: unhealthyHarborJSONPATH$.components[?(@.name == 'portal')].status.first()JAVASCRIPTif(value == "healthy"){
return 1;
} else {
return 0;
}harbor.allstatus{last(#1,1)}=0Harbor service: Portal is unhealthyAVERAGE
- Status of RedisDEPENDENTharbor.status.redis01: healthy
0: unhealthyHarborJSONPATH$.components[?(@.name == 'redis')].status.first()JAVASCRIPTif(value == "healthy"){
return 1;
} else {
return 0;
}harbor.allstatus{last(#1,1)}=0Harbor service: Redis is unhealthyAVERAGE
- Status of RegistryDEPENDENTharbor.status.registry01: healthy
0: unhealthyHarborJSONPATH$.components[?(@.name == 'registry')].status.first()JAVASCRIPTif(value == "healthy"){
return 1;
} else {
return 0;
}harbor.allstatus{last(#1,1)}=0Harbor service: Registry is unhealthyAVERAGE
- Status of RegistryctlDEPENDENTharbor.status.registryctl01: healthy
0: unhealthyHarborJSONPATH$.components[?(@.name == 'registryctl')].status.first()JAVASCRIPTif(value == "healthy"){
return 1;
} else {
return 0;
}harbor.allstatus{last(#1,1)}=0Harbor service: RegistryCtl is unhealthyAVERAGE
- System InformationHTTP_AGENTharbor.system.info5m00TEXTBASIC{$HARBOR_USERNAME}{$HARBOR_PASSWORD}HarborJSONPATH$.body{$HARBOR_URL}/api/v2.0/systeminfoNOJSONYESYES
- Auth modeDEPENDENTharbor.system.info.auth_mode00TEXTHarborJSONPATH$.auth_modeharbor.system.info
- External URLDEPENDENTharbor.system.info.external_url00TEXTHarborJSONPATH$.external_urlharbor.system.info
- Has CA RootDEPENDENTharbor.system.info.has_ca_root00TEXTHarborJSONPATH$.has_ca_rootharbor.system.info
- Notification EnableDEPENDENTharbor.system.info.notification_enable00TEXTHarborJSONPATH$.notification_enableharbor.system.info
- Project Creation RestrictionDEPENDENTharbor.system.info.project_creation_restriction00TEXTHarborJSONPATH$.project_creation_restrictionharbor.system.info
- Read OnlyDEPENDENTharbor.system.info.read_only00TEXTHarborJSONPATH$.read_onlyharbor.system.info
- Registry Storage Provider NameDEPENDENTharbor.system.info.registry_storage_provider_name00TEXTHarborJSONPATH$.registry_storage_provider_nameharbor.system.info
- Registry URLDEPENDENTharbor.system.info.registry_url00TEXTHarborJSONPATH$.registry_urlharbor.system.info
- Self RestrictionDEPENDENTharbor.system.info.self_registration00TEXTHarborJSONPATH$.self_registrationharbor.system.info
- VersionDEPENDENTharbor.system.info.version00TEXTHarborJSONPATH$.harbor_versionharbor.system.info
- System Volume InformationHTTP_AGENTharbor.system.info.volume30s00TEXTBASIC{$HARBOR_USERNAME}{$HARBOR_PASSWORD}HarborJSONPATH$.body{$HARBOR_URL}/api/v2.0/systeminfo/volumesNOJSONYESYES
- Free volume storage sizeDEPENDENTharbor.system.info.volume.storage.free0BHarborJSONPATH$.storage.freeharbor.system.info.volume
- Free volume storage size (percent)CALCULATEDharbor.system.info.volume.storage.free.percentFLOAT%100*last("harbor.system.info.volume.storage.free")/last("harbor.system.info.volume.storage.total")Harbor{last()}<10Free Harbor volume storage size < 10 %HIGH{last()}<20Free Harbor volume storage size < 20 %AVERAGE
- Total volume storage sizeDEPENDENTharbor.system.info.volume.storage.total0BHarborJSONPATH$.storage.totalharbor.system.info.volume
- With ChatmuseumDEPENDENTharbor.system.info.with_chartmuseum00TEXTHarborJSONPATH$.with_chartmuseumharbor.system.info
- With NotaryDEPENDENTharbor.system.info.with_notary00TEXTHarborJSONPATH$.with_notaryharbor.system.info
- Core log watchZABBIX_ACTIVElog[/var/log/harbor/core.log,"Handle notification with Handler 'AuditLog' on topic (.*)",,,,\1]20s7d0LOGCore log monitoringHarbor{str(PULL)}=0Harbor Operation on {HOST.NAME}INFOExcluding image pulling actions.MULTIPLEYES
{$HARBOR_PASSWORD}SECRET_TEXT{$HARBOR_URL}127.0.0.1{$HARBOR_USERNAME}SECRET_TEXT{Harbor:harbor.status.notary.last(#1,1)}=0 and {Harbor:harbor.system.info.with_notary.last()}="true"Harbor service: Notary is unhealthyAVERAGE