-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add BGP connection / session metrics (up, prefix_count, updates, withdraws) #94
Comments
I'm quite sure that with ROS 7.x not all of those metrics can be extracted. Here is what I get with the REST API call for a session. The prefix count also seems to be underrun somehow for an added run. {
".id": "*280002A",
"ebgp": "",
"established": "true",
"hold-time": "3m",
"input.filter": "s2s_import_v4",
"input.last-notification": "ffffffffffffffffffffffffffffffff0015030600",
"input.procid": "32",
"keepalive-time": "1m",
"last-started": "2023-11-01 00:18:14",
"last-stopped": "2023-11-01 00:18:08",
"local.address": "100.100.1.0",
"local.as": "27152",
"local.bytes": "1803479",
"local.capabilities": "mp,rr,gr,as4",
"local.eor": "",
"local.id": "44.128.3.255",
"local.messages": "13623",
"multihop": "true",
"name": "atvie1_vsh01_v4_in_v6-1",
"output.filter-chain": "s2s_export_med121",
"output.keep-sent-attributes": "true",
"output.procid": "32",
"prefix-count": "4294967221",
"remote.address": "100.100.0.35",
"remote.afi": "ip,ipv6",
"remote.as": "27187",
"remote.bytes": "2277993",
"remote.capabilities": "mp,rr,gr,as4,err,llgr",
"remote.eor": "ip",
"remote.gr-time": "120",
"remote.hold-time": "4m",
"remote.id": "44.128.143.255",
"remote.messages": "16967",
"uptime": "1w9h52m40s110ms",
"use-bfd": "true"
} |
@endreszabo thanks for looking into this. Could you maybe disclose which API calls you made here and how? Edit: I suppose you use the Python Example client at https://help.mikrotik.com/docs/display/ROS/API#API-Exampleclient ? |
Hello, I'm currently also in the process of moving away from nshttpd/mikrotik-exporter but information about our BGP sessions is important to us. I'm not versed in Python enough to contribute to code but if someone wants to tackle this and needs an output example happy to run whatever command is needed for them. |
Adding BGP collector/metrics is not a big deal by itself, the main problem is that I'm myself not doing much with BGP right now and so it'd be a bit awkward for me to test the functionality. Any ideas on a how to get over this? An accessible BGP endpoint in a test environment would be ideal, if someone would be willing to set it up for me |
Using dn42 as a BGP test bed can be an good way to play around with BGP configurations. However, setting up dn42 involves considerable manual labor and coordination. Alternatively, a simpler method could just be peering two MikroTik devices (or CHR containers) together and announcing bogon addresses from one to the other. Start by creating one host and making an address-list that will be used as the output network: /ip firewall address-list
add address=0.0.0.0/8 list=bogon
add address=10.0.0.0/8 list=bogon
add address=100.64.0.0/10 list=bogon
add address=127.0.0.0/8 list=bogon
add address=169.254.0.0/16 list=bogon
add address=172.16.0.0/12 list=bogon
add address=192.0.0.0/24 list=bogon
add address=192.0.2.0/24 list=bogon
add address=192.168.0.0/16 list=bogon
add address=198.18.0.0/15 list=bogon
add address=198.51.100.0/24 list=bogon
add address=203.0.113.0/24 list=bogon
add address=224.0.0.0/3 list=bogon On the same host, add routes to the routing table as blackholes since RouterOS requires routes to be present in the routing table before distribution: :foreach item in=[/ip/firewall/address-list/find list=bogon] do={
/ip/route/add dst-address=[/ip firewall address-list get $item address] blackhole
} Create this side of the peer on the same host as the first two steps: /routing/bgp/connection/add output.network=bogon name=bogon as=65532 local.role=ebgp local.address=CURRENT_DEVICES_IP remote.as=65533 remote.address=OTHER_ROUTER_IP On the second host, create the other side of the peer /routing/bgp/connection/add name=bogon as=65533 local.role=ebgp local.address=CURRENT_DEVICES_IP remote.as=65532 remote.address=OTHER_ROUTER_IP Now, on the second host, you should see your session come online and prefixes get loaded into your RIB. Check using |
@akpw I can't offer you public access to a router, but I could offer to test this on multiple CCRs running RouterOS 7 with BGP peerings (IPv4 and IPv6). @timcole seems to have offered the same. But I like the simply test setup he described even more. |
@frittentheke OK so I put two CHRs on QEMU/KVM and set them up according to @timcole suggestions.
Would this kind of info be useful to what you guys need? Feel free to suggest what other related info would be of interest. |
That's awesome @akpw, thanks a lot for caring and then implementing this!
Yes, definitely! Let me pick and choose a little ..... Something to identify an individual session:
If only one label was extracted, Please also add the address family (IPv4 or IPv6):
Also having 'ebgp' or 'ibgp' reported is nice, but that could be extracted from the fact that the local and remote AS are the same. The most valuable numeric metrics seem to be: As counters:
As gauges:
(If there is any chance, please kindly normalize the |
If you're able to use the router-id aka But |
@frittentheke @timcole OK, so this is the resulting mktxp output so far:
Let me know if anything needs further tuning, I will also add this to the repo for you guys to play with in a more realistic setup. |
done. Before testing, just activate in your
|
Hey @akpw, Prometheus is throwing an error |
@timcole interesting, I did expect problems with the '.' in label names but somehow it seemed to work fine for me. |
should be fixed in the latest |
@frittentheke anything else to do here, or shall we close? |
First of all let me thank you again for implementing this @akpw! But I am wondering though, what your idea behind |
well, mainly your specification of "Something to identify an individual session:" :) |
As unique identified the But in any case @akpw , the state of things is totally fine, but since you asked I just felt the urge to comment ;-) |
the info metric gathers essential session labels not imposing high cardinality, can be extended if needed with additional labels of the same kind. The reason for including extra labels in the other metrics, as mentioned above, is due to your initial specification of what reliably constitutes a unique session ID. If the combination of session name and instance is sufficient for this, I can remove the extra ones in the next update |
Let's hear what @timcole says. I mean it's convenient not having to join in some info metric, but is it also best-practice and future proof? |
Personally, I'm fine with it either way as long as I have the ability to group by remote AS. In Grafana, I have a variable that uses |
Whatever you decide @akpw I am fine either way. May I gently nag you again about doing a release (to pypi)? |
Personally I'd leave the info metric as is and remove the extra labels from all other metrics. @timcole would that be OK, or would you rather prefer to have AS in all of them? This should be mostly about complexity of the grouping queries, not sure about potential impact on their performance etc. |
@frittentheke I planned to do a few more small things and then release at the end of this week, if this is good enough for you |
It should still be possible to do what I'm after joining info instead, so whatever you decide works for me 👍🏻 |
Hello! How are you doing? I know that I already know this, but I wanted to know if it is possible that you could share the code of your dashboard that you show in your publication! If so, I would appreciate it very much. |
@timcole would you mind sharing your grafana dashboard with the mktxp BGP metrics? Yours looks very nice. |
There are two issues with giving it to you. First, I never got around to updating that dashboard after the March 10 update, so it won’t work with the newest version. Second, we only have one site that uses a MikroTik device (we use Arista elsewhere, which is also why we haven't bothered to update the dashboard yet). It’s very specific to the peers’ naming convention, where v6 peers end with "-v6." But here’s the export: https://gist.github.com/timcole/6e90b45d17973714f5d1c1e6c5dab747. Feel free to do whatever you want with it, but no support will be provided—it's as-is. |
Thanks for this awesome exporter!
I just switched over from https://github.com/nshttpd/mikrotik-exporter/ as that once was not really compatible with RouterOS 7.x anymore. I am really happy with mktxp so far, but noticed that mktxp does not yet provide BGP session metrics like the mikrotik-exporter did. See https://github.com/nshttpd/mikrotik-exporter/blob/e1b06c6ebe6e71a5661326b3a33afe2fd741283d/collector/bgp_collector.go#L24
Here are some example of the metrics I had before:
The BGP configuration on Mikrotik devices as changed quite a lot with RouterOS 7.x, thus the old exporter also did not provide them anymore. Would be awesome to have those metrics available again.
The text was updated successfully, but these errors were encountered: