2019-05-22 23:16:55 +02:00
|
|
|
// Code generated by qtc from "federate.qtpl". DO NOT EDIT.
|
|
|
|
// See https://github.com/valyala/quicktemplate for details.
|
|
|
|
|
|
|
|
//line app/vmselect/prometheus/federate.qtpl:1
|
|
|
|
package prometheus
|
|
|
|
|
|
|
|
//line app/vmselect/prometheus/federate.qtpl:1
|
|
|
|
import (
|
2022-10-01 18:47:35 +02:00
|
|
|
"math"
|
|
|
|
|
2019-05-22 23:16:55 +02:00
|
|
|
"github.com/VictoriaMetrics/VictoriaMetrics/app/vmselect/netstorage"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Federate writes rs in /federate format.// See https://prometheus.io/docs/prometheus/latest/federation/
|
|
|
|
|
2022-10-01 18:47:35 +02:00
|
|
|
//line app/vmselect/prometheus/federate.qtpl:11
|
2019-05-22 23:16:55 +02:00
|
|
|
import (
|
|
|
|
qtio422016 "io"
|
|
|
|
|
|
|
|
qt422016 "github.com/valyala/quicktemplate"
|
|
|
|
)
|
|
|
|
|
2022-10-01 18:47:35 +02:00
|
|
|
//line app/vmselect/prometheus/federate.qtpl:11
|
2019-05-22 23:16:55 +02:00
|
|
|
var (
|
|
|
|
_ = qtio422016.Copy
|
|
|
|
_ = qt422016.AcquireByteBuffer
|
|
|
|
)
|
|
|
|
|
2022-10-01 18:47:35 +02:00
|
|
|
//line app/vmselect/prometheus/federate.qtpl:11
|
2019-05-22 23:16:55 +02:00
|
|
|
func StreamFederate(qw422016 *qt422016.Writer, rs *netstorage.Result) {
|
2022-10-01 18:47:35 +02:00
|
|
|
//line app/vmselect/prometheus/federate.qtpl:13
|
|
|
|
values := rs.Values
|
|
|
|
timestamps := rs.Timestamps
|
|
|
|
|
|
|
|
//line app/vmselect/prometheus/federate.qtpl:16
|
|
|
|
if len(timestamps) == 0 || len(values) == 0 {
|
|
|
|
//line app/vmselect/prometheus/federate.qtpl:16
|
2019-05-22 23:16:55 +02:00
|
|
|
return
|
2022-10-01 18:47:35 +02:00
|
|
|
//line app/vmselect/prometheus/federate.qtpl:16
|
2019-05-22 23:16:55 +02:00
|
|
|
}
|
2022-10-01 18:47:35 +02:00
|
|
|
//line app/vmselect/prometheus/federate.qtpl:18
|
|
|
|
lastValue := values[len(values)-1]
|
|
|
|
|
|
|
|
//line app/vmselect/prometheus/federate.qtpl:20
|
|
|
|
if math.IsNaN(lastValue) {
|
|
|
|
//line app/vmselect/prometheus/federate.qtpl:26
|
|
|
|
return
|
|
|
|
//line app/vmselect/prometheus/federate.qtpl:27
|
|
|
|
}
|
|
|
|
//line app/vmselect/prometheus/federate.qtpl:28
|
2019-05-22 23:16:55 +02:00
|
|
|
streamprometheusMetricName(qw422016, &rs.MetricName)
|
2022-10-01 18:47:35 +02:00
|
|
|
//line app/vmselect/prometheus/federate.qtpl:28
|
2019-05-22 23:16:55 +02:00
|
|
|
qw422016.N().S(` `)
|
2022-10-01 18:47:35 +02:00
|
|
|
//line app/vmselect/prometheus/federate.qtpl:29
|
|
|
|
qw422016.N().F(lastValue)
|
|
|
|
//line app/vmselect/prometheus/federate.qtpl:29
|
2019-05-22 23:16:55 +02:00
|
|
|
qw422016.N().S(` `)
|
2022-10-01 18:47:35 +02:00
|
|
|
//line app/vmselect/prometheus/federate.qtpl:30
|
|
|
|
qw422016.N().DL(timestamps[len(timestamps)-1])
|
|
|
|
//line app/vmselect/prometheus/federate.qtpl:30
|
2019-05-22 23:16:55 +02:00
|
|
|
qw422016.N().S(`
|
|
|
|
`)
|
2022-10-01 18:47:35 +02:00
|
|
|
//line app/vmselect/prometheus/federate.qtpl:31
|
2019-05-22 23:16:55 +02:00
|
|
|
}
|
|
|
|
|
2022-10-01 18:47:35 +02:00
|
|
|
//line app/vmselect/prometheus/federate.qtpl:31
|
2019-05-22 23:16:55 +02:00
|
|
|
func WriteFederate(qq422016 qtio422016.Writer, rs *netstorage.Result) {
|
2022-10-01 18:47:35 +02:00
|
|
|
//line app/vmselect/prometheus/federate.qtpl:31
|
2019-05-22 23:16:55 +02:00
|
|
|
qw422016 := qt422016.AcquireWriter(qq422016)
|
2022-10-01 18:47:35 +02:00
|
|
|
//line app/vmselect/prometheus/federate.qtpl:31
|
2019-05-22 23:16:55 +02:00
|
|
|
StreamFederate(qw422016, rs)
|
2022-10-01 18:47:35 +02:00
|
|
|
//line app/vmselect/prometheus/federate.qtpl:31
|
2019-05-22 23:16:55 +02:00
|
|
|
qt422016.ReleaseWriter(qw422016)
|
2022-10-01 18:47:35 +02:00
|
|
|
//line app/vmselect/prometheus/federate.qtpl:31
|
2019-05-22 23:16:55 +02:00
|
|
|
}
|
|
|
|
|
2022-10-01 18:47:35 +02:00
|
|
|
//line app/vmselect/prometheus/federate.qtpl:31
|
2019-05-22 23:16:55 +02:00
|
|
|
func Federate(rs *netstorage.Result) string {
|
2022-10-01 18:47:35 +02:00
|
|
|
//line app/vmselect/prometheus/federate.qtpl:31
|
2019-05-22 23:16:55 +02:00
|
|
|
qb422016 := qt422016.AcquireByteBuffer()
|
2022-10-01 18:47:35 +02:00
|
|
|
//line app/vmselect/prometheus/federate.qtpl:31
|
2019-05-22 23:16:55 +02:00
|
|
|
WriteFederate(qb422016, rs)
|
2022-10-01 18:47:35 +02:00
|
|
|
//line app/vmselect/prometheus/federate.qtpl:31
|
2019-05-22 23:16:55 +02:00
|
|
|
qs422016 := string(qb422016.B)
|
2022-10-01 18:47:35 +02:00
|
|
|
//line app/vmselect/prometheus/federate.qtpl:31
|
2019-05-22 23:16:55 +02:00
|
|
|
qt422016.ReleaseByteBuffer(qb422016)
|
2022-10-01 18:47:35 +02:00
|
|
|
//line app/vmselect/prometheus/federate.qtpl:31
|
2019-05-22 23:16:55 +02:00
|
|
|
return qs422016
|
2022-10-01 18:47:35 +02:00
|
|
|
//line app/vmselect/prometheus/federate.qtpl:31
|
2019-05-22 23:16:55 +02:00
|
|
|
}
|