Uploaded image for project: 'OpenNMS'
  1. OpenNMS
  2. NMS-8337

Non-existing resources or attributes break JasperReports when using the Measurements API

    XMLWordPrintable

    Details

      Description

      I have a custom jasper report template that uses the Measurements API:

          <queryString language="measurement">
              <![CDATA[<query-request step="300000" start="$P{startDateTime}" end="$P{endDateTime}" maxrows="5000">
                  <source aggregation="AVERAGE" label="ifInErrors" attribute="ifInErrors" transient="false" resourceId="$P{nodeResourceDescriptor}.interfaceSnmp[$P{interface}]"/>
                  <source aggregation="AVERAGE" label="ifOutErrors" attribute="ifOutErrors" transient="false" resourceId="$P{nodeResourceDescriptor}.interfaceSnmp[$P{interface}]"/>
                  <source aggregation="AVERAGE" label="ifOutDiscards" attribute="ifOutDiscards" transient="false" resourceId="$P{nodeResourceDescriptor}.interfaceSnmp[$P{interface}]"/>
                  <source aggregation="AVERAGE" label="ifInDiscards" attribute="ifInDiscards" transient="false" resourceId="$P{nodeResourceDescriptor}.interfaceSnmp[$P{interface}]"/>
                  <source aggregation="AVERAGE" label="InPauseFrame" attribute="dot3HCInPauseFrame" transient="false" resourceId="$P{nodeResourceDescriptor}.interfaceSnmp[$P{interface}]"/>
              </query-request>]]>
          </queryString>
      

      For all the nodes involved, some of the interface have all the attributes, but some of them don't (specially dot3HCInPauseFrame). When they don't have the attributes, an exception is thrown and the report is generated but all the values associated with metric fields are always going to be null, even those that are supposed to have data:

      2016-04-12 07:27:08,661 DEBUG [gkvi_Ifin_outErrors subreports #2] o.o.n.d.s.InterfaceSnmpResourceType: populateResourceList: adding resource toString interfaceSnmp[Gi2_0_12-503de57e070c]
      2016-04-12 07:27:08,661 DEBUG [gkvi_Ifin_outErrors subreports #2] o.o.n.d.s.DefaultResourceDao: getChildResource: returning resource nodeSource[RZ-Access-Switche%3A30036a].interfaceSnmp[Gi2_0_12-503de57e070c]
      2016-04-12 07:27:08,661 ERROR [gkvi_Ifin_outErrors subreports #2] o.o.n.m.i.AbstractRrdBasedFetchStrategy: No attribute with name: dot3HCInPauseFrame
      2016-04-12 07:27:08,661 WARN  [gkvi_Ifin_outErrors subreports #2] o.o.n.j.m.l.LocalMeasurementDataSourceWrapper: A attribute or resource was not found
      org.opennms.netmgt.measurements.api.exceptions.ResourceNotFoundException: Resource or attribute not found for QueryRequest{Step=300, Start=1460325600000, End=1460412000000, Max Rows=0, Interval=null, Heartbeat=null, Sources=[Source{Label=ifInErrors, Resource ID=nodeSource
      [RZ-Access-Switche:30036a].interfaceSnmp[Gi2_0_12-503de57e070c], Attribute=ifInErrors, Datasource=null, Transient=false}, Source{Label=ifOutErrors, Resource ID=nodeSource[RZ-Access-Switche:30036a].interfaceSnmp[Gi2_0_12-503de57e070c], Attribute=ifOutErrors, Datasource=nul
      l, Transient=false}, Source{Label=ifOutDiscards, Resource ID=nodeSource[RZ-Access-Switche:30036a].interfaceSnmp[Gi2_0_12-503de57e070c], Attribute=ifOutDiscards, Datasource=null, Transient=false}, Source{Label=ifInDiscards, Resource ID=nodeSource[RZ-Access-Switche:30036a].
      interfaceSnmp[Gi2_0_12-503de57e070c], Attribute=ifInDiscards, Datasource=null, Transient=false}, Source{Label=InPauseFrame, Resource ID=nodeSource[RZ-Access-Switche:30036a].interfaceSnmp[Gi2_0_12-503de57e070c], Attribute=dot3HCInPauseFrame, Datasource=null, Transient=fals
      e}], Expressions=[], Filters=[]}
              at org.opennms.netmgt.measurements.api.MeasurementsService.query(MeasurementsService.java:79) ~[org.opennms.features.measurements.api-17.1.0.jar:?]
              at org.opennms.netmgt.jasper.measurement.local.LocalMeasurementDataSourceWrapper.createDataSource(LocalMeasurementDataSourceWrapper.java:76) [jasper-extensions-17.1.0.jar:?]
              at org.opennms.netmgt.jasper.measurement.MeasurementQueryExecutor.createDatasource(MeasurementQueryExecutor.java:77) [jasper-extensions-17.1.0.jar:?]
              at org.opennms.netmgt.jasper.measurement.MeasurementQueryExecutor.createDatasource(MeasurementQueryExecutor.java:46) [jasper-extensions-17.1.0.jar:?]
              at net.sf.jasperreports.engine.fill.JRFillDataset.createQueryDatasource(JRFillDataset.java:1129) [jasperreports-6.1.1.jar:6.1.1]
              at net.sf.jasperreports.engine.fill.JRFillDataset.initDatasource(JRFillDataset.java:696) [jasperreports-6.1.1.jar:6.1.1]
              at net.sf.jasperreports.engine.fill.BaseReportFiller.setParameters(BaseReportFiller.java:437) [jasperreports-6.1.1.jar:6.1.1]
              at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:523) [jasperreports-6.1.1.jar:6.1.1]
              at net.sf.jasperreports.engine.fill.JRFillSubreport.fillSubreport(JRFillSubreport.java:742) [jasperreports-6.1.1.jar:6.1.1]
              at net.sf.jasperreports.engine.fill.JRSubreportRunnable.run(JRSubreportRunnable.java:58) [jasperreports-6.1.1.jar:6.1.1]
              at net.sf.jasperreports.engine.fill.AbstractThreadSubreportRunner.run(AbstractThreadSubreportRunner.java:216) [jasperreports-6.1.1.jar:6.1.1]
              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_45]
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_45]
              at java.lang.Thread.run(Thread.java:745) [?:1.8.0_45]
      

      A missing resource or attribute should not break the filling process of a report. In fact, with the old jrobin/rrdtool query language, a missing entity is silently ignored (i.e. no data, NaN or whatever Jasper expects for "not a number"), which is the expected behavior.

        Attachments

          Activity

            People

            • Assignee:
              mvr Markus von RĂ¼den
              Reporter:
              agalue Alejandro Galue
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: