This is an example of how to setup gnmi-gateway with the Prometheus Exporter enabled.
- Copy
targets-example.json
from the project root toexample/gnmi-prometheus/targets.json
and modifytargets.json
to match the details of the gNMI target you want to connect to (your router). - cd to the root of the gnmi-gateway git repository. You can't build from this directory due to build context restrictions imposed by Docker.
- Build the gnmi-gateway docker image:
docker build \ -f examples/gnmi-prometheus/Dockerfile \ -t gnmi-gateway:latest .
- Create the network bridge that will be used to connect the two docker containers:
docker network create --driver bridge gnmi-net
- Start the gnmi-gateway docker image:
docker run \ -it --rm \ -p 59100:59100 \ -v $(pwd)/examples/gnmi-prometheus/targets.json:/opt/gnmi-gateway/targets.json \ --name gnmi-gateway-01 \ --network gnmi-net \ gnmi-gateway:latest
- In a new terminal window start the Prometheus docker image:
docker run \ -it --rm \ -p 9090:9090 \ -v $(pwd)/examples/gnmi-prometheus/prometheus.yml:/etc/prometheus/prometheus.yml \ --name prometheus-01 \ --network gnmi-net \ prom/prometheus
- You should now be able to browse to the Prometheus web server at http://127.0.0.1:9090 and see your gNMI metrics after a few minutes.