Orb GNMIC
Orb GNMIC provison gnmic instances through a simple REST API using a policy mechanism. Each policy spin up a new gnmic
process running the configuration provided by the policy.
Project premises
1. Single binary: orb-gnmic
embeds gnmic
in its binary. Therefore, only one static binary is provided.
2. No persistence: orb-gnmic
stores data in memory and in temporary files only. This adds a new paradigm to gnmic
that is expected to run over a persisted config file as default.
3. Compatibility: orb-gnmic
is basically a wrapper over the official gnmic
which has not released a version 1.0
yet, i.e., breaking changes are expected. Any changes that occurs on its CLI will be reflected in this project.
Docker Image
You can download and run using docker image:
docker run --net=host ghcr.io/orb-community/orb-gnmic run
Command Line Interface (CLI)
Orb GNMIC allows some start up configuration that is listed below.
docker run --net=host ghcr.io/orb-community/orb-gnmic run --help
Run orb-gnmic
Usage:
orb-gnmic run [flags]
Flags:
-d, --debug Enable verbose (debug level) output
-h, --help help for run
-a, --server_host string Define REST Host (default "localhost")
-p, --server_port uint Define REST Port (default 10337)
REST API
The default orb-gnmic
address is localhost:10222
. to change that you can specify host and port when starting orb-gnimc
:
docker run --net=host ghcr.io/orb-community/orb-gnmic run -a {host} -p {port}
Routes (v1)
orb-gnmic
is aimed to be simple and straightforward.
Get runtime and capabilities information
GET
/api/v1/status
(gets orb-gnmic runtime data)
Parameters
None
Responses
http code content-type response 200
application/json; charset=utf-8
JSON data
Example cURL
curl -X GET -H "Content-Type: application/json" http://localhost:10337/api/v1/status
GET
/api/v1/capabilities
(gets otelcol-contrib capabilities)
Parameters
None
Responses
http code content-type response 200
application/json; charset=utf-8
JSON data
Example cURL
curl -X GET -H "Content-Type: application/json" http://localhost:10337/api/v1/capabilities
Policies Management
GET
/api/v1/policies
(gets all existing policies)
Parameters
None
Responses
http code content-type response 200
application/json; charset=utf-8
JSON array containing all applied policy names
Example cURL
curl -X GET -H "Content-Type: application/json" http://localhost:10337/api/v1/policies
POST
/api/v1/policies
(Creates a new policy)
Parameters
name type data type description None required YAML object yaml format specified in Policy RFC
Responses
http code content-type response 201
application/x-yaml; charset=UTF-8
YAML object 400
application/json; charset=UTF-8
{ "message": "invalid Content-Type. Only 'application/x-yaml' is supported" }
400
application/json; charset=UTF-8
Any policy error 400
application/json; charset=UTF-8
{ "message": "only single policy allowed per request" }
403
application/json; charset=UTF-8
{ "message": "config field is required" }
409
application/json; charset=UTF-8
{ "message": "policy already exists" }
Example cURL
curl -X POST -H "Content-Type: application/x-yaml" --data @post.yaml http://localhost:10337/api/v1/policies
GET
/api/v1/policies/{policy_name}
(gets information of a specific policy)
Parameters
name type data type description policy_name
required string The unique policy name
Responses
http code content-type response 200
application/x-yaml; charset=UTF-8
YAML object 404
application/json; charset=UTF-8
{ "message": "policy not found" }
Example cURL
curl -X GET http://localhost:10337/api/v1/policies/my_policy
DELETE
/api/v1/policies/{policy_name}
(delete a existing policy)
Parameters
name type data type description policy_name
required string The unique policy name
Responses
http code content-type response 200
application/json; charset=UTF-8
{ "message": "my_policy was deleted" }
404
application/json; charset=UTF-8
{ "message": "policy not found" }
Example cURL
curl -X DELETE http://localhost:10337/api/v1/policies/my_policy
Policy RFC (v1)
my_policy:
username: admin
password: admin
port: 57400
timeout: 10s
skip-verify: true
encoding: json_ietf
targets:
leaf1:57400:
leaf2:57400:
leaf3:57400:
spine1:57400:
spine2:57400:
subscriptions:
srl_if_oper_state:
paths:
- /interface[name=ethernet-1/*]/oper-state
mode: stream
stream-mode: sample
sample-interval: 5s
srl_net_instance:
paths:
- /network-instance[name=*]/oper-state
mode: stream
stream-mode: sample
sample-interval: 5s
srl_if_stats:
paths:
- /interface[name=ethernet-1/*]/statistics
mode: stream
stream-mode: sample
sample-interval: 5s
srl_if_traffic_rate:
paths:
- /interface[name=ethernet-1/*]/traffic-rate
mode: stream
stream-mode: sample
sample-interval: 5s
srl_cpu:
paths:
- /platform/control[slot=*]/cpu[index=all]/total
mode: stream
stream-mode: sample
sample-interval: 5s
srl_mem:
paths:
- /platform/control[slot=*]/memory
mode: stream
stream-mode: sample
sample-interval: 5s
srl_bgp_stats:
paths:
- /network-instance[name=*]/protocols/bgp/statistics
mode: stream
stream-mode: sample
sample-interval: 5s
srl_ipv4_routes:
paths:
- /network-instance[name=*]/route-table/ipv4-unicast/statistics/
mode: stream
stream-mode: sample
sample-interval: 5s
srl_ipv6_routes:
paths:
- /network-instance[name=*]/route-table/ipv6-unicast/statistics/
mode: stream
stream-mode: sample
sample-interval: 5s
srl_apps:
paths:
- /system/app-management/application[name=*]
mode: stream
stream-mode: sample
sample-interval: 5s
outputs:
prom:
type: prometheus
listen: :9273
path: /metrics
metric-prefix: gnmic
append-subscription-name: true
export-timestamps: true
debug: false
event-processors:
- trim-prefixes
- up-down-map
processors:
trim-prefixes:
event-strings:
value-names:
- ".*"
transforms:
- path-base:
apply-on: "name"
up-down-map:
event-strings:
value-names:
- oper-state
transforms:
- replace:
apply-on: "value"
old: "up"
new: "1"
- replace:
apply-on: "value"
old: "down"
new: "0"