Skip to content

go client doesn't work  #53

@pingwangrh

Description

@pingwangrh

trying the example code from go client doc: https://pkg.go.dev/github.com/prometheus/client_golang/prometheus/push?utm_source=godoc#Pusher.Push

it works with the normal pushgateway, but if I point the url to prom-aggregation-gateway,
got error: Could not push to Pushgateway: unexpected status code 400 while pushing to http://localhost:8080/metrics/job/ping_test: text format parsing error in line 1: expected float as value, got ""

package main

import (
	"fmt"

	"github.com/prometheus/client_golang/prometheus"
	"github.com/prometheus/client_golang/prometheus/push"
)

func main() {
	completionTime := prometheus.NewGauge(prometheus.GaugeOpts{
		Name: "db_backup_last_completion_timestamp_seconds",
		Help: "The timestamp of the last successful completion of a DB backup.",
	})
	completionTime.SetToCurrentTime()
	if err := push.New("http://pushgateway:9091", "ping_test").
		Collector(completionTime).
		Grouping("db", "customers").
		Push(); err != nil {
		fmt.Println("Could not push completion time to Pushgateway:", err)
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions