I am attempting to use the golang experimental module to remote write data to a local prometheus instance however the metadata for the gauge is failing to show up in the prometheus ui. I understand that remote_write v1 protocol does not send metadata so I am using a v2 request but still not seeing metadata in the ui. Anyone know if my configuration is incorrect or if this is not possible and I have misinterpreted something?
OS: darwin Tahoe 26.4
Arch: arm64
Prometheus version: 3.11.1
prometheus.yml
global:
scrape_interval: 7s
evaluation_interval: 7s
scrape_configs:
- job_name: "prometheus"
static_configs:
- targets: ["localhost:9090"]
labels:
app: "prometheus"
remote_write:
- url: "http://localhost:9090/api/v1/write"
protobuf_message: "io.prometheus.write.v2.Request"
metadata_config:
send: true
send_interval: 5s
Starting prometheus as so...
./prometheus \
--config.file=prometheus.yml \
--web.enable-remote-write-receiver
go remote_writer
import (
"context"
"crypto/tls"
"log"
"net/http"
"time"
"github.com/prometheus/client_golang/exp/api/remote"
writev2 "github.com/prometheus/client_golang/exp/api/remote/genproto/v2"
)
func main() {
httpClient := &http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
},
}
apiOpts := []remote.APIOption{remote.WithAPIHTTPClient(httpClient)}
api, err := remote.NewAPI("http://localhost:9090/", apiOpts...)
if err != nil {
log.Fatalf("remote API: %v", err)
}
sym := writev2.NewSymbolTable()
labelsRefs := []string{"__name__", "super_fast_gpu"}
help := "super_fast_gpu help"
unit := "_ratio"
ts := &writev2.TimeSeries{
LabelsRefs: sym.SymbolizeLabels(labelsRefs, nil),
Samples: []*writev2.Sample{
{Value: 100.0, Timestamp: time.Now().UnixMilli()},
},
Metadata: &writev2.Metadata{
Type: writev2.Metadata_METRIC_TYPE_GAUGE,
HelpRef: sym.Symbolize(help),
UnitRef: sym.Symbolize(unit),
},
}
req := &writev2.Request{
Symbols: sym.Symbols(),
Timeseries: []*writev2.TimeSeries{ts},
}
req.Symbols = sym.Symbols()
stats, err := api.Write(context.Background(), remote.WriteV2MessageType, req)
if err != nil {
log.Fatalf("remote_write v2 failed: %v", err)
}
log.Printf("remote_write v2 ok samples=%d", stats.Samples)
}
I am attempting to use the golang experimental module to remote write data to a local prometheus instance however the metadata for the gauge is failing to show up in the prometheus ui. I understand that remote_write v1 protocol does not send metadata so I am using a v2 request but still not seeing metadata in the ui. Anyone know if my configuration is incorrect or if this is not possible and I have misinterpreted something?
OS: darwin Tahoe 26.4
Arch: arm64
Prometheus version: 3.11.1
prometheus.ymlStarting prometheus as so...
go remote_writer