fixed naming inconsistency

This commit is contained in:
Daniel Czerwonk 2017-12-01 08:34:57 +01:00
parent ef017bf424
commit b9e7bbd5fe
4 changed files with 21 additions and 12 deletions

View File

@ -30,8 +30,8 @@ ospfv3_running{name="ospf1"} 1
### new format
```
bird_protocol_prefix_count_import{name="bgp1",proto="BGP",ip_version="4"} 600000
bird_protocol_prefix_count_import{name="bgp1",proto="BGP",ip_version="6"} 50000
bird_protocol_prefix_import_count{name="bgp1",proto="BGP",ip_version="4"} 600000
bird_protocol_prefix_import_count{name="bgp1",proto="BGP",ip_version="6"} 50000
bird_ospfv3_running{name="ospf1"} 1
```

View File

@ -40,7 +40,7 @@ func exportersForLegacy() map[int][]metrics.MetricExporter {
func exportersForDefault() map[int][]metrics.MetricExporter {
l := &metrics.DefaultLabelStrategy{}
e := metrics.NewGenericProtocolMetricExporter("bird_protocol", l)
e := metrics.NewGenericProtocolMetricExporter("bird_protocol", true, l)
return map[int][]metrics.MetricExporter{
protocol.BGP: []metrics.MetricExporter{e},

View File

@ -12,8 +12,8 @@ type ProtocolMetricExporter struct {
func NewMetricExporter(prefixIpv4, prefixIpv6 string, labelStrategy LabelStrategy) *ProtocolMetricExporter {
return &ProtocolMetricExporter{
ipv4Exporter: NewGenericProtocolMetricExporter(prefixIpv4, labelStrategy),
ipv6Exporter: NewGenericProtocolMetricExporter(prefixIpv6, labelStrategy),
ipv4Exporter: NewGenericProtocolMetricExporter(prefixIpv4, false, labelStrategy),
ipv6Exporter: NewGenericProtocolMetricExporter(prefixIpv6, false, labelStrategy),
}
}

View File

@ -35,20 +35,29 @@ type GenericProtocolMetricExporter struct {
withdrawsExportAcceptCountDesc *prometheus.Desc
}
func NewGenericProtocolMetricExporter(prefix string, labelStrategy LabelStrategy) *GenericProtocolMetricExporter {
func NewGenericProtocolMetricExporter(prefix string, newNaming bool, labelStrategy LabelStrategy) *GenericProtocolMetricExporter {
m := &GenericProtocolMetricExporter{labelStrategy: labelStrategy}
m.initDesc(prefix)
m.initDesc(prefix, newNaming)
return m
}
func (m *GenericProtocolMetricExporter) initDesc(prefix string) {
func (m *GenericProtocolMetricExporter) initDesc(prefix string, newNaming bool) {
labels := m.labelStrategy.labelNames()
m.upDesc = prometheus.NewDesc(prefix+"_up", "Protocol is up", labels, nil)
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)
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)
} 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)
}
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 beeing ignored", labels, nil)
m.updatesImportAcceptCountDesc = prometheus.NewDesc(prefix+"_changes_update_import_accept_count", "Number of incoming updates beeing accepted", labels, nil)