diff -Nru prometheus-bird-exporter-1.2.4+ds/debian/changelog prometheus-bird-exporter-1.2.5+ds/debian/changelog --- prometheus-bird-exporter-1.2.4+ds/debian/changelog 2020-10-01 14:12:44.000000000 +0000 +++ prometheus-bird-exporter-1.2.5+ds/debian/changelog 2021-01-24 00:29:52.000000000 +0000 @@ -1,3 +1,12 @@ +prometheus-bird-exporter (1.2.5+ds-1) unstable; urgency=medium + + * New upstream release + * Bump Standards-Version to 4.5.1 (no changes) + * Refresh patches + * Add lintian override regarding ignored Kubernetes example config + + -- Daniel Swarbrick Sun, 24 Jan 2021 01:29:52 +0100 + prometheus-bird-exporter (1.2.4+ds-1) unstable; urgency=medium [ Ben Fiedler ] diff -Nru prometheus-bird-exporter-1.2.4+ds/debian/control prometheus-bird-exporter-1.2.5+ds/debian/control --- prometheus-bird-exporter-1.2.4+ds/debian/control 2020-10-01 14:12:44.000000000 +0000 +++ prometheus-bird-exporter-1.2.5+ds/debian/control 2021-01-24 00:29:52.000000000 +0000 @@ -1,5 +1,6 @@ Source: prometheus-bird-exporter Section: net +Testsuite: autopkgtest-pkg-go Priority: optional Maintainer: Debian Go Packaging Team Uploaders: Daniel Swarbrick @@ -9,7 +10,7 @@ golang-github-prometheus-common-dev, golang-go, pandoc -Standards-Version: 4.5.0 +Standards-Version: 4.5.1 Rules-Requires-Root: no Homepage: https://github.com/czerwonk/bird_exporter Vcs-Browser: https://salsa.debian.org/go-team/packages/prometheus-bird-exporter diff -Nru prometheus-bird-exporter-1.2.4+ds/debian/gbp.conf prometheus-bird-exporter-1.2.5+ds/debian/gbp.conf --- prometheus-bird-exporter-1.2.4+ds/debian/gbp.conf 1970-01-01 00:00:00.000000000 +0000 +++ prometheus-bird-exporter-1.2.5+ds/debian/gbp.conf 2021-01-24 00:29:52.000000000 +0000 @@ -0,0 +1,6 @@ +[DEFAULT] +debian-branch = debian/sid + +[buildpackage] +dist = DEP14 +upstream-tag = upstream/%(version)s diff -Nru prometheus-bird-exporter-1.2.4+ds/debian/patches/01-default_settings.patch prometheus-bird-exporter-1.2.5+ds/debian/patches/01-default_settings.patch --- prometheus-bird-exporter-1.2.4+ds/debian/patches/01-default_settings.patch 2020-10-01 14:12:44.000000000 +0000 +++ prometheus-bird-exporter-1.2.5+ds/debian/patches/01-default_settings.patch 2021-01-24 00:29:52.000000000 +0000 @@ -16,8 +16,8 @@ enableStatic = flag.Bool("proto.static", true, "Enables metrics for protocol Static") enableDirect = flag.Bool("proto.direct", true, "Enables metrics for protocol Direct") // pre bird 2.0 -- bird6Socket = flag.String("bird.socket6", "/var/run/bird6.ctl", "Socket to communicate with bird6 routing daemon (not compatible with -bird.v2)") -+ bird6Socket = flag.String("bird.socket6", "/run/bird/bird6.ctl", "Socket to communicate with bird6 routing daemon (not compatible with -bird.v2)") - birdEnabled = flag.Bool("bird.ipv4", true, "Get protocols from bird (not compatible with -bird.v2)") - bird6Enabled = flag.Bool("bird.ipv6", true, "Get protocols from bird6 (not compatible with -bird.v2)") - ) +- bird6Socket = flag.String("bird.socket6", "/var/run/bird6.ctl", "Socket to communicate with bird6 routing daemon (not compatible with -bird.v2)") ++ bird6Socket = flag.String("bird.socket6", "/run/bird/bird6.ctl", "Socket to communicate with bird6 routing daemon (not compatible with -bird.v2)") + birdEnabled = flag.Bool("bird.ipv4", true, "Get protocols from bird (not compatible with -bird.v2)") + bird6Enabled = flag.Bool("bird.ipv6", true, "Get protocols from bird6 (not compatible with -bird.v2)") + descriptionLabels = flag.Bool("format.description-labels", false, "Add labels from protocol descriptions.") diff -Nru prometheus-bird-exporter-1.2.4+ds/debian/source/lintian-overrides prometheus-bird-exporter-1.2.5+ds/debian/source/lintian-overrides --- prometheus-bird-exporter-1.2.4+ds/debian/source/lintian-overrides 1970-01-01 00:00:00.000000000 +0000 +++ prometheus-bird-exporter-1.2.5+ds/debian/source/lintian-overrides 2021-01-24 00:29:52.000000000 +0000 @@ -0,0 +1,3 @@ +# Examples directory currently only contains a Kubernetes config, which is not +# relevant on a typical Debian system. +prometheus-bird-exporter source: package-does-not-install-examples examples/ diff -Nru prometheus-bird-exporter-1.2.4+ds/Dockerfile prometheus-bird-exporter-1.2.5+ds/Dockerfile --- prometheus-bird-exporter-1.2.4+ds/Dockerfile 2019-11-01 12:18:42.000000000 +0000 +++ prometheus-bird-exporter-1.2.5+ds/Dockerfile 2020-02-19 16:14:30.000000000 +0000 @@ -1,12 +1,12 @@ FROM golang as builder -RUN go get -d -v github.com/czerwonk/bird_exporter -WORKDIR /go/src/github.com/czerwonk/bird_exporter -RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app . +ADD . /go/bird_exporter/ +WORKDIR /go/bird_exporter +RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o /go/bin/bird_exporter FROM alpine:latest RUN apk --no-cache add ca-certificates bash WORKDIR /app -COPY --from=builder /go/src/github.com/czerwonk/bird_exporter/app bird_exporter +COPY --from=builder /go/bin/bird_exporter . EXPOSE 9324 ENTRYPOINT ["/app/bird_exporter"] diff -Nru prometheus-bird-exporter-1.2.4+ds/go.mod prometheus-bird-exporter-1.2.5+ds/go.mod --- prometheus-bird-exporter-1.2.4+ds/go.mod 2019-11-01 12:18:42.000000000 +0000 +++ prometheus-bird-exporter-1.2.5+ds/go.mod 2020-02-19 16:14:30.000000000 +0000 @@ -3,8 +3,8 @@ require ( github.com/czerwonk/bird_socket v0.0.0-20170701072538-fe8194eb5598 github.com/czerwonk/testutils v0.0.0-20170526233935-dd9dabe360d4 - github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect - github.com/modern-go/reflect2 v1.0.1 // indirect github.com/prometheus/client_golang v1.2.1 github.com/prometheus/common v0.7.0 ) + +go 1.13 diff -Nru prometheus-bird-exporter-1.2.4+ds/go.sum prometheus-bird-exporter-1.2.5+ds/go.sum --- prometheus-bird-exporter-1.2.4+ds/go.sum 2019-11-01 12:18:42.000000000 +0000 +++ prometheus-bird-exporter-1.2.5+ds/go.sum 2020-02-19 16:14:30.000000000 +0000 @@ -53,6 +53,7 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.2.1 h1:JnMpQc6ppsNgw9QPAGF6Dod479itz7lvlsMzzNayLOI= github.com/prometheus/client_golang v1.2.1/go.mod h1:XMU6Z2MjaRKVu/dC1qupJI9SiNkDYzz3xecMgSW/F+U= +github.com/prometheus/client_golang v1.4.1 h1:FFSuS004yOQEtDdTq+TAOLP5xUq63KqAFYyOi8zA+Y8= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4 h1:gQz4mCbXsO+nc9n1hCxHcGA3Zx3Eo+UHZoInFGUIXNM= diff -Nru prometheus-bird-exporter-1.2.4+ds/main.go prometheus-bird-exporter-1.2.5+ds/main.go --- prometheus-bird-exporter-1.2.4+ds/main.go 2019-11-01 12:18:42.000000000 +0000 +++ prometheus-bird-exporter-1.2.5+ds/main.go 2020-02-19 16:14:30.000000000 +0000 @@ -12,7 +12,7 @@ "github.com/prometheus/common/log" ) -const version string = "1.2.4" +const version string = "1.2.5" var ( showVersion = flag.Bool("version", false, "Print version information.") @@ -27,9 +27,10 @@ enableStatic = flag.Bool("proto.static", true, "Enables metrics for protocol Static") enableDirect = flag.Bool("proto.direct", true, "Enables metrics for protocol Direct") // pre bird 2.0 - bird6Socket = flag.String("bird.socket6", "/var/run/bird6.ctl", "Socket to communicate with bird6 routing daemon (not compatible with -bird.v2)") - birdEnabled = flag.Bool("bird.ipv4", true, "Get protocols from bird (not compatible with -bird.v2)") - bird6Enabled = flag.Bool("bird.ipv6", true, "Get protocols from bird6 (not compatible with -bird.v2)") + bird6Socket = flag.String("bird.socket6", "/var/run/bird6.ctl", "Socket to communicate with bird6 routing daemon (not compatible with -bird.v2)") + birdEnabled = flag.Bool("bird.ipv4", true, "Get protocols from bird (not compatible with -bird.v2)") + bird6Enabled = flag.Bool("bird.ipv6", true, "Get protocols from bird6 (not compatible with -bird.v2)") + descriptionLabels = flag.Bool("format.description-labels", false, "Add labels from protocol descriptions.") ) func init() { @@ -85,7 +86,7 @@ func handleMetricsRequest(w http.ResponseWriter, r *http.Request) { reg := prometheus.NewRegistry() p := enabledProtocols() - c := NewMetricCollector(*newFormat, p) + c := NewMetricCollector(*newFormat, p, *descriptionLabels) reg.MustRegister(c) promhttp.HandlerFor(reg, promhttp.HandlerOpts{ diff -Nru prometheus-bird-exporter-1.2.4+ds/metric_collector.go prometheus-bird-exporter-1.2.5+ds/metric_collector.go --- prometheus-bird-exporter-1.2.4+ds/metric_collector.go 2019-11-01 12:18:42.000000000 +0000 +++ prometheus-bird-exporter-1.2.5+ds/metric_collector.go 2020-02-19 16:14:30.000000000 +0000 @@ -12,19 +12,25 @@ exporters map[int][]metrics.MetricExporter client *client.BirdClient enabledProtocols int + newFormat bool } -func NewMetricCollector(newFormat bool, enabledProtocols int) *MetricCollector { +func NewMetricCollector(newFormat bool, enabledProtocols int, descriptionLabels bool) *MetricCollector { c := getClient() var e map[int][]metrics.MetricExporter if newFormat { - e = exportersForDefault(c) + e = exportersForDefault(c, descriptionLabels) } else { e = exportersForLegacy(c) } - return &MetricCollector{exporters: e, client: c, enabledProtocols: enabledProtocols} + return &MetricCollector{ + exporters: e, + client: c, + enabledProtocols: enabledProtocols, + newFormat: newFormat, + } } func getClient() *client.BirdClient { @@ -40,7 +46,7 @@ } func exportersForLegacy(c *client.BirdClient) map[int][]metrics.MetricExporter { - l := &metrics.LegacyLabelStrategy{} + l := metrics.NewLegacyLabelStrategy() return map[int][]metrics.MetricExporter{ protocol.BGP: {metrics.NewLegacyMetricExporter("bgp4_session", "bgp6_session", l)}, @@ -51,8 +57,8 @@ } } -func exportersForDefault(c *client.BirdClient) map[int][]metrics.MetricExporter { - l := &metrics.DefaultLabelStrategy{} +func exportersForDefault(c *client.BirdClient, descriptionLabels bool) map[int][]metrics.MetricExporter { + l := metrics.NewDefaultLabelStrategy(descriptionLabels) e := metrics.NewGenericProtocolMetricExporter("bird_protocol", true, l) return map[int][]metrics.MetricExporter{ @@ -85,7 +91,7 @@ } for _, e := range m.exporters[p.Proto] { - e.Export(p, ch) + e.Export(p, ch, m.newFormat) } } } diff -Nru prometheus-bird-exporter-1.2.4+ds/metrics/default_label_strategy.go prometheus-bird-exporter-1.2.5+ds/metrics/default_label_strategy.go --- prometheus-bird-exporter-1.2.4+ds/metrics/default_label_strategy.go 2019-11-01 12:18:42.000000000 +0000 +++ prometheus-bird-exporter-1.2.5+ds/metrics/default_label_strategy.go 2020-02-19 16:14:30.000000000 +0000 @@ -1,21 +1,66 @@ package metrics import ( + "strings" + "github.com/czerwonk/bird_exporter/protocol" ) // DefaultLabelStrategy defines the labels to add to an metric and its data retrieval method type DefaultLabelStrategy struct { + descriptionLabels bool +} + +func NewDefaultLabelStrategy(descriptionLabels bool) *DefaultLabelStrategy { + return &DefaultLabelStrategy{ + descriptionLabels: descriptionLabels, + } } // LabelNames returns the list of label names -func (*DefaultLabelStrategy) LabelNames() []string { - return []string{"name", "proto", "ip_version", "import_filter", "export_filter"} +func (d *DefaultLabelStrategy) LabelNames(p *protocol.Protocol) []string { + res := []string{"name", "proto", "ip_version", "import_filter", "export_filter"} + if d.descriptionLabels && p.Description != "" { + res = append(res, labelKeysFromDescription(p.Description)...) + } + + return res } // LabelValues returns the values for a protocol -func (*DefaultLabelStrategy) LabelValues(p *protocol.Protocol) []string { - return []string{p.Name, protoString(p), p.IPVersion, p.ImportFilter, p.ExportFilter} +func (d *DefaultLabelStrategy) LabelValues(p *protocol.Protocol) []string { + res := []string{p.Name, protoString(p), p.IPVersion, p.ImportFilter, p.ExportFilter} + if d.descriptionLabels && p.Description != "" { + res = append(res, labelValuesFromDescription(p.Description)...) + } + + return res +} + +func labelKeysFromDescription(desc string) (res []string) { + for _, x := range strings.Split(desc, ",") { + tmp := strings.Split(x, "=") + if len(tmp) != 2 { + continue + } + + res = append(res, tmp[0]) + } + + return +} + +func labelValuesFromDescription(desc string) (res []string) { + for _, x := range strings.Split(desc, ",") { + tmp := strings.Split(x, "=") + if len(tmp) != 2 { + continue + } + + res = append(res, tmp[1]) + } + + return } func protoString(p *protocol.Protocol) string { diff -Nru prometheus-bird-exporter-1.2.4+ds/metrics/generic_exporter.go prometheus-bird-exporter-1.2.5+ds/metrics/generic_exporter.go --- prometheus-bird-exporter-1.2.4+ds/metrics/generic_exporter.go 2019-11-01 12:18:42.000000000 +0000 +++ prometheus-bird-exporter-1.2.5+ds/metrics/generic_exporter.go 2020-02-19 16:14:30.000000000 +0000 @@ -7,137 +7,92 @@ // GenericProtocolMetricExporter exports metrics retrieved from Bird routing daemon type GenericProtocolMetricExporter struct { - labelStrategy LabelStrategy - upDesc *prometheus.Desc - importCountDesc *prometheus.Desc - exportCountDesc *prometheus.Desc - filterCountDesc *prometheus.Desc - preferredCountDesc *prometheus.Desc - uptimeDesc *prometheus.Desc - updatesImportReceiveCountDesc *prometheus.Desc - updatesImportRejectCountDesc *prometheus.Desc - updatesImportFilterCountDesc *prometheus.Desc - updatesImportIgnoreCountDesc *prometheus.Desc - updatesImportAcceptCountDesc *prometheus.Desc - withdrawsImportReceiveCountDesc *prometheus.Desc - withdrawsImportRejectCountDesc *prometheus.Desc - withdrawsImportFilterCountDesc *prometheus.Desc - withdrawsImportIgnoreCountDesc *prometheus.Desc - withdrawsImportAcceptCountDesc *prometheus.Desc - updatesExportReceiveCountDesc *prometheus.Desc - updatesExportRejectCountDesc *prometheus.Desc - updatesExportFilterCountDesc *prometheus.Desc - updatesExportIgnoreCountDesc *prometheus.Desc - updatesExportAcceptCountDesc *prometheus.Desc - withdrawsExportReceiveCountDesc *prometheus.Desc - withdrawsExportRejectCountDesc *prometheus.Desc - withdrawsExportFilterCountDesc *prometheus.Desc - withdrawsExportIgnoreCountDesc *prometheus.Desc - withdrawsExportAcceptCountDesc *prometheus.Desc + labelStrategy LabelStrategy + prefix string } // NewGenericProtocolMetricExporter creates a new instance of GenericProtocolMetricExporter func NewGenericProtocolMetricExporter(prefix string, newNaming bool, labelStrategy LabelStrategy) *GenericProtocolMetricExporter { - m := &GenericProtocolMetricExporter{labelStrategy: labelStrategy} - m.initDesc(prefix, newNaming) + m := &GenericProtocolMetricExporter{ + prefix: prefix, + labelStrategy: labelStrategy, + } return m } -func (m *GenericProtocolMetricExporter) initDesc(prefix string, newNaming bool) { - labels := m.labelStrategy.LabelNames() - m.upDesc = prometheus.NewDesc(prefix+"_up", "Protocol is up", labels, nil) +func (m *GenericProtocolMetricExporter) Describe(ch chan<- *prometheus.Desc) { +} + +func (m *GenericProtocolMetricExporter) Export(p *protocol.Protocol, ch chan<- prometheus.Metric, newNaming bool) { + labels := m.labelStrategy.LabelNames(p) + + var importCountDesc *prometheus.Desc + var exportCountDesc *prometheus.Desc + var filterCountDesc *prometheus.Desc + var preferredCountDesc *prometheus.Desc + + upDesc := prometheus.NewDesc(m.prefix+"_up", "Protocol is up", labels, nil) if newNaming { - m.importCountDesc = prometheus.NewDesc(prefix+"_prefix_import_count", "Number of imported routes", labels, nil) - m.exportCountDesc = prometheus.NewDesc(prefix+"_prefix_export_count", "Number of exported routes", labels, nil) - m.filterCountDesc = prometheus.NewDesc(prefix+"_prefix_filter_count", "Number of filtered routes", labels, nil) - m.preferredCountDesc = prometheus.NewDesc(prefix+"_prefix_preferred_count", "Number of preferred routes", labels, nil) + importCountDesc = prometheus.NewDesc(m.prefix+"_prefix_import_count", "Number of imported routes", labels, nil) + exportCountDesc = prometheus.NewDesc(m.prefix+"_prefix_export_count", "Number of exported routes", labels, nil) + filterCountDesc = prometheus.NewDesc(m.prefix+"_prefix_filter_count", "Number of filtered routes", labels, nil) + preferredCountDesc = prometheus.NewDesc(m.prefix+"_prefix_preferred_count", "Number of preferred routes", labels, nil) } else { - m.importCountDesc = prometheus.NewDesc(prefix+"_prefix_count_import", "Number of imported routes", labels, nil) - m.exportCountDesc = prometheus.NewDesc(prefix+"_prefix_count_export", "Number of exported routes", labels, nil) - m.filterCountDesc = prometheus.NewDesc(prefix+"_prefix_count_filter", "Number of filtered routes", labels, nil) - m.preferredCountDesc = prometheus.NewDesc(prefix+"_prefix_count_preferred", "Number of preferred routes", labels, nil) + importCountDesc = prometheus.NewDesc(m.prefix+"_prefix_count_import", "Number of imported routes", labels, nil) + exportCountDesc = prometheus.NewDesc(m.prefix+"_prefix_count_export", "Number of exported routes", labels, nil) + filterCountDesc = prometheus.NewDesc(m.prefix+"_prefix_count_filter", "Number of filtered routes", labels, nil) + preferredCountDesc = prometheus.NewDesc(m.prefix+"_prefix_count_preferred", "Number of preferred routes", labels, nil) } - m.uptimeDesc = prometheus.NewDesc(prefix+"_uptime", "Uptime of the protocol in seconds", labels, nil) - m.updatesImportIgnoreCountDesc = prometheus.NewDesc(prefix+"_changes_update_import_ignore_count", "Number of incoming updates being ignored", labels, nil) - m.updatesImportAcceptCountDesc = prometheus.NewDesc(prefix+"_changes_update_import_accept_count", "Number of incoming updates being accepted", labels, nil) - m.updatesImportFilterCountDesc = prometheus.NewDesc(prefix+"_changes_update_import_filter_count", "Number of incoming updates being filtered", labels, nil) - m.updatesImportRejectCountDesc = prometheus.NewDesc(prefix+"_changes_update_import_reject_count", "Number of incoming updates being rejected", labels, nil) - m.updatesImportReceiveCountDesc = prometheus.NewDesc(prefix+"_changes_update_import_receive_count", "Number of received updates", labels, nil) - m.withdrawsImportIgnoreCountDesc = prometheus.NewDesc(prefix+"_changes_withdraw_import_ignore_count", "Number of incoming withdraws being ignored", labels, nil) - m.withdrawsImportAcceptCountDesc = prometheus.NewDesc(prefix+"_changes_withdraw_import_accept_count", "Number of incoming withdraws being accepted", labels, nil) - m.withdrawsImportFilterCountDesc = prometheus.NewDesc(prefix+"_changes_withdraw_import_filter_count", "Number of incoming withdraws being filtered", labels, nil) - m.withdrawsImportRejectCountDesc = prometheus.NewDesc(prefix+"_changes_withdraw_import_reject_count", "Number of incoming withdraws being rejected", labels, nil) - m.withdrawsImportReceiveCountDesc = prometheus.NewDesc(prefix+"_changes_withdraw_import_receive_count", "Number of received withdraws", labels, nil) - m.updatesExportIgnoreCountDesc = prometheus.NewDesc(prefix+"_changes_update_export_ignore_count", "Number of outgoing updates being ignored", labels, nil) - m.updatesExportAcceptCountDesc = prometheus.NewDesc(prefix+"_changes_update_export_accept_count", "Number of outgoing updates being accepted", labels, nil) - m.updatesExportFilterCountDesc = prometheus.NewDesc(prefix+"_changes_update_export_filter_count", "Number of outgoing updates being filtered", labels, nil) - m.updatesExportRejectCountDesc = prometheus.NewDesc(prefix+"_changes_update_export_reject_count", "Number of outgoing updates being rejected", labels, nil) - m.updatesExportReceiveCountDesc = prometheus.NewDesc(prefix+"_changes_update_export_receive_count", "Number of sent updates", labels, nil) - m.withdrawsExportIgnoreCountDesc = prometheus.NewDesc(prefix+"_changes_withdraw_export_ignore_count", "Number of outgoing withdraws being ignored", labels, nil) - m.withdrawsExportAcceptCountDesc = prometheus.NewDesc(prefix+"_changes_withdraw_export_accept_count", "Number of outgoing withdraws being accepted", labels, nil) - m.withdrawsExportFilterCountDesc = prometheus.NewDesc(prefix+"_changes_withdraw_export_filter_count", "Number of outgoing withdraws being filtered", labels, nil) - m.withdrawsExportRejectCountDesc = prometheus.NewDesc(prefix+"_changes_withdraw_export_reject_count", "Number of outgoing withdraws being rejected", labels, nil) - m.withdrawsExportReceiveCountDesc = prometheus.NewDesc(prefix+"_changes_withdraw_export_receive_count", "Number of outgoing withdraws", labels, nil) -} - -func (m *GenericProtocolMetricExporter) Describe(ch chan<- *prometheus.Desc) { - ch <- m.upDesc - ch <- m.importCountDesc - ch <- m.exportCountDesc - ch <- m.filterCountDesc - ch <- m.preferredCountDesc - ch <- m.uptimeDesc - ch <- m.updatesImportReceiveCountDesc - ch <- m.updatesImportRejectCountDesc - ch <- m.updatesImportFilterCountDesc - ch <- m.updatesImportIgnoreCountDesc - ch <- m.updatesImportAcceptCountDesc - ch <- m.updatesExportReceiveCountDesc - ch <- m.updatesExportRejectCountDesc - ch <- m.updatesExportFilterCountDesc - ch <- m.updatesExportIgnoreCountDesc - ch <- m.updatesExportAcceptCountDesc - ch <- m.withdrawsImportIgnoreCountDesc - ch <- m.withdrawsImportAcceptCountDesc - ch <- m.withdrawsImportFilterCountDesc - ch <- m.withdrawsImportRejectCountDesc - ch <- m.withdrawsImportReceiveCountDesc - ch <- m.withdrawsExportIgnoreCountDesc - ch <- m.withdrawsExportAcceptCountDesc - ch <- m.withdrawsExportFilterCountDesc - ch <- m.withdrawsExportRejectCountDesc - ch <- m.withdrawsExportReceiveCountDesc -} + uptimeDesc := prometheus.NewDesc(m.prefix+"_uptime", "Uptime of the protocol in seconds", labels, nil) + updatesImportIgnoreCountDesc := prometheus.NewDesc(m.prefix+"_changes_update_import_ignore_count", "Number of incoming updates being ignored", labels, nil) + updatesImportAcceptCountDesc := prometheus.NewDesc(m.prefix+"_changes_update_import_accept_count", "Number of incoming updates being accepted", labels, nil) + updatesImportFilterCountDesc := prometheus.NewDesc(m.prefix+"_changes_update_import_filter_count", "Number of incoming updates being filtered", labels, nil) + updatesImportRejectCountDesc := prometheus.NewDesc(m.prefix+"_changes_update_import_reject_count", "Number of incoming updates being rejected", labels, nil) + updatesImportReceiveCountDesc := prometheus.NewDesc(m.prefix+"_changes_update_import_receive_count", "Number of received updates", labels, nil) + withdrawsImportIgnoreCountDesc := prometheus.NewDesc(m.prefix+"_changes_withdraw_import_ignore_count", "Number of incoming withdraws being ignored", labels, nil) + withdrawsImportAcceptCountDesc := prometheus.NewDesc(m.prefix+"_changes_withdraw_import_accept_count", "Number of incoming withdraws being accepted", labels, nil) + withdrawsImportFilterCountDesc := prometheus.NewDesc(m.prefix+"_changes_withdraw_import_filter_count", "Number of incoming withdraws being filtered", labels, nil) + withdrawsImportRejectCountDesc := prometheus.NewDesc(m.prefix+"_changes_withdraw_import_reject_count", "Number of incoming withdraws being rejected", labels, nil) + withdrawsImportReceiveCountDesc := prometheus.NewDesc(m.prefix+"_changes_withdraw_import_receive_count", "Number of received withdraws", labels, nil) + updatesExportIgnoreCountDesc := prometheus.NewDesc(m.prefix+"_changes_update_export_ignore_count", "Number of outgoing updates being ignored", labels, nil) + updatesExportAcceptCountDesc := prometheus.NewDesc(m.prefix+"_changes_update_export_accept_count", "Number of outgoing updates being accepted", labels, nil) + updatesExportFilterCountDesc := prometheus.NewDesc(m.prefix+"_changes_update_export_filter_count", "Number of outgoing updates being filtered", labels, nil) + updatesExportRejectCountDesc := prometheus.NewDesc(m.prefix+"_changes_update_export_reject_count", "Number of outgoing updates being rejected", labels, nil) + updatesExportReceiveCountDesc := prometheus.NewDesc(m.prefix+"_changes_update_export_receive_count", "Number of sent updates", labels, nil) + withdrawsExportIgnoreCountDesc := prometheus.NewDesc(m.prefix+"_changes_withdraw_export_ignore_count", "Number of outgoing withdraws being ignored", labels, nil) + withdrawsExportAcceptCountDesc := prometheus.NewDesc(m.prefix+"_changes_withdraw_export_accept_count", "Number of outgoing withdraws being accepted", labels, nil) + withdrawsExportFilterCountDesc := prometheus.NewDesc(m.prefix+"_changes_withdraw_export_filter_count", "Number of outgoing withdraws being filtered", labels, nil) + withdrawsExportRejectCountDesc := prometheus.NewDesc(m.prefix+"_changes_withdraw_export_reject_count", "Number of outgoing withdraws being rejected", labels, nil) + withdrawsExportReceiveCountDesc := prometheus.NewDesc(m.prefix+"_changes_withdraw_export_receive_count", "Number of outgoing withdraws", labels, nil) -func (m *GenericProtocolMetricExporter) Export(p *protocol.Protocol, ch chan<- prometheus.Metric) { l := m.labelStrategy.LabelValues(p) - ch <- prometheus.MustNewConstMetric(m.upDesc, prometheus.GaugeValue, float64(p.Up), l...) - ch <- prometheus.MustNewConstMetric(m.importCountDesc, prometheus.GaugeValue, float64(p.Imported), l...) - ch <- prometheus.MustNewConstMetric(m.exportCountDesc, prometheus.GaugeValue, float64(p.Exported), l...) - ch <- prometheus.MustNewConstMetric(m.filterCountDesc, prometheus.GaugeValue, float64(p.Filtered), l...) - ch <- prometheus.MustNewConstMetric(m.preferredCountDesc, prometheus.GaugeValue, float64(p.Preferred), l...) - ch <- prometheus.MustNewConstMetric(m.uptimeDesc, prometheus.GaugeValue, float64(p.Uptime), l...) - ch <- prometheus.MustNewConstMetric(m.updatesImportReceiveCountDesc, prometheus.GaugeValue, float64(p.ImportUpdates.Received), l...) - ch <- prometheus.MustNewConstMetric(m.updatesImportRejectCountDesc, prometheus.GaugeValue, float64(p.ImportUpdates.Rejected), l...) - ch <- prometheus.MustNewConstMetric(m.updatesImportFilterCountDesc, prometheus.GaugeValue, float64(p.ImportUpdates.Filtered), l...) - ch <- prometheus.MustNewConstMetric(m.updatesImportAcceptCountDesc, prometheus.GaugeValue, float64(p.ImportUpdates.Accepted), l...) - ch <- prometheus.MustNewConstMetric(m.updatesImportIgnoreCountDesc, prometheus.GaugeValue, float64(p.ImportUpdates.Ignored), l...) - ch <- prometheus.MustNewConstMetric(m.updatesExportReceiveCountDesc, prometheus.GaugeValue, float64(p.ExportUpdates.Received), l...) - ch <- prometheus.MustNewConstMetric(m.updatesExportRejectCountDesc, prometheus.GaugeValue, float64(p.ExportUpdates.Rejected), l...) - ch <- prometheus.MustNewConstMetric(m.updatesExportFilterCountDesc, prometheus.GaugeValue, float64(p.ExportUpdates.Filtered), l...) - ch <- prometheus.MustNewConstMetric(m.updatesExportAcceptCountDesc, prometheus.GaugeValue, float64(p.ExportUpdates.Accepted), l...) - ch <- prometheus.MustNewConstMetric(m.updatesExportIgnoreCountDesc, prometheus.GaugeValue, float64(p.ExportUpdates.Ignored), l...) - ch <- prometheus.MustNewConstMetric(m.withdrawsImportReceiveCountDesc, prometheus.GaugeValue, float64(p.ImportWithdraws.Received), l...) - ch <- prometheus.MustNewConstMetric(m.withdrawsImportRejectCountDesc, prometheus.GaugeValue, float64(p.ImportWithdraws.Rejected), l...) - ch <- prometheus.MustNewConstMetric(m.withdrawsImportFilterCountDesc, prometheus.GaugeValue, float64(p.ImportWithdraws.Filtered), l...) - ch <- prometheus.MustNewConstMetric(m.withdrawsImportAcceptCountDesc, prometheus.GaugeValue, float64(p.ImportWithdraws.Accepted), l...) - ch <- prometheus.MustNewConstMetric(m.withdrawsImportIgnoreCountDesc, prometheus.GaugeValue, float64(p.ImportWithdraws.Ignored), l...) - ch <- prometheus.MustNewConstMetric(m.withdrawsExportReceiveCountDesc, prometheus.GaugeValue, float64(p.ExportWithdraws.Received), l...) - ch <- prometheus.MustNewConstMetric(m.withdrawsExportRejectCountDesc, prometheus.GaugeValue, float64(p.ExportWithdraws.Rejected), l...) - ch <- prometheus.MustNewConstMetric(m.withdrawsExportFilterCountDesc, prometheus.GaugeValue, float64(p.ExportWithdraws.Filtered), l...) - ch <- prometheus.MustNewConstMetric(m.withdrawsExportAcceptCountDesc, prometheus.GaugeValue, float64(p.ExportWithdraws.Accepted), l...) - ch <- prometheus.MustNewConstMetric(m.withdrawsExportIgnoreCountDesc, prometheus.GaugeValue, float64(p.ExportWithdraws.Ignored), l...) + ch <- prometheus.MustNewConstMetric(upDesc, prometheus.GaugeValue, float64(p.Up), l...) + ch <- prometheus.MustNewConstMetric(importCountDesc, prometheus.GaugeValue, float64(p.Imported), l...) + ch <- prometheus.MustNewConstMetric(exportCountDesc, prometheus.GaugeValue, float64(p.Exported), l...) + ch <- prometheus.MustNewConstMetric(filterCountDesc, prometheus.GaugeValue, float64(p.Filtered), l...) + ch <- prometheus.MustNewConstMetric(preferredCountDesc, prometheus.GaugeValue, float64(p.Preferred), l...) + ch <- prometheus.MustNewConstMetric(uptimeDesc, prometheus.GaugeValue, float64(p.Uptime), l...) + ch <- prometheus.MustNewConstMetric(updatesImportReceiveCountDesc, prometheus.GaugeValue, float64(p.ImportUpdates.Received), l...) + ch <- prometheus.MustNewConstMetric(updatesImportRejectCountDesc, prometheus.GaugeValue, float64(p.ImportUpdates.Rejected), l...) + ch <- prometheus.MustNewConstMetric(updatesImportFilterCountDesc, prometheus.GaugeValue, float64(p.ImportUpdates.Filtered), l...) + ch <- prometheus.MustNewConstMetric(updatesImportAcceptCountDesc, prometheus.GaugeValue, float64(p.ImportUpdates.Accepted), l...) + ch <- prometheus.MustNewConstMetric(updatesImportIgnoreCountDesc, prometheus.GaugeValue, float64(p.ImportUpdates.Ignored), l...) + ch <- prometheus.MustNewConstMetric(updatesExportReceiveCountDesc, prometheus.GaugeValue, float64(p.ExportUpdates.Received), l...) + ch <- prometheus.MustNewConstMetric(updatesExportRejectCountDesc, prometheus.GaugeValue, float64(p.ExportUpdates.Rejected), l...) + ch <- prometheus.MustNewConstMetric(updatesExportFilterCountDesc, prometheus.GaugeValue, float64(p.ExportUpdates.Filtered), l...) + ch <- prometheus.MustNewConstMetric(updatesExportAcceptCountDesc, prometheus.GaugeValue, float64(p.ExportUpdates.Accepted), l...) + ch <- prometheus.MustNewConstMetric(updatesExportIgnoreCountDesc, prometheus.GaugeValue, float64(p.ExportUpdates.Ignored), l...) + ch <- prometheus.MustNewConstMetric(withdrawsImportReceiveCountDesc, prometheus.GaugeValue, float64(p.ImportWithdraws.Received), l...) + ch <- prometheus.MustNewConstMetric(withdrawsImportRejectCountDesc, prometheus.GaugeValue, float64(p.ImportWithdraws.Rejected), l...) + ch <- prometheus.MustNewConstMetric(withdrawsImportFilterCountDesc, prometheus.GaugeValue, float64(p.ImportWithdraws.Filtered), l...) + ch <- prometheus.MustNewConstMetric(withdrawsImportAcceptCountDesc, prometheus.GaugeValue, float64(p.ImportWithdraws.Accepted), l...) + ch <- prometheus.MustNewConstMetric(withdrawsImportIgnoreCountDesc, prometheus.GaugeValue, float64(p.ImportWithdraws.Ignored), l...) + ch <- prometheus.MustNewConstMetric(withdrawsExportReceiveCountDesc, prometheus.GaugeValue, float64(p.ExportWithdraws.Received), l...) + ch <- prometheus.MustNewConstMetric(withdrawsExportRejectCountDesc, prometheus.GaugeValue, float64(p.ExportWithdraws.Rejected), l...) + ch <- prometheus.MustNewConstMetric(withdrawsExportFilterCountDesc, prometheus.GaugeValue, float64(p.ExportWithdraws.Filtered), l...) + ch <- prometheus.MustNewConstMetric(withdrawsExportAcceptCountDesc, prometheus.GaugeValue, float64(p.ExportWithdraws.Accepted), l...) + ch <- prometheus.MustNewConstMetric(withdrawsExportIgnoreCountDesc, prometheus.GaugeValue, float64(p.ExportWithdraws.Ignored), l...) } diff -Nru prometheus-bird-exporter-1.2.4+ds/metrics/label_strategy.go prometheus-bird-exporter-1.2.5+ds/metrics/label_strategy.go --- prometheus-bird-exporter-1.2.4+ds/metrics/label_strategy.go 2019-11-01 12:18:42.000000000 +0000 +++ prometheus-bird-exporter-1.2.5+ds/metrics/label_strategy.go 2020-02-19 16:14:30.000000000 +0000 @@ -5,8 +5,8 @@ // LabelStrategy abstracts the label generation for protocol metrics type LabelStrategy interface { // LabelNames is the list of label names - LabelNames() []string - - // Label values is the list of values for the labels specified in `LabelNames()` + LabelNames(p *protocol.Protocol) []string + + // Label values is the list of values for the labels specified in `LabelNames()` LabelValues(p *protocol.Protocol) []string } diff -Nru prometheus-bird-exporter-1.2.4+ds/metrics/legacy_exporter.go prometheus-bird-exporter-1.2.5+ds/metrics/legacy_exporter.go --- prometheus-bird-exporter-1.2.4+ds/metrics/legacy_exporter.go 2019-11-01 12:18:42.000000000 +0000 +++ prometheus-bird-exporter-1.2.5+ds/metrics/legacy_exporter.go 2020-02-19 16:14:30.000000000 +0000 @@ -22,10 +22,10 @@ e.ipv6Exporter.Describe(ch) } -func (e *LegacyMetricExporter) Export(p *protocol.Protocol, ch chan<- prometheus.Metric) { +func (e *LegacyMetricExporter) Export(p *protocol.Protocol, ch chan<- prometheus.Metric, newFormat bool) { if p.IPVersion == "4" { - e.ipv4Exporter.Export(p, ch) + e.ipv4Exporter.Export(p, ch, false) } else { - e.ipv6Exporter.Export(p, ch) + e.ipv6Exporter.Export(p, ch, false) } } diff -Nru prometheus-bird-exporter-1.2.4+ds/metrics/legacy_label_strategy.go prometheus-bird-exporter-1.2.5+ds/metrics/legacy_label_strategy.go --- prometheus-bird-exporter-1.2.4+ds/metrics/legacy_label_strategy.go 2019-11-01 12:18:42.000000000 +0000 +++ prometheus-bird-exporter-1.2.5+ds/metrics/legacy_label_strategy.go 2020-02-19 16:14:30.000000000 +0000 @@ -5,7 +5,11 @@ type LegacyLabelStrategy struct { } -func (*LegacyLabelStrategy) LabelNames() []string { +func NewLegacyLabelStrategy() *LegacyLabelStrategy { + return &LegacyLabelStrategy{} +} + +func (*LegacyLabelStrategy) LabelNames(p *protocol.Protocol) []string { return []string{"name"} } diff -Nru prometheus-bird-exporter-1.2.4+ds/metrics/metrics_exporter.go prometheus-bird-exporter-1.2.5+ds/metrics/metrics_exporter.go --- prometheus-bird-exporter-1.2.4+ds/metrics/metrics_exporter.go 2019-11-01 12:18:42.000000000 +0000 +++ prometheus-bird-exporter-1.2.5+ds/metrics/metrics_exporter.go 2020-02-19 16:14:30.000000000 +0000 @@ -7,5 +7,5 @@ type MetricExporter interface { Describe(ch chan<- *prometheus.Desc) - Export(p *protocol.Protocol, ch chan<- prometheus.Metric) + Export(p *protocol.Protocol, ch chan<- prometheus.Metric, newFormat bool) } diff -Nru prometheus-bird-exporter-1.2.4+ds/metrics/ospf_exporter.go prometheus-bird-exporter-1.2.5+ds/metrics/ospf_exporter.go --- prometheus-bird-exporter-1.2.4+ds/metrics/ospf_exporter.go 2019-11-01 12:18:42.000000000 +0000 +++ prometheus-bird-exporter-1.2.5+ds/metrics/ospf_exporter.go 2020-02-19 16:14:30.000000000 +0000 @@ -55,7 +55,7 @@ ch <- d.neighborAdjacentCountDesc } -func (m *ospfMetricExporter) Export(p *protocol.Protocol, ch chan<- prometheus.Metric) { +func (m *ospfMetricExporter) Export(p *protocol.Protocol, ch chan<- prometheus.Metric, newFormat bool) { d := m.descriptions[p.IPVersion] ch <- prometheus.MustNewConstMetric(d.runningDesc, prometheus.GaugeValue, p.Attributes["running"], p.Name) diff -Nru prometheus-bird-exporter-1.2.4+ds/parser/parser.go prometheus-bird-exporter-1.2.5+ds/parser/parser.go --- prometheus-bird-exporter-1.2.4+ds/parser/parser.go 2019-11-01 12:18:42.000000000 +0000 +++ prometheus-bird-exporter-1.2.5+ds/parser/parser.go 2020-02-19 16:14:30.000000000 +0000 @@ -15,6 +15,7 @@ var ( protocolRegex *regexp.Regexp + descriptionRegex *regexp.Regexp routeRegex *regexp.Regexp uptimeRegex *regexp.Regexp routeChangeRegex *regexp.Regexp @@ -32,6 +33,7 @@ func init() { protocolRegex = regexp.MustCompile(`^(?:1002\-)?([^\s]+)\s+(BGP|OSPF|Direct|Device|Kernel|Static)\s+([^\s]+)\s+([^\s]+)\s+(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}|[^\s]+)(?:\s+(.*?))?$`) + descriptionRegex = regexp.MustCompile(`Description:\s+(.*)`) routeRegex = regexp.MustCompile(`^\s+Routes:\s+(\d+) imported, (?:(\d+) filtered, )?(\d+) exported(?:, (\d+) preferred)?`) uptimeRegex = regexp.MustCompile(`^(?:((\d+):(\d{2}):(\d{2}))|(\d+)|(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}))$`) routeChangeRegex = regexp.MustCompile(`(Import|Export) (updates|withdraws):\s+(\d+|---)\s+(\d+|---)\s+(\d+|---)\s+(\d+|---)\s+(\d+|---)\s*`) @@ -49,6 +51,7 @@ var handlers = []func(*context){ handleEmptyLine, parseLineForProtocol, + parseLineForDescription, parseLineForChannel, parseLineForRoutes, parseLineForRouteChanges, @@ -97,6 +100,20 @@ c.handled = true } +func parseLineForDescription(c *context) { + match := descriptionRegex.FindStringSubmatch(c.line) + + if match == nil { + return + } + + if len(match) <= 1 { + return + } + + c.current.Description = strings.Join(match[1:], " ") +} + func parseProto(val string) int { switch val { case "BGP": diff -Nru prometheus-bird-exporter-1.2.4+ds/protocol/protocol.go prometheus-bird-exporter-1.2.5+ds/protocol/protocol.go --- prometheus-bird-exporter-1.2.4+ds/protocol/protocol.go 2019-11-01 12:18:42.000000000 +0000 +++ prometheus-bird-exporter-1.2.5+ds/protocol/protocol.go 2020-02-19 16:14:30.000000000 +0000 @@ -11,6 +11,7 @@ type Protocol struct { Name string + Description string IPVersion string ImportFilter string ExportFilter string