-
Notifications
You must be signed in to change notification settings - Fork 612
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
experiment: add experimental metrics exporter #2899
Conversation
func (v *TimerVec) createPprofLabels(lvs []string) pprof.LabelSet { | ||
k := v.labels.Copy() | ||
if len(lvs) > 0 { | ||
for i, lv := range lvs { | ||
k[i].Value = lv | ||
} | ||
} | ||
sort.Sort(k) | ||
var b bytes.Buffer | ||
b.WriteString(pprofMetricLabelPrefix) | ||
b.WriteByte('{') | ||
for i, l := range k { | ||
if i > 0 { | ||
b.WriteByte(',') | ||
b.WriteByte(' ') | ||
} | ||
b.WriteString(l.Name) | ||
b.WriteByte('=') | ||
b.WriteString(strconv.Quote(l.Value)) | ||
} | ||
b.WriteByte('}') | ||
return pprof.Labels(b.String(), "") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ineffective, but very simple method. Note that we should not mix metric labels with pprof labels
for _, series := range req.Series { | ||
for _, sample := range series.Samples { | ||
mr := exporter.WriteRequest{ | ||
Timestamp: time.Unix(0, sample.Profile.TimeNanos).UnixMilli(), | ||
} | ||
pprof.ExtractMetrics(sample.Profile.Profile, func(labels labels.Labels, v int64) { | ||
mr.TimeSeries = append(mr.TimeSeries, exporter.TimeSeries{Labels: labels, Value: float64(v)}) | ||
}) | ||
|
||
if len(mr.TimeSeries) > 0 { | ||
go func() { | ||
if sendErr := d.exporter.Send(context.Background(), &mr); sendErr != nil { | ||
_ = d.logger.Log("msg", "failed to push metrics", "err", sendErr) | ||
} | ||
}() | ||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For PoC purposes only. Prometheus remote write protocol requires strict order by time within series, therefore we'll likely need a dedicated component that will handle proxying to receiver
if err := buf.Marshal(p); err != nil { | ||
return err | ||
} | ||
return e.client.Store(ctx, snappy.Encode(nil, buf.Bytes()), 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prometheus also provides a "fat" remote storage that uses WAL. We should probably consider this option
A PoC of derived metrics. See #2908 for details