duplicate metrics collector registration attempted

174 views
Skip to first unread message

akshay sharma

unread,
Oct 27, 2020, 3:44:18 AM10/27/20
to promethe...@googlegroups.com
Hi,

i'm trying to send metrics of same type but with different value, but facing this error
duplicate metrics collector registration attempted.

Code snippet
// A CPUStat contains statistics for an individual CPU.
type CPUStat struct {
        // The ID of the CPU.
        ID string

        // Value of cpu usage
        Value int
}

func main() {

        for i:=0; i<=100000; i++ {
           opts := new(CPUStat)
           opts.ID = "1"
           opts.Value =  i

          // Make Prometheus client aware of our collector.
           c := newCollector(*opts)
           prometheus.MustRegister(c)

           if err := push.New("http://xxx.xx.xx.xxx:30091/", "db_usage").
                Collector(c).
                //Grouping("db", "customers").
                Push(); err != nil {
                fmt.Println("Could not push completion time to Pushgateway:", err)
           }

How To register multiple collector for same metrics?
Reply all
Reply to author
Forward
0 new messages