# Travis CI by HTTP ## Overview The template to monitor Travis CI by Zabbix that work without any external scripts. Most of the metrics are collected in one go, thanks to Zabbix bulk data collection. ## Requirements Zabbix version: 7.0 and higher. ## Tested versions This template has been tested on: - Travis CI API V3 2021 ## Configuration > Zabbix should be configured according to the instructions in the [Templates out of the box](https://www.zabbix.com/documentation/7.0/manual/config/templates_out_of_the_box) section. ## Setup You must set {$TRAVIS.API.TOKEN} and {$TRAVIS.API.URL} macros. {$TRAVIS.API.TOKEN} is a Travis API authentication token located in User -> Settings -> API authentication. {$TRAVIS.API.URL} could be in 2 different variations: - for a private project : api.travis-ci.com - for an enterprise projects: api.example.com (where you replace example.com with the domain Travis CI is running on) ### Macros used |Name|Description|Default| |----|-----------|-------| |{$TRAVIS.API.TOKEN}|
Travis API Token
|| |{$TRAVIS.API.URL}|Travis API URL
|`api.travis-ci.com`| |{$TRAVIS.BUILDS.SUCCESS.PERCENT}|Percent of successful builds in the repo (for trigger expression)
|`80`| ### Items |Name|Description|Type|Key and additional info| |----|-----------|----|-----------------------| |Travis: Get repos|Getting repos using Travis API.
|HTTP agent|travis.get_repos| |Travis: Get builds|Getting builds using Travis API.
|HTTP agent|travis.get_builds| |Travis: Get jobs|Getting jobs using Travis API.
|HTTP agent|travis.get_jobs| |Travis: Get health|Getting home JSON using Travis API.
|HTTP agent|travis.get_health**Preprocessing**
Check for not supported value
⛔️Custom on fail: Set value to: `0`
JavaScript: `The text is too long. Please see the template.`
Total count of passed jobs in all repos.
|Dependent item|travis.jobs.total**Preprocessing**
JSON Path: `$.jobs.length()`
Active jobs in all repos.
|Dependent item|travis.jobs.active**Preprocessing**
JSON Path: `$.jobs[?(@.state == "started")].length()`
⛔️Custom on fail: Set value to: `0`
Jobs in queue in all repos.
|Dependent item|travis.jobs.queue**Preprocessing**
JSON Path: `$.jobs[?(@.state == "received")].length()`
⛔️Custom on fail: Set value to: `0`
Total count of builds in all repos.
|Dependent item|travis.builds.total**Preprocessing**
JSON Path: `$.builds.length()`
Sum of all builds durations in all repos.
|Dependent item|travis.builds.duration**Preprocessing**
JSON Path: `$..duration.sum()`
⛔️Custom on fail: Discard value
Travis API is unavailable. Please check if the correct macros are set.
|`last(/Travis CI by HTTP/travis.get_health)=0`|High|**Manual close**: Yes| |Travis: Failed to fetch home page|Zabbix has not received any data for items for the last 30 minutes.
|`nodata(/Travis CI by HTTP/travis.get_health,30m)=1`|Warning|**Manual close**: Yes| ### LLD rule Repos metrics discovery |Name|Description|Type|Key and additional info| |----|-----------|----|-----------------------| |Repos metrics discovery|Metrics for Repos statistics.
|Dependent item|travis.repos.discovery**Preprocessing**
JavaScript: `The text is too long. Please see the template.`
Discard unchanged with heartbeat: `1h`
Getting builds of {#SLUG} using Travis API.
|HTTP agent|travis.repo.get_builds[{#SLUG}]| |Travis: Repo [{#SLUG}]: Get caches|Getting caches of {#SLUG} using Travis API.
|HTTP agent|travis.repo.get_caches[{#SLUG}]| |Travis: Repo [{#SLUG}]: Cache files|Count of cache files in {#SLUG} repo.
|Dependent item|travis.repo.caches.files[{#SLUG}]**Preprocessing**
JSON Path: `$.caches.length()`
Total size of cache files in {#SLUG} repo.
|Dependent item|travis.repo.caches.size[{#SLUG}]**Preprocessing**
JSON Path: `$.caches..size.sum()`
⛔️Custom on fail: Set value to: `0`
Count of all passed builds in {#SLUG} repo.
|Dependent item|travis.repo.builds.passed[{#SLUG}]**Preprocessing**
JavaScript: `The text is too long. Please see the template.`
Count of all failed builds in {#SLUG} repo.
|Dependent item|travis.repo.builds.failed[{#SLUG}]**Preprocessing**
JavaScript: `The text is too long. Please see the template.`
Count of total builds in {#SLUG} repo.
|Dependent item|travis.repo.builds.total[{#SLUG}]**Preprocessing**
JSON Path: `$.builds.length()`
Percent of passed builds in {#SLUG} repo.
|Calculated|travis.repo.builds.passed.pct[{#SLUG}]| |Travis: Repo [{#SLUG}]: Description|Description of Travis repo (git project description).
|Dependent item|travis.repo.description[{#SLUG}]**Preprocessing**
JSON Path: `$.repositories[?(@.slug == "{#SLUG}")].description.first()`
Discard unchanged with heartbeat: `1h`
Last build duration in {#SLUG} repo.
|Dependent item|travis.repo.last_build.duration[{#SLUG}]**Preprocessing**
JSON Path: `$.builds[0].duration`
⛔️Custom on fail: Discard value
Discard unchanged with heartbeat: `1h`
Last build state in {#SLUG} repo.
|Dependent item|travis.repo.last_build.state[{#SLUG}]**Preprocessing**
JSON Path: `$.builds[0].state`
Discard unchanged with heartbeat: `1h`
Last build number in {#SLUG} repo.
|Dependent item|travis.repo.last_build.number[{#SLUG}]**Preprocessing**
JSON Path: `$.builds[0].number`
Discard unchanged with heartbeat: `1h`
Last build id in {#SLUG} repo.
|Dependent item|travis.repo.last_build.id[{#SLUG}]**Preprocessing**
JSON Path: `$.builds[0].id`
Discard unchanged with heartbeat: `1h`
Low successful builds rate.
|`last(/Travis CI by HTTP/travis.repo.builds.passed.pct[{#SLUG}])<{$TRAVIS.BUILDS.SUCCESS.PERCENT}`|Warning|**Manual close**: Yes| |Travis: Repo [{#SLUG}]: Last build status is 'errored'|Last build status is errored.
|`find(/Travis CI by HTTP/travis.repo.last_build.state[{#SLUG}],,"like","errored")=1`|Warning|**Manual close**: Yes| ## Feedback Please report any issues with the template at [`https://support.zabbix.com`](https://support.zabbix.com) You can also provide feedback, discuss the template, or ask for help at [`ZABBIX forums`](https://www.zabbix.com/forum/zabbix-suggestions-and-feedback)