-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrepo_collector.go
58 lines (49 loc) · 1.71 KB
/
repo_collector.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package main
import (
"strconv"
"github.com/bohrasd/aliyun-cr-exporter/aliyun"
"github.com/prometheus/client_golang/prometheus"
)
// let's not make it too complicated
func (metric_map MetricMap) initRepoDisc() {
metric_map["aliyun_acr_repo_info"] = prometheus.NewDesc(
"aliyun_acr_repo_info",
"Aliyun ACR repository downloads",
[]string{ //"downloads", "gmtCreate", "gmtModified", "logo",
"regionId", "repoAuthorizeType", "repoBuildType", //"repoDomainList",
"repoId", "repoName", "repoNamespace", "repoStatus", "repoType", "summary"}, nil)
metric_map["aliyun_acr_repo_downloads"] = prometheus.NewDesc(
"aliyun_acr_repo_downloads",
"Aliyun ACR repository downloads",
[]string{"repoName", "repoNamespace", "regionId"}, nil)
// "aliyun_acr_repo_stars": prometheus.NewDesc(
// "aliyun_acr_repo_stars",
// "Aliyun ACR repository stars",
// []string{"repoId", "repoNamespace", "regionId"}, nil),
}
func (metric_map MetricMap) collectRepoMetric(prom_ch chan<- prometheus.Metric, repo aliyun.Repo) {
prom_ch <- prometheus.MustNewConstMetric(metric_map["aliyun_acr_repo_info"], prometheus.GaugeValue,
1,
repo.RegionId,
repo.RepoAuthorizeType,
repo.RepoBuildType,
strconv.FormatInt(repo.RepoId, 10),
repo.RepoName,
repo.RepoNamespace,
repo.RepoStatus,
repo.RepoType,
repo.Summary,
)
prom_ch <- prometheus.MustNewConstMetric(metric_map["aliyun_acr_repo_downloads"], prometheus.GaugeValue,
float64(repo.Downloads),
repo.RegionId,
repo.RepoName,
repo.RepoNamespace,
)
// prom_ch <- prometheus.MustNewConstMetric(exporter.metric_map["aliyun_acr_repo_stars"], prometheus.GaugeValue,
// float64(repo.Stars),
// repo.RegionId,
// strconv.FormatInt(repo.RepoId, 10),
// repo.RepoNamespace,
// )
}