Skip to content
This repository has been archived by the owner on Aug 23, 2023. It is now read-only.

Ensure that metric id is always set during kafka ingestion #1687

Merged
merged 4 commits into from
Feb 27, 2020
Merged
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
1 change: 1 addition & 0 deletions cmd/mt-gateway/ingest/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ func prepareIngest(in []*schema.MetricData, toPublish []*schema.MetricData) ([]*
promDiscards.Add(m.OrgId, err.Error())
continue
}
m.SetId()
metricTimestamp = getMetricsTimestampStat(m.OrgId)
metricTimestamp.ValueUint32(uint32(m.Time))
toPublish = append(toPublish, m)
Expand Down
14 changes: 6 additions & 8 deletions publish/kafka/publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,14 +276,12 @@ func (m *mtPublisher) Publish(metrics []*schema.MetricData) error {

for _, metric := range metrics {
if metric.Interval == 0 {
if m.autoInterval {
_, s := m.schemas.Match(metric.Name, 0)
metric.Interval = s.Retentions.Rets[0].SecondsPerPoint
metric.SetId()
} else {
log.Error("interval is 0 but can't deduce interval automatically. this should never happen")
return errors.New("need to deduce interval but cannot")
}
log.Error("interval must be set before publishing")
return errors.New("interval must be set before publishing")
}
if metric.Id == "" {
log.Error("metric ID must be set before publishing")
return errors.New("metric ID must be set before publishing")
}

isMD := false
Expand Down
3 changes: 3 additions & 0 deletions publish/publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ var (
)

type Publisher interface {
//Publish the given metrics.
//Requires that the metric interval and ID have been set
Publish(metrics []*schema.MetricData) error
//Type returns the type of system the Publisher publishes to
Type() string
}

Expand Down