VictoriaMetrics / metrics

Lightweight alternative to github.com/prometheus/client_golang
MIT License
538 stars 62 forks source link

[FR] Possible package push improvements #35

Closed shedimon closed 10 months ago

shedimon commented 2 years ago

Hello everyone! I have some questions/proposals to improve the user experience when pushing metrics using this library. Some of them are not backward-compatible, so it's up to you to decide on these :)

valyala commented 2 years ago

@shedimon , thanks for the feature request!

The proposed metrics_push_* metrics are published starting from v1.21.0 - see e9b4bb1534f39252df9b249495c3211ceba204db for implementation details.

As for the proposed change for extraLabels arg, it is unlikely it will be implemented because of the following issues:

extraArgs := map[string]string{
  "instance": hostname,
  "job": "foobar",
}
extraArgs := fmt.Sprintf(`instance=%q,job=%q`, hostname, "foobar")

The fmt.Sprintf() approach is already recommended by metrics package for creating metric names with non-empty set of labels. So it looks logical to keep consistency with this approach for extraLabels arg as well.

shedimon commented 2 years ago

Sure, the most important thing for me were metrics, thanks a lot!

This narrows down the ability to push metrics to external systems, since the extra_label query arg is supported only by VictoriaMetrics.

I didn't know that there are systems that implement plaintext metrics import like VM does, so thought of this as a "VM only" feature, in that case it would have made more sense to me to use the query args :)

Thanks a lot for the swift implementation!

valyala commented 10 months ago

Closing the feature request as partially done. The remaining parts of the feature request won't be implemented because of reasons outlined here.