In this post I will show you how to push metrics programmatically to Pushgateway. There are two types of puffed out metrics:
- Protocol buffer
In this post we will cover Protocol buffer
Library for languages
There is a library for each language, although it is a little blind spot because the metric push method to Push gateway is implemented in the client library of Prometheus. Normally, it is better to use the following library.
Pushing metrics | Prometheus
Occasionally you will need to monitor components which cannot be scraped. The Prometheus Pushgateway allows you to push…
Prometheus Client Data Specifications
The following documentation describes the format of Prometheus Client Data.
32-Bit Varint-Encoded Record Length-Delimited need to be applied
It seems good to add the Length of the entire byte string of Protocol buffer to the beginning of the byte string.
The proto file metrics.proto is published in the following repository
GitHub - prometheus/client_model: Data model artifacts for Prometheus.
This repository used to contain the protocol buffer code that defined both the data model and the exposition format of…
By the way, the structure definition metrics.pb.go for Go language is also prepared, so if you want to implement it in Go language, just go get and get it. Just in case, you should use the same version as client_model of the dependent module of Push Gateway of your version .
The value of the header
application/vnd.google.protobuf; proto=io.prometheus.client.MetricFamily; encoding=delimited
dump Is an unnecessary process for pushing metrics, and is a code written for byte string comparison.