├── LICENSE ├── README.md ├── alias.txt ├── dc-vmx-3.json ├── prometheus.yml └── resources ├── _interfaces_interface_state_counters_out_pkts_console.png ├── _interfaces_interface_state_counters_out_pkts_graph.png ├── _interfaces_interface_state_counters_out_pkts_rate.png ├── ifd_in_octets.png ├── ifd_in_pkts.png └── rate_ifd_in_pkts_2m.png /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Juniper Networks, Inc. All rights reserved 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # About this repository 2 | 3 | jtimon can collect openconfig telemetry from Junos devices 4 | it can also export the telemetry data received from Junos devices to Prometheus. The default export port is 8090, it is configurable. 5 | 6 | We will use jtimon to collect openconfig telemetry from junos devices. 7 | The data collected by jtimon will be exported to Prometheus 8 | 9 | # Junos details 10 | 11 | ## Junos version 12 | ``` 13 | lab@dc-vmx-3> show version | match telemetry 14 | JUNOS na telemetry [17.4R1.16-C1] 15 | ``` 16 | ``` 17 | lab@dc-vmx-3> show version | match openconfig 18 | JUNOS Openconfig [0.0.0.8] 19 | ``` 20 | ## Junos configuration 21 | ``` 22 | lab@dc-vmx-3> show configuration system services extension-service | display set 23 | set system services extension-service request-response grpc clear-text port 50051 24 | set system services extension-service request-response grpc skip-authentication 25 | set system services extension-service notification allow-clients address 0.0.0.0/0 26 | ``` 27 | ``` 28 | lab@dc-vmx-3> show configuration system services netconf | display set 29 | set system services netconf ssh 30 | ``` 31 | ## Junos troubleshooting 32 | to Display information about sensors, run this command: 33 | ``` 34 | lab@dc-vmx-3> show agent sensors 35 | ``` 36 | 37 | # Prometheus 38 | 39 | ## About Prometheus 40 | https://prometheus.io/ 41 | 42 | ## Install Prometheus 43 | Download Prometheus 44 | ``` 45 | $ wget https://github.com/prometheus/prometheus/releases/download/v2.5.0/prometheus-2.5.0.linux-amd64.tar.gz . 46 | ``` 47 | extract the content of the archieve 48 | ``` 49 | $ tar xvfz prometheus-2.5.0.linux-amd64.tar.gz 50 | ``` 51 | ``` 52 | $ cd prometheus-2.5.0.linux-amd64/ 53 | ``` 54 | Verify 55 | ``` 56 | $ ./prometheus --version 57 | $ ./prometheus --help 58 | ``` 59 | ## configure Prometheus 60 | update the ```prometheus.yml``` configuration file ([use this file](prometheus.yml)) 61 | 62 | ``` 63 | $ vi prometheus.yml 64 | ``` 65 | ## Start Prometheus 66 | ``` 67 | $ ./prometheus --config.file=prometheus.yml 68 | ``` 69 | ## prometheus GUI 70 | 71 | The url is ```http://:9090``` 72 | 73 | # jtimon 74 | 75 | ## About jtimon 76 | 77 | jtimon is a grpc client. 78 | you can use it to collect telemetry on junos devices. 79 | it is opensourced and written in GO 80 | https://github.com/nileshsimaria/jtimon 81 | https://forums.juniper.net/t5/Automation/OpenConfig-and-gRPC-Junos-Telemetry-Interface/ta-p/316090 82 | https://github.com/nileshsimaria/jtimon/wiki/JTIMON-and-Prometheus 83 | 84 | ## Install GO 85 | 86 | find out which ubuntu release you are using 87 | ``` 88 | $ lsb_release -a 89 | ``` 90 | download go 91 | ``` 92 | $ wget https://dl.google.com/go/go1.11.2.linux-amd64.tar.gz 93 | ``` 94 | verify 95 | ``` 96 | $ sha256sum go1.11.2.linux-amd64.tar.gz 97 | 98 | ``` 99 | unpack the package 100 | ``` 101 | $ tar xvfz go1.11.2.linux-amd64.tar.gz 102 | ``` 103 | move the go directory to /usr/local 104 | ``` 105 | $ sudo mv go /usr/local 106 | ``` 107 | ``` 108 | $ ls /usr/local/go/ 109 | ``` 110 | print go version 111 | ``` 112 | $ /usr/local/go/bin/go version 113 | ``` 114 | create a directory projects 115 | ``` 116 | $ mkdir projects 117 | ``` 118 | set environment variables 119 | - The GOPATH variable indicates places to look for Go code 120 | - The GOROOT environment variable indicates the path you choosed to unpack the package 121 | - The PATH environment variable specifies the directories in which the system will check when looking for commands (when a user types in a command without typing the whole path to the file on the command line) 122 | 123 | ``` 124 | $ export GOPATH=$HOME/projects 125 | $ export GOROOT=/usr/local/go 126 | $ export PATH=$GOPATH/bin:$GOROOT/bin:$PATH 127 | ``` 128 | Display the value of environment variables 129 | ``` 130 | $ printenv 131 | $ echo $HOME 132 | $ echo $GOROOT 133 | $ echo $GOPATH 134 | $ echo $PATH 135 | ``` 136 | print go version without typing the whole path 137 | ``` 138 | $ go version 139 | ``` 140 | 141 | 142 | ## Install jtimon 143 | ``` 144 | $ cd projects/ 145 | ``` 146 | download and install packages and dependencies 147 | ``` 148 | $ go get github.com/nileshsimaria/jtimon 149 | ``` 150 | ``` 151 | $ ls 152 | ``` 153 | ``` 154 | $ jtimon --help 155 | Usage of jtimon: 156 | --alias-file string File containing aliasing information 157 | --api Receive HTTP commands when running 158 | --compression string Enable HTTP/2 compression (gzip, deflate) 159 | --config strings Config file name(s) 160 | --config-file-list string List of Config files 161 | --explore-config Explore full config of JTIMON and exit 162 | --grpc-headers Add grpc headers in DB 163 | --gtrace Collect GRPC traces 164 | --json Convert telemetry packet into JSON 165 | --latency-profile Profile latencies. Place them in TSDB 166 | --log-mux-stdout All logs to stdout 167 | --max-run int Max run time in seconds 168 | --no-per-packet-goroutines Spawn per packet go routines 169 | --pprof Profile JTIMON 170 | --pprof-port int32 Profile port (default 6060) 171 | --prefix-check Report missing __prefix__ in telemetry packet 172 | --print Print Telemetry data 173 | --prometheus Stats for prometheus monitoring system 174 | --prometheus-port int32 Prometheus port (default 8090) 175 | --stats-handler Use GRPC statshandler 176 | --version Print version and build-time of the binary and exit 177 | ``` 178 | 179 | ## create a jtimon configuration file 180 | [use this file](dc-vmx-3.json) 181 | ``` 182 | $ vi dc-vmx-3.json 183 | ``` 184 | 185 | ## alias 186 | 187 | you can use alias. 188 | This is optional. 189 | If JTIMON does not find alias, it would use the names of the path as received from JTI (it will replace '/' with '_'). 190 | 191 | ``` 192 | $ cp src/github.com/nileshsimaria/jtimon/alias.txt alias.txt 193 | ``` 194 | ``` 195 | $ cat alias.txt 196 | ifd : /interfaces/interface/name 197 | physical_interface : /interfaces/interface/@name 198 | ifd-admin-status : /interfaces/interface/state/admin-status 199 | ifd-oper-status : /interfaces/interface/state/oper-status 200 | ifd-in-pkts:/interfaces/interface/state/counters/in-pkts 201 | ifd-in-octets:/interfaces/interface/state/counters/in-octets 202 | ifl:/interfaces/interface/subinterfaces/subinterface/index 203 | logical-interface-index:/interfaces/interface/subinterfaces/subinterface/@index 204 | ifl-in-ucast-pkts:/interfaces/interface/subinterfaces/subinterface/state/counters/in-unicast-pkts 205 | ifl-in-mcast-pkts:/interfaces/interface/subinterfaces/subinterface/state/counters/in-multicast-pkts 206 | ``` 207 | 208 | ## run jtimon and export data to prometheus 209 | 210 | run jtimon with the configuration file ```dc-vmx-3.json``` and print telemetry data and export telemetry data to prometheus 211 | ``` 212 | $ jtimon --prometheus --prometheus-port 8090 --config dc-vmx-3.json --print --alias-file alias.txt 213 | ``` 214 | 215 | ## verify jtimon is exporting telemetry data to prometheus 216 | 217 | verify jtimon and prometheus are active 218 | ``` 219 | $ ps -ef | grep "prometheus \| jtimon" 220 | root 1110 1 0 09:25 ? 00:00:01 ./prometheus --config.file=prometheus.yml 221 | root 1216 1 0 09:28 ? 00:00:13 jtimon --prometheus --prometheus-port 8090 --config vmx1.json --print --alias-file alias.txt 222 | ``` 223 | verify jtimon is exporting telemetry data to prometheus 224 | ``` 225 | $ netstat -ntlp | grep 90 226 | tcp 0 0 127.0.0.1:8090 0.0.0.0:* LISTEN 32074/jtimon 227 | tcp6 0 0 :::9090 :::* LISTEN 32063/prometheus 228 | ``` 229 | # Use Prometheus 230 | 231 | Open a browser and use the prometheus GUI. The url is ```http://:9090``` 232 | 233 | Examples 234 | 235 | ![ifd_in_pkts.png](resources/ifd_in_pkts.png) 236 | ![ifd_in_octets.png](resources/ifd_in_octets.png) 237 | ![rate_ifd_in_pkts_2m.png](resources/rate_ifd_in_pkts_2m.png) 238 | ![_interfaces_interface_state_counters_out_pkts_console.png](resources/_interfaces_interface_state_counters_out_pkts_console.png) 239 | ![_interfaces_interface_state_counters_out_pkts_rate.png](resources/_interfaces_interface_state_counters_out_pkts_rate.png) 240 | ![_interfaces_interface_state_counters_out_pkts_graph.png](resources/_interfaces_interface_state_counters_out_pkts_graph.png) 241 | 242 | -------------------------------------------------------------------------------- /alias.txt: -------------------------------------------------------------------------------- 1 | ifd : /interfaces/interface/name 2 | physical_interface : /interfaces/interface/@name 3 | ifd-admin-status : /interfaces/interface/state/admin-status 4 | ifd-oper-status : /interfaces/interface/state/oper-status 5 | ifd-in-pkts:/interfaces/interface/state/counters/in-pkts 6 | ifd-in-octets:/interfaces/interface/state/counters/in-octets 7 | ifl:/interfaces/interface/subinterfaces/subinterface/index 8 | logical-interface-index:/interfaces/interface/subinterfaces/subinterface/@index 9 | ifl-in-ucast-pkts:/interfaces/interface/subinterfaces/subinterface/state/counters/in-unicast-pkts 10 | ifl-in-mcast-pkts:/interfaces/interface/subinterfaces/subinterface/state/counters/in-multicast-pkts 11 | -------------------------------------------------------------------------------- /dc-vmx-3.json: -------------------------------------------------------------------------------- 1 | { 2 | "host": "172.30.52.152", 3 | "port": 50051, 4 | "user": "lab", 5 | "password": "m0naco", 6 | "cid": "my-client-id", 7 | "paths": [{ 8 | "path": "/interfaces", 9 | "freq": 2000 10 | }] 11 | } 12 | -------------------------------------------------------------------------------- /prometheus.yml: -------------------------------------------------------------------------------- 1 | # my global config 2 | global: 3 | scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. 4 | evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute. 5 | # scrape_timeout is set to the global default (10s). 6 | 7 | # Alertmanager configuration 8 | alerting: 9 | alertmanagers: 10 | - static_configs: 11 | - targets: 12 | # - alertmanager:9093 13 | 14 | # Load rules once and periodically evaluate them according to the global 'evaluation_interval'. 15 | rule_files: 16 | # - "first_rules.yml" 17 | # - "second_rules.yml" 18 | 19 | # A scrape configuration containing exactly one endpoint to scrape: 20 | # Here it's Prometheus itself. 21 | scrape_configs: 22 | # The job name is added as a label `job=` to any timeseries scraped from this config. 23 | 24 | - job_name: 'jtimon' 25 | static_configs: 26 | - targets: ['localhost:8090'] 27 | -------------------------------------------------------------------------------- /resources/_interfaces_interface_state_counters_out_pkts_console.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ksator/junos_monitoring_with_prometheus/0ff9b71439add66b51648f4c6456da359e784ee5/resources/_interfaces_interface_state_counters_out_pkts_console.png -------------------------------------------------------------------------------- /resources/_interfaces_interface_state_counters_out_pkts_graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ksator/junos_monitoring_with_prometheus/0ff9b71439add66b51648f4c6456da359e784ee5/resources/_interfaces_interface_state_counters_out_pkts_graph.png -------------------------------------------------------------------------------- /resources/_interfaces_interface_state_counters_out_pkts_rate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ksator/junos_monitoring_with_prometheus/0ff9b71439add66b51648f4c6456da359e784ee5/resources/_interfaces_interface_state_counters_out_pkts_rate.png -------------------------------------------------------------------------------- /resources/ifd_in_octets.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ksator/junos_monitoring_with_prometheus/0ff9b71439add66b51648f4c6456da359e784ee5/resources/ifd_in_octets.png -------------------------------------------------------------------------------- /resources/ifd_in_pkts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ksator/junos_monitoring_with_prometheus/0ff9b71439add66b51648f4c6456da359e784ee5/resources/ifd_in_pkts.png -------------------------------------------------------------------------------- /resources/rate_ifd_in_pkts_2m.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ksator/junos_monitoring_with_prometheus/0ff9b71439add66b51648f4c6456da359e784ee5/resources/rate_ifd_in_pkts_2m.png --------------------------------------------------------------------------------