Add Prometheus remote write output plugin.#5003
Conversation
|
Thanks for the pull request, this sounds useful. This would work with any of these integrations that are marked as write? |
|
@danielnelson thats right! |
|
@danielnelson anything I can do to help this along? |
| } | ||
| defer resp.Body.Close() | ||
|
|
||
| if resp.StatusCode/100 != 2 { |
There was a problem hiding this comment.
I would prefer matching the exact status codes or range, to avoid any potential issue where an error can be missed.
There was a problem hiding this comment.
The protocol doesn't specify the exact code, and I know some implementation return 200 and 204 (no content).
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| syntax = "proto3"; |
There was a problem hiding this comment.
This seems like it copied from the prometheus library, is there a package would we need to import to avoid duplicating this file? I would only want to define this again here if it would be a hit on binary size.
There was a problem hiding this comment.
The biggest problem is Prometheus imports quite a few projects (for service discovery), including kubernetes, so eventually we end up importing the world and conflicting on versions. I gave it a go and it wasn't as bad as I expected.
| copy(labels, commonLabels) | ||
| labels = append(labels, &Label{ | ||
| Name: "__name__", | ||
| Value: metric.Name() + "_" + field.Key, |
There was a problem hiding this comment.
We may wish to mirror this code to special case a few input formats, this is useful for round tripping data collected by the prometheus input.
telegraf/plugins/outputs/prometheus_client/prometheus_client.go
Lines 472 to 488 in 1334919
Signed-off-by: Tom Wilkie <tom.wilkie@gmail.com>
Signed-off-by: Tom Wilkie <tom.wilkie@gmail.com>
Signed-off-by: Tom Wilkie <tom.wilkie@gmail.com>
Signed-off-by: Tom Wilkie <tom.wilkie@gmail.com>
4feaa00 to
35b28de
Compare
Required pinning / updating a couple of dependancies, but wasn't as bad as I first throught. Signed-off-by: Tom Wilkie <tom.wilkie@gmail.com>
Signed-off-by: Tom Wilkie <tom.wilkie@gmail.com>
|
Most of the feedback done; I'd like to refactor and dedupe some of the code with the existing prometheus output format first though, and add support for histograms. WDYT so far? |
danielnelson
left a comment
There was a problem hiding this comment.
Looks good, feel free to refactor the prometheus output code so long as the output format isn't changed. You can create a package internal/prometheus if you need a place for shared code.
| version = "0.2.3" | ||
|
|
||
| [[constraint]] | ||
| name = "github.com/golang/protobuf" |
There was a problem hiding this comment.
This is a direct dependency, as is genproto, so they should both stay in the Gopkg.toml. I think perhaps you ran into grpc-ecosystem/grpc-gateway#829, if so we can use the override to workaround the issue:
[[constraint]]
name = "github.com/golang/protobuf"
version = "1.1.0"
version = "1.2.0"
[[override]]
name = "github.com/golang/protobuf"
version = "1.2.0"
|
@tomwilkie Just a heads up in case you need this to go out with the next release, we are hoping to do an release candidate for 1.10 on the 12th. |
…mp order mismatch 1. Add bearer Token support 2. Sanitize the metrics to follow prometheus format i.e having underscrore. 3. Sorted returns a copy of the metrics in time ascending order. A copy is made to avoid modifying the input metric slice since doing so causing issue of timestamp order mismatch.
Add support of Bearer Token and handle timestamp order mismatch issue
|
@tomwilkie @danielnelson What else is pending on this PR? I am happy to work on this if there any work required. |
|
Please let me know if i can help :) |
|
Continued on #5942 |
Add a output plugin that allows Telegraf to send metrics to systems which support Prometheus remote write format (such as Cortex).
Doesn't handle histograms or summaries right now. Tested and it works.
Signed-off-by: Tom Wilkie tom.wilkie@gmail.com
Required for all PRs: