Welcome to Questions - Ask OpenNMS, where you can ask questions and receive answers from other members of the community.

Qwery RESTful API for interface traffic

0 votes
31 views

I'm looking for a way to qwery the RESTful API to get traffic information for a particular link on a particular node. I've looked through https://docs.opennms.org/opennms/releases/17.0.0/guide-development/guide-development.html#_nodes but have not found details on the node id (if the 3 digit number eg 180 is the node id or if it is what is in the curl command below).

I was hoping somebody has anything that could be helpful, below is my best attempt at a qwery, albeit one that does not function.

curl --insecure -u username:password "https://$SERVER:8443/opennms/rest/measurements/nodes/Routers%3A1445531058618/link%5Bxe_2_0_0-40a6779fa54a%5D"

OpenNMS version
19.0.1
asked Jul 31 by pederskz (230 points)

1 Answer

+2 votes
 
Best answer

Here is an example posting a JSON file with a request which allows you also to calculate requested data if necessary. I have this request in JSON format in a file named report.json which I can post to the measurements API:

{
    "start": 1425563626316,
    "end": 1501487728000,
    "step": 10000,
    "maxrows": 1600,
    "source": [
        {
            "aggregation": "AVERAGE",
            "attribute": "ifHCInOctets",
            "label": "ifHCInOctets",
            "resourceId": "nodeSource[Server:hevir01].interfaceSnmp[venet0]",
            "transient": "false"
        }
    ],
    "expression": [
        {
            "label": "ifHCInBytes",
            "value": "ifHCInOctets * 8",
            "transient": "false"
        }
    ]
}

  • The important parameters:
  • Start: Timestamp in milliseconds
  • End: Timestamp in millisecons
  • Resource ID: nodeSource[Server:hevir01].interfaceSnmp[venet0]
    • "Server" is the name of the Requisition my node named hevir01 is provisioned
    • "hevi01" is the foreignId which is in my case the same as the node label cause it is unique in my environment
    • "venet0" is the name of the interface

Hope this helps

curl -X POST \

     -H "Accept:application/json" \

     -H "content-type: application/json" \

     -u admin \

     -d @report.json \

     http://your-opennms:8980/opennms/rest/measurements

You can use the command line tool "jq" on linux which helps you dealing with JSON data on the CLI.

Hope it helps

 

answered Jul 31 by indigo (11,140 points)
selected Nov 7 by pederskz
...