Rest API nodes search doesnt return nodes with no interface defined to grafana
Description
When a node is defined in a requisition with no interfaces it cannot be listed in a node list by a grafana template $node.
However it can be listed if searched for in grafana when directly defining the node for an attribute. See attached screenshots;
grafanaDatasourceRequisition.jpg defines 2 nodes for the purposes of this experiment
testsearchnode1 is defined with no interfaces
testsearchnode2 has one interface.
When the nodes are listed to create an attribute in grafana both nodes show up in the list
See grafanaDatasourceAttribute.jpg
However when trying to list the nodes in a datasource template, only the nodes defined with interfaces are listed. See grafanaDatasourceTemplate.jpg
Yet nodes can be defined in OpenNMS which have no interfaces. (Note I know that statistics for a node could in theory only be obtained if the nodes had an interface but my use case is for displaying data for IoT nodes which are not directly reachable yet still have node data).
Looking at the logs, the REST interface turns this into a query through JdbcFilterDao.getNodeMap() which can only ever return nodes with an entry in the ipInterface table; The relavant SQL log is;
Filter.getNodeMap(): SQL statement: SELECT DISTINCT node.nodeID, node.nodeLabel FROM ipInterface JOIN node ON (ipInterface.nodeID = node.nodeID)
There appears to be no easy way to change the expression to include nodes not listed in the ipInterface table as the join is created by the DatabaseSchemaConfigFactory However I do not know this code sufficiently well to be sure that a simple fix could not be thought of.
Acceptance / Success Criteria
None
Attachments
3
Lucidchart Diagrams
Activity
Show:
Jesse White November 30, 2017 at 6:00 PM
The nodeFilter() query leverages the Filter API which returns a set of (Node ID, IP Address).
If your interested in seeing all nodes, perhaps would could add a new allNodes() query.
As a work-around, I would assign loop-back or link-local addresses without any services to the nodes in question.
When a node is defined in a requisition with no interfaces it cannot be listed in a node list by a grafana template $node.
However it can be listed if searched for in grafana when directly defining the node for an attribute. See attached screenshots;
grafanaDatasourceRequisition.jpg defines 2 nodes for the purposes of this experiment
testsearchnode1 is defined with no interfaces
testsearchnode2 has one interface.
When the nodes are listed to create an attribute in grafana both nodes show up in the list
See grafanaDatasourceAttribute.jpg
However when trying to list the nodes in a datasource template, only the nodes defined with interfaces are listed. See grafanaDatasourceTemplate.jpg
Yet nodes can be defined in OpenNMS which have no interfaces. (Note I know that statistics for a node could in theory only be obtained if the nodes had an interface but my use case is for displaying data for IoT nodes which are not directly reachable yet still have node data).
I traced this back to the opennms datasource template nodeFilter() function creating a rest query like http://139.162.227.142:8980/opennms/rest/nodes?filterRule=
If I run this query directly it only returns nodes which have an entry in the interfaces table.
(however all nodes are returned by http://139.162.227.142:8980/opennms/rest/nodes )
Looking at the logs, the REST interface turns this into a query through JdbcFilterDao.getNodeMap() which can only ever return nodes with an entry in the ipInterface table; The relavant SQL log is;
Filter.getNodeMap(): SQL statement: SELECT DISTINCT node.nodeID, node.nodeLabel FROM ipInterface JOIN node ON (ipInterface.nodeID = node.nodeID)
There appears to be no easy way to change the expression to include nodes not listed in the ipInterface table as the join is created by the DatabaseSchemaConfigFactory However I do not know this code sufficiently well to be sure that a simple fix could not be thought of.