Prometheus Remote Write protocol support#8702
Prometheus Remote Write protocol support#8702aleksey-novikov wants to merge 3 commits intoinfluxdata:masterfrom
Conversation
There was a problem hiding this comment.
Thanks so much for the pull request!
🤝 ✒️ Just a reminder that the CLA has not yet been signed, and we'll need it before merging. Please sign the CLA when you get a chance, then post a comment here saying !signed-cla
|
This pull request introduces 1 alert when merging a3f26a6 into 76c2201 - view on LGTM.com new alerts:
|
|
Fixes #8682 |
| "github.com/prometheus/prometheus/prompb" | ||
| "github.com/gogo/protobuf/proto" | ||
| "github.com/prometheus/common/model" |
|
|
||
|
|
There was a problem hiding this comment.
Please just one newline. Same for all of those instances below.
| metric, err := metric.New("prometheusremotewrite", tags, fields, t) | ||
| if err == nil { |
There was a problem hiding this comment.
We might silently drop metrics here without allowing the user to be aware of this. Please either fail here (i.e. return err) or at least issue a log message in case we see an error here.
| tags[l.Name] = l.Value | ||
| } | ||
|
|
||
| metricName := tags[model.MetricNameLabel] |
There was a problem hiding this comment.
Can we be absolutely sure that tag exists? I will sleep better if we check that model.MetricNameLabel exists in tags by
| metricName := tags[model.MetricNameLabel] | |
| metricName := tags[model.MetricNameLabel] | |
| if metricName == "" { | |
| return fmt.Errorf("metric name %q not found in tag-set or empty", model.MetricNameLabel) | |
| } |
| metricName := tags[model.MetricNameLabel] | ||
| delete(tags, model.MetricNameLabel) | ||
|
|
||
| for _, s := range ts.Samples { |
There was a problem hiding this comment.
As we approximately know how many metrics we expect we might want to preallocate the array with the number of samples, i.e. capacity = len(ts.Samples) and len = 0.
| for _, l := range ts.Labels { | ||
| tags[l.Name] = l.Value | ||
| } | ||
|
|
There was a problem hiding this comment.
You also have to add the DefaultTags here.
| delete(tags, model.MetricNameLabel) | ||
|
|
||
| for _, s := range ts.Samples { | ||
| fields := getNameAndValue(&s, metricName) |
There was a problem hiding this comment.
Maybe you should move the code here. It's not a lot and this would follow the tags handling.
|
|
||
| // converting to telegraf metric | ||
| if len(fields) > 0 { | ||
| t := getTimestamp(&s, now) |
There was a problem hiding this comment.
You might also move the body of the function here. See above.
srebhan
left a comment
There was a problem hiding this comment.
Hey @aleksey-novikov, this is really nice code! I have some comments in the code. Additionally I have some major comments/requests:
- Please split the
http_listener,snappyencoding change into an own PR. I think this is independent of the prometheus parser a very useful change. - Please add tests! This holds for both, the
snappysupport as well as the parser part. Provide some examples where you know the expected output. - This is more a question/suggestion rather than a request: Do you think it makes sense to collect samples from the same timestamp into one metric? Not sure if this makes sense at all, but I want to know your opinion on this...
- You should add a README.md with some parsing result examples. Furthermore, you need to extend the list of available parsers etc.
|
Hi @aleksey-novikov 👋 , Just checking if you can address @srebhan's comments. We'd love to get this in our upcoming 1.18 feature release targeted for the end of March. |
|
@aleksey-novikov - Another ping. We'd love to get this into 1.18 so let us know if you want to make the changes otherwise someone on the influx side can finish it up. Thanks! |
|
Hey @aleksey-novikov great work! We're really interested on working to get this merged in. Are you interested in carrying on with the PR? If you could address some of @srebhan's comments. If not I can take over the PR and get it to a ready to merge state to be merged. |
|
Hi @helenosheaa! |
|
Hi @aleksey-novikov, thanks for getting back to me quickly. I'll start my own PR and link to this one and close when it's up. Thanks for getting it going and if you have any feedback when I submit mine please comment. |
|
Closing to move forward with #8967 |
Prometheus Remote Write protocol
This is basic implementation of Prometheus Remote Write Protocol. Includes:
Must be used with http_listener_v2
Sample input configuration:
Closes #8682