Git Product home page Git Product logo

Comments (3)

iwinux avatar iwinux commented on May 27, 2024

Got the same problem here, with collectd 5.5.0 and collectd_exporter 0.2.0.

Tracked down to expfmt.MetricFamilyToText(), but I have no idea why a counter could be recognized as a gauge.

from collectd_exporter.

iwinux avatar iwinux commented on May 27, 2024

There're actually two errors alternating:

  • expected counter in metric collectd_nginx_connections
  • expected gauge in metric collectd_nginx_connections

A possible cause is: multiple different metrics (with Dstype gauge and derive) share the same name, which confuses Prometheus's API.

Here's my debug code:

diff --git a/main.go b/main.go
index 4b0f14e..5fd960f 100644
--- a/main.go
+++ b/main.go
@@ -113,7 +113,14 @@ func newMetric(vl api.ValueList, index int) (prometheus.Metric, error) {
                return nil, fmt.Errorf("unknown value type: %T", v)
        }

-       return prometheus.NewConstMetric(newDesc(vl, index), valueType, value)
+       name := newName(vl, index)
+       desc := newDesc(vl, index)
+
+       if name == "collectd_nginx_connections" {
+               log.Printf("%v\n", desc)
+       }
+
+       return prometheus.NewConstMetric(desc, valueType, value)
 }

 type collectdCollector struct {

And this is what I got:

$ ./collectd_exporter -log.level=debug
INFO[0000] Starting Server: :9103                        file=main.go line=273

INFO[0010] Desc{fqName: "collectd_nginx_connections", help: "Collectd exporter: 'nginx' Type: 'nginx_connections' Dstype: 'api.Gauge' Dsname: 'value'", constLabels: {instance="zerus",nginx="waiting"}, variableLabels: []}
  file=main.go line=120

INFO[0010] Desc{fqName: "collectd_nginx_connections", help: "Collectd exporter: 'nginx' Type: 'connections' Dstype: 'api.Derive' Dsname: 'value'", constLabels: {instance="zerus",nginx="handled"}, variableLabels: []}
  file=main.go line=120

INFO[0010] Desc{fqName: "collectd_nginx_connections", help: "Collectd exporter: 'nginx' Type: 'nginx_connections' Dstype: 'api.Gauge' Dsname: 'value'", constLabels: {instance="zerus",nginx="writing"}, variableLabels: []}
  file=main.go line=120

INFO[0010] Desc{fqName: "collectd_nginx_connections", help: "Collectd exporter: 'nginx' Type: 'nginx_connections' Dstype: 'api.Gauge' Dsname: 'value'", constLabels: {instance="zerus",nginx="active"}, variableLabels: []}
  file=main.go line=120

INFO[0010] Desc{fqName: "collectd_nginx_connections", help: "Collectd exporter: 'nginx' Type: 'connections' Dstype: 'api.Derive' Dsname: 'value'", constLabels: {instance="zerus",nginx="accepted"}, variableLabels: []}
  file=main.go line=120

INFO[0010] Desc{fqName: "collectd_nginx_connections", help: "Collectd exporter: 'nginx' Type: 'nginx_connections' Dstype: 'api.Gauge' Dsname: 'value'", constLabels: {instance="zerus",nginx="reading"}, variableLabels: []}
  file=main.go line=120

from collectd_exporter.

iwinux avatar iwinux commented on May 27, 2024

FYI, this is how write_graphite plugin of collectd concats the "labels":

collectd.zerus.nginx.connections.accepted.value
collectd.zerus.nginx.connections.handled.value
collectd.zerus.nginx.nginx_connections.active.value
collectd.zerus.nginx.nginx_connections.reading.value
collectd.zerus.nginx.nginx_connections.waiting.value
collectd.zerus.nginx.nginx_connections.writing.value
collectd.zerus.nginx.nginx_requests.value

from collectd_exporter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.