Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pkg/export/export_gauge.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,16 @@ func (c *Metrics) Collect(ch chan<- prometheus.Metric) {
logger.Error(fmt.Sprintf("[ %s ] json.Unmarshal error: %v", recordCertInfoCacheKey, err))
continue
}
seenIDs := make(map[string]bool)
for _, v := range recordCerts {
if v.RecordID == "" {
continue
}
if seenIDs[v.RecordID] {
logger.Error(fmt.Sprintf("【Duplicate Found】Cloud: %s, Domain: %s, RecordID: %s is duplicated!", v.CloudName, v.FullRecord, v.RecordID))
continue
}
seenIDs[v.RecordID] = true
ch <- prometheus.MustNewConstMetric(c.metrics[public.RecordCertInfo], prometheus.GaugeValue, float64(v.DaysUntilExpiry), v.CloudProvider, v.CloudName, v.DomainName, v.RecordID, v.FullRecord, v.SubjectCommonName, v.SubjectOrganization, v.SubjectOrganizationalUnit, v.IssuerCommonName, v.IssuerOrganization, v.IssuerOrganizationalUnit, v.CreatedDate, v.ExpiryDate, fmt.Sprintf("%t", v.CertMatched), v.ErrorMsg)
}
}
Expand Down
15 changes: 8 additions & 7 deletions pkg/provider/amazon.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,13 @@ func (a *AmazonDNS) ListRecords() ([]Record, error) {
CloudProvider: a.account.CloudProvider,
CloudName: a.account.CloudName,
DomainName: domain,
RecordID: public.GetID(),
RecordType: string(record.Type),
RecordWeight: fmt.Sprintf("%d", record.Weight),
RecordStatus: oneStatus("enable"),
RecordRemark: tea.StringValue(nil),
UpdateTime: carbon.CreateFromTimestampMilli(tea.Int64Value(nil)).ToDateTimeString(),
FullRecord: strings.TrimSuffix(tea.StringValue(record.Name), "."),
// RecordID: public.GetID(),
RecordType: string(record.Type),
RecordWeight: fmt.Sprintf("%d", record.Weight),
RecordStatus: oneStatus("enable"),
RecordRemark: tea.StringValue(nil),
UpdateTime: carbon.CreateFromTimestampMilli(tea.Int64Value(nil)).ToDateTimeString(),
FullRecord: strings.TrimSuffix(tea.StringValue(record.Name), "."),
}
// aws域名返回完整域名处理
recordName := strings.TrimSuffix(tea.StringValue(record.Name), ".")
Expand All @@ -162,6 +162,7 @@ func (a *AmazonDNS) ListRecords() ([]Record, error) {
}
if record.ResourceRecords != nil {
for _, record := range record.ResourceRecords {
recordInfo.RecordID = public.GetID()
recordInfo.RecordValue = tea.StringValue(record.Value)
dataObj = append(dataObj, recordInfo)
}
Expand Down
Loading