Skip to content

JTIMON and Prometheus

Nilesh Simaria edited this page Jan 10, 2019 · 7 revisions

JTIMON supports exporting telemetry data it has received from Junos devices into Prometheus. To explain how to do it, please find below sample prometheus configuration. You would need to add a section in scrap_configs as shown below.

$ cat prometheus.yml
# my global config
global:
  scrape_interval:     15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
  evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
  # scrape_timeout is set to the global default (10s).

# Alertmanager configuration
alerting:
  alertmanagers:
  - static_configs:
    - targets:
      # - alertmanager:9093

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  # - "first_rules.yml"
  # - "second_rules.yml"

# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
  # The job name is added as a label `job=` to any timeseries scraped from this config.
  - job_name: 'jtimon'

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    static_configs:
    - targets: ['localhost:8090']

I am running Prometheus on localhost and JTIMON on localhost. The JTIMON is exporting metrics on port 8090. This is configurable in JTIMON so one can change as required.

Start Prometheus with the above config.

Now, start JTIMON as shown below.

$ ./jtimon-darwin-amd64 --prometheus --config ~/sample-config/r0edge.json --print

where r0edge.json is following (you can add your path of interest)

$ cat ~/sample-config/r0edge.json
{
    "host": "your-junos-ip-or-hostname",
    "port": JSD-GRPC-Port-Number,
    "paths": [{
        "path": "/interfaces",
        "freq": 4000
    }],
    "alias" : "tests/data/juniper-junos/alias/alias.txt"
}

Please chose right JTIMON binary as per OS on which you are running it. I am running it on Mac.

alias is optional. However, you can make use of it to give small aliases to a long paths, if you wish. You can provide the mapping as shown below.

$ cat tests/data/juniper-junos/alias/alias.txt
ifd : /interfaces/interface/name
physical_interface : /interfaces/interface/@name
ifd-admin-status : /interfaces/interface/state/admin-status
ifd-oper-status : /interfaces/interface/state/oper-status
ifd-in-pkts:/interfaces/interface/state/counters/in-pkts
ifd-in-octets:/interfaces/interface/state/counters/in-octets
ifl:/interfaces/interface/subinterfaces/subinterface/index
logical-interface-index:/interfaces/interface/subinterfaces/subinterface/@index
ifl-in-ucast-pkts:/interfaces/interface/subinterfaces/subinterface/state/counters/in-unicast-pkts
ifl-in-mcast-pkts:/interfaces/interface/subinterfaces/subinterface/state/counters/in-multicast-pkts

So when device send /interfaces/interface/subinterfaces/subinterface/state/counters/in-unicast-pkts, it will use ifl-in-ucast-pkts and store it in Prometheus.

If JTIMON does not find mapping/alias, it would use the names of the path as received from JTI (it will replace '/' with '_').

Below is from my run.

JTIMON-Prometheus

Clone this wiki locally