1# Collecting BGP metrics with pmacct
2
3Pmacct can export BGP updates and withdrawals received from a BGP or BMP (BGP Monitoring Protocol) peer (bmp_daemon_msglog, bgp_daemon_msglog) or dump the collected BGP RIB in regular intervals (bmp_table_dump,bgp_table_dump) from a BGP router.
4
5This documents describes, dependent if they are collected through BGP or BMP, which metrics are collected with sample configurations for Apache Kafka export.
6
7---
8## BGP collected local RIB metrics
9
10### pmacct example configuration
11~~~~
12bgp_daemon: true
13bgp_daemon_ip: 192.0.2.1
14bgp_daemon_port: 179
15bgp_daemon_max_peers: 255
16!
17bgp_daemon_msglog_kafka_broker_host: kafka.example.com
18bgp_daemon_msglog_kafka_broker_port: 9093
19bgp_daemon_msglog_kafka_topic: topic.name.example.com
20bgp_daemon_msglog_kafka_config_file: /etc/pmacct/librdkafka.conf
21!
22bgp_table_dump_kafka_broker_host: kafka.example.com
23bgp_table_dump_kafka_broker_port: 9093
24bgp_table_dump_kafka_topic: topic.name.example.com
25bgp_table_dump_kafka_config_file: /etc/pmacct/librdkafka.conf
26bgp_table_dump_refresh_time: 60
27~~~~
28
29### BGP metric description
30
31Title | Description
32:----- | :-----------
33`seq` | pmacct sequence number. Uniquely identifies each metric.
34`log_type` | pmacct log type. Either "update" or "delete" depending if BGP advertisement is an update or withdrawal
35`timestamp` | pmacct time stamp of data collection
36`peer_ip_src` | IP address of BGP router which peers to pmacct
37`peer_tcp_port` | TCP port of BGP router which peers to pmacct
38`event_type` | pmacct event type. Can be either "log" for msglog or "dump" for table_dump.
39`afi` | BGP Address Family Indicator (RFC 4760 -  Multiprotocol Extensions for BGP-4)
40`safi` | BGP Subsequent Address Family Identifier (RFC 4760 -  Multiprotocol Extensions for BGP-4)
41`ip_prefix` | BGP Prefix
42`bgp_nexthop` | BGP next hop
43`as_path` | BGP AS path
44`comms` | BGP standard community string
45`ecomms` | BGP extended community string
46`origin` | BGP origin attribute
47`local_pref` | BGP local preference
48`rd` | BGP route-distinguisher
49`label` | BGP MPLS VPN label
50`writer_id` | pmacct process name and id
51
52### Example BGP metrics
53In case of table dump. Each batch of metric will start with "log_init" and end with "log_close" event_type meta data. This meta data includes the time of the data collection, the peering IP address and TCP port and which pmacct process name and id exported the metrics.
54~~~~
55{
56  "seq": 1164,
57  "timestamp": "1558677934.255773",
58  "peer_ip_src": "192.0.2.2",
59  "peer_tcp_port": 25344,
60  "event_type": "log_init",
61  "writer_id": "pmacct-bgp01c/4857"
62}
63{
64  "seq": 1165,
65  "log_type": "update",
66  "timestamp": "1558677958.092808",
67  "peer_ip_src": "192.0.2.2",
68  "peer_tcp_port": 25344,
69  "event_type": "log",
70  "afi": 2,
71  "safi": 128,
72  "ip_prefix": "2001:db8::/32",
73  "bgp_nexthop": "203.0.113.1",
74  "as_path": "64496 64497",
75  "comms": "64496:1 64497:2 64498:3",
76  "ecomms": "RT:64496:100",
77  "origin": "i",
78  "local_pref": 0,
79  "rd": "0:64499:1",
80  "label": "25",
81  "writer_id": "pmacct-bgp01c/4857"
82}
83{
84  "seq": 1166,
85  "timestamp": "1558677933.627806",
86  "peer_ip_src": "192.0.2.2",
87  "peer_tcp_port": 31402,
88  "event_type": "log_close",
89  "writer_id": "pmacct-bgp01c/4857"
90}
91~~~~
92
93---
94## BMP collected adjacent RIB in metrics
95
96### pmacct example configuration
97~~~~
98bmp_daemon_ip: 192.0.2.1
99bmp_daemon_port: 1790
100bmp_daemon_max_peers: 255
101bmp_daemon_msglog_kafka_broker_host: kafka.example.com
102bmp_daemon_msglog_kafka_broker_port: 9093
103bmp_daemon_msglog_kafka_topic: topic.name.example.com
104bmp_daemon_msglog_kafka_config_file: /etc/pmacct/librdkafka.conf
105~~~~
106
107### BMP message type 0, route monitoring metrics
108Title | Description
109:----- | :-----------
110`seq` | pmacct sequence number. Uniquely identifies each metric.
111`log_type` | pmacct log type. Either "update" or "delete" depending if BGP advertisement is an update or withdrawal
112`timestamp` | pmacct time stamp of data collection
113`bmp_router` | IP address of BMP router which peers to pmacct
114`bmp_router_port` | TCP port of BMP router which peers to pmacct
115`event_type` | pmacct event type. Can be either "log" for msglog or "dump" for table_dump.
116`bmp_msg_type` | "route_monitoring" for BMP message type 0
117`peer_ip` | BGP peer IP address where BGP metrics are received from
118`afi` | BGP Address Family Indicator (RFC 4760 -  Multiprotocol Extensions for BGP-4)
119`safi` | BGP Subsequent Address Family Identifier (RFC 4760 -  Multiprotocol Extensions for BGP-4)
120`ip_prefix` | BGP Prefix
121`bgp_nexthop` | BGP next hop
122`as_path` | BGP AS path
123`comms` | BGP standard community string
124`ecomms` | BGP extended community string
125`origin` | BGP origin attribute
126`local_pref` | BGP local preference
127`rd` | BGP route-distinguisher
128`label` | BGP MPLS VPN label
129
130~~~~
131{
132  "seq": 5835,
133  "log_type": "update",
134  "timestamp": "2019-05-24 09:33:31.136734",
135  "peer_ip": "192.0.2.2",
136  "bmp_router_port": 45047,
137  "event_type": "log",
138  "afi": 1,
139  "safi": 128,
140  "ip_prefix": "198.51.100.0/24",
141  "bgp_nexthop": "203.0.113.1",
142  "as_path": "64496 64497 64498",
143  "comms": "64496:1 64497:2 64498:3",
144  "ecomms": "RT:64497:192",
145  "origin": "i",
146  "local_pref": 0,
147  "rd": "0:64499:2",
148  "label": "19356",
149  "bmp_router": "192.0.2.2",
150  "bmp_msg_type": "route_monitor"
151}
152~~~~
153
154### BMP message type 1, statistics report
155Title | Description
156:----- | :-----------
157`seq` | pmacct sequence number. Uniquely identifies each metric.
158`timestamp` | pmacct time stamp of data collection
159`bmp_router` | IP address of BMP router which peers to pmacct
160`bmp_router_port` | TCP port of BMP router which peers to pmacct
161`event_type` | pmacct event type. Can be either "log" for msglog or "dump" for table_dump.
162`bmp_msg_type` | "stats" for BMP message type 1
163`peer_ip` | BGP peer IP address where BGP metrics are received from
164`peer_asn` | BGP peer BGP AS number
165`peer_type` | Type of BGP peer (https://www.iana.org/assignments/bmp-parameters/bmp-parameters.xhtml#peer-types)
166`counter_type` | Statistics type field code (https://www.iana.org/assignments/bmp-parameters/bmp-parameters.xhtml#statistics-types)
167`counter_type_str` | Statistics description
168`counter_value` | Statistics counter value
169
170~~~~
171{
172  "event_type": "log",
173  "seq": 18271,
174  "timestamp": "2019-05-24 09:41:34.543389",
175  "bmp_router": "192.0.2.2",
176  "bmp_router_port": 45047,
177  "bmp_msg_type": "stats",
178  "peer_ip": "203.0.113.1",
179  "peer_asn": 60633,
180  "peer_type": 0,
181  "counter_type": 0,
182  "counter_type_str": "Number of prefixes rejected by inbound policy",
183  "counter_value": 0
184}
185~~~~
186
187### BMP message type 2, peer down
188Title | Description
189:----- | :-----------
190`seq` | pmacct sequence number. Uniquely identifies each metric.
191`timestamp` | pmacct time stamp of data collection
192`bmp_router` | IP address of BMP router which peers to pmacct
193`bmp_router_port` | TCP port of BMP router which peers to pmacct
194`event_type` | pmacct event type. Can be either "log" for msglog or "dump" for table_dump.
195`bmp_msg_type` | "peer_down" for BMP message type 2
196`peer_ip` | BGP peer IP address where BGP metrics are received from
197`peer_asn` | BGP peer BGP AS number
198`peer_type` | Type of BGP peer (https://www.iana.org/assignments/bmp-parameters/bmp-parameters.xhtml#peer-types)
199`peer_type_str` | type of BGP peer description
200`reason_type` | Reason type why BGP went down  (https://www.iana.org/assignments/bmp-parameters/bmp-parameters.xhtml#peer-down-reason-codes)
201`reason_str` | Reason description why BGP went down
202
203~~~~
204{
205  "event_type": "log",
206  "seq": 18696,
207  "timestamp": "2019-05-24 09:49:22.437488",
208  "bmp_router": "192.0.2.2",
209  "bmp_router_port": 45047,
210  "bmp_msg_type": "peer_down",
211  "peer_ip": "203.0.113.3",
212  "peer_asn": 64496,
213  "peer_type": 0,
214  "peer_type_str": "Global Instance Peer",
215  "reason_type": 1,
216  "reason_str": "The local system closed the session"
217}
218~~~~
219
220### BMP message type 3, peer up
221Title | Description
222:----- | :-----------
223`seq` | pmacct sequence number. Uniquely identifies each metric.
224`timestamp` | pmacct time stamp of data collection
225`bmp_router` | IP address of BMP router which peers to pmacct
226`bmp_router_port` | TCP port of BMP router which peers to pmacct
227`event_type` | pmacct event type. Can be either "log" for msglog or "dump" for table_dump.
228`bmp_msg_type` | "peer_up" for BMP message type 3
229`peer_ip` | BGP peer IP address where BGP metrics are received from
230`peer_asn` | BGP peer BGP AS number
231`peer_type` | Type of BGP peer (https://www.iana.org/assignments/bmp-parameters/bmp-parameters.xhtml#peer-types)
232`peer_type_str` | type of BGP peer description
233`bgp_id` | BGP router ID of remote peer from BGP open message
234`local_port` | BGP peer local TCP port
235`remote_port` | BGP peer remote TCP port
236`local_ip` | BGP peer local IP address
237
238~~~~
239{
240  "event_type": "log",
241  "seq": 10,
242  "timestamp": "2019-05-24 09:31:03.160056",
243  "bmp_router": "192.0.2.2",
244  "bmp_router_port": 45047,
245  "bmp_msg_type": "peer_up",
246  "peer_ip": "203.0.113.2",
247  "peer_asn": 64496,
248  "peer_type": 0,
249  "peer_type_str": "Global Instance Peer",
250  "bgp_id": "192.0.2.2",
251  "local_port": 26354,
252  "remote_port": 179,
253  "local_ip": "203.0.113.1"
254}
255~~~~
256
257### BMP message type 4, initiation
258Title | Description
259:----- | :-----------
260`seq` | pmacct sequence number. Uniquely identifies each metric.
261`timestamp` | pmacct time stamp of data collection
262`bmp_router` | IP address of BMP router which peers to pmacct
263`bmp_router_port` | TCP port of BMP router which peers to pmacct
264`event_type` | pmacct event type. Can be either "log" for msglog or "dump" for table_dump.
265`bmp_msg_type` | "init" for BMP message type 4
266`bmp_init_info_sysdescr` | BGP software version of router peering to pmacct
267`bmp_init_info_sysname` | BGP hostname of router peering to pmacct
268`writer_id` | pmacct process name and id
269
270~~~~
271{
272  "event_type": "log",
273  "seq": 9,
274  "timestamp": "2019-06-01 18:29:58.515420",
275  "bmp_router": "192.0.2.2",
276  "bmp_router_port": 17677,
277  "bmp_msg_type": "init",
278  "bmp_init_info_sysdescr": "6.5.2",
279  "bmp_init_info_sysname": "bgprouter.example.com",
280  "writer_id": "daisy62bmp01c/9254"
281}
282~~~~