Skip to content
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 metrics for TX/RX broadcast, multicast, unicasts, CRC error packets #157

Merged
merged 2 commits into from
Dec 11, 2021

Conversation

kakkotetsu
Copy link
Contributor

This PR adds prometheus metrics for TX/RX broadcast, multicast, unicasts, CRC error packets entries.

The following metrics are now exposed.

# HELP junos_interface_receive_broadcasts Received broadcast packets
# TYPE junos_interface_receive_broadcasts gauge
junos_interface_receive_broadcasts{description="",mac="00:26:88:78:6b:03",name="ge-0/0/46",target="ex3200-1"} 5.06705251e+08

# HELP junos_interface_receive_errors_crc Number of CRC error incoming packets
# TYPE junos_interface_receive_errors_crc gauge
junos_interface_receive_errors_crc{description="",mac="00:26:88:78:6b:30",name="ge-0/0/45",target="ex3200-1"} 1

# HELP junos_interface_receive_multicasts Received multicast packets
# TYPE junos_interface_receive_multicasts gauge
junos_interface_receive_multicasts{description="",mac="00:26:88:78:6b:03",name="ge-0/0/46",target="ex3200-1"} 1.054740167e+09

# HELP junos_interface_receive_unicasts Received unicast packets
# TYPE junos_interface_receive_unicasts gauge
junos_interface_receive_unicasts{description="",mac="00:26:88:78:6b:03",name="ge-0/0/46",target="ex3200-1"} 1.093475547e+09

# HELP junos_interface_transmit_broadcasts Transmitted broadcast packets
# TYPE junos_interface_transmit_broadcasts gauge
junos_interface_transmit_broadcasts{description="",mac="00:26:88:78:6b:03",name="ge-0/0/46",target="ex3200-1"} 4.22708706e+08

# HELP junos_interface_transmit_errors_crc Number of CRC error outgoing packets
# TYPE junos_interface_transmit_errors_crc gauge
junos_interface_transmit_errors_crc{description="",mac="00:26:88:78:6b:05",name="ge-0/0/2",target="ex3200-1"} 0

# HELP junos_interface_transmit_multicasts Transmitted multicast packets
# TYPE junos_interface_transmit_multicasts gauge
junos_interface_transmit_multicasts{description="",mac="00:26:88:78:6b:03",name="ge-0/0/46",target="ex3200-1"} 9.96547927e+08

# HELP junos_interface_transmit_unicasts Transmitted unicast packets
# TYPE junos_interface_transmit_unicasts gauge
junos_interface_transmit_unicasts{description="",mac="00:26:88:78:6b:03",name="ge-0/0/46",target="ex3200-1"} 1.246669437e+09

These metrics are based on the output of show interfaces extensive | display xml .
The output of this command is the output of show interfaces statistics detail | display xml with the following additions.

<rpc-reply xmlns:junos="http://xml.juniper.net/junos/12.3R12/junos">
    <interface-information xmlns="http://xml.juniper.net/junos/12.3R12/junos-interface" junos:style="normal">
        <physical-interface>
            <name>ge-0/0/0</name>

            ...snip

            <ethernet-mac-statistics junos:style="verbose">
                <input-bytes>4779885871833</input-bytes>
                <output-bytes>14355870285837</output-bytes>
                <input-packets>24156588355</input-packets>
                <output-packets>31789344367</output-packets>
                <input-unicasts>22993966350</input-unicasts>
                <output-unicasts>29940927110</output-unicasts>
                <input-broadcasts>153380313</input-broadcasts>
                <output-broadcasts>538903016</output-broadcasts>
                <input-multicasts>1009241692</input-multicasts>
                <output-multicasts>1309514241</output-multicasts>
                <input-crc-errors>0</input-crc-errors>
                <output-crc-errors>0</output-crc-errors>
                <input-fifo-errors>0</input-fifo-errors>
                <output-fifo-errors>0</output-fifo-errors>
                <input-mac-control-frames>0</input-mac-control-frames>
                <output-mac-control-frames>0</output-mac-control-frames>
                <input-mac-pause-frames>0</input-mac-pause-frames>
                <output-mac-pause-frames>0</output-mac-pause-frames>
                <input-oversized-frames>0</input-oversized-frames>
                <input-jabber-frames>0</input-jabber-frames>
                <input-fragment-frames>0</input-fragment-frames>
                <input-code-violations>0</input-code-violations>
            </ethernet-mac-statistics>
            <ethernet-autonegotiation>
                <autonegotiation-status>complete</autonegotiation-status>
                <link-partner-status>OK</link-partner-status>
                <link-partner-duplexity>full-duplex</link-partner-duplexity>
                <link-partner-speed>1000 Mbps</link-partner-speed>
                <flow-control>Symmetric</flow-control>
                <local-info>
                    <local-flow-control>Symmetric</local-flow-control>
                    <local-remote-fault>Link OK</local-remote-fault>
                </local-info>
            </ethernet-autonegotiation>
            <pfe-information>
                <destination-slot>0</destination-slot>
            </pfe-information>
            <cos-header/>
            <cos-information>
                <cos-stream-information>
                    <cos-direction>Output</cos-direction>
                    <cos-queue-configuration>
                        <cos-queue-number>0</cos-queue-number>
                        <cos-queue-forwarding-class>best-effort</cos-queue-forwarding-class>
                        <cos-queue-bandwidth>95</cos-queue-bandwidth>
                        <cos-queue-bandwidth-bps>950000000</cos-queue-bandwidth-bps>
                        <cos-queue-buffer>95</cos-queue-buffer>
                        <cos-queue-buffer-bytes>NA</cos-queue-buffer-bytes>
                        <cos-queue-priority>low</cos-queue-priority>
                        <cos-queue-limit>none</cos-queue-limit>
                    </cos-queue-configuration>
                    <cos-queue-configuration>
                        <cos-queue-number>7</cos-queue-number>
                        <cos-queue-forwarding-class>network-control</cos-queue-forwarding-class>
                        <cos-queue-bandwidth>5</cos-queue-bandwidth>
                        <cos-queue-bandwidth-bps>50000000</cos-queue-bandwidth-bps>
                        <cos-queue-buffer>5</cos-queue-buffer>
                        <cos-queue-buffer-bytes>NA</cos-queue-buffer-bytes>
                        <cos-queue-priority>low</cos-queue-priority>
                        <cos-queue-limit>none</cos-queue-limit>
                    </cos-queue-configuration>
                </cos-stream-information>
            </cos-information>

            ...snip

Copy link
Owner

@czerwonk czerwonk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a unit to the metric names to make it more clear. Everything else LGTM

@@ -71,6 +79,14 @@ func (c *interfaceCollector) init() {
c.operStatusDesc = prometheus.NewDesc(prefix+"up", "Interface operational status", l, nil)
c.errorStatusDesc = prometheus.NewDesc(prefix+"error_status", "Admin and operational status differ", l, nil)
c.lastFlappedDesc = prometheus.NewDesc(prefix+"last_flapped_seconds", "Seconds since last flapped (-1 if never)", l, nil)
c.receiveUnicastsDesc = prometheus.NewDesc(prefix+"receive_unicasts", "Received unicast packets", l, nil)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a unit to the metric name (e.g. _packets)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for reviewing it!
Added units to the metric name. (_packets)

Copy link
Owner

@czerwonk czerwonk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@czerwonk czerwonk merged commit 042c6f2 into czerwonk:master Dec 11, 2021
@kakkotetsu kakkotetsu deleted the interface_bum branch March 7, 2022 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants