Added WebAPI support for custom grafana labels; Fixed WebAPI grafana data collection...
authorEriks Jenkevics <eriks@netxms.org>
Wed, 29 Mar 2017 14:55:14 +0000 (17:55 +0300)
committerEriks Jenkevics <eriks@netxms.org>
Wed, 29 Mar 2017 14:55:19 +0000 (17:55 +0300)
src/server/nxapisrv/java/src/main/java/org/netxms/websvc/handlers/GrafanaDataCollection.java

index a8ab95b..1a1b85a 100644 (file)
@@ -97,11 +97,15 @@ public class GrafanaDataCollection extends AbstractHandler
          for(DciDataRow r : data.getValues())
          {
             datapoint = new JsonArray();
-            datapoint.add(r.getValueAsLong());
+            datapoint.add(r.getValueAsDouble());
             datapoint.add(r.getTimestamp().getTime());
             datapoints.add(datapoint);
          }
-         root.addProperty("target", e.getAsJsonObject().get("dci").getAsString());
+         if (e.getAsJsonObject().has("legend") && !e.getAsJsonObject().get("legend").getAsString().equals(""))
+            root.addProperty("target", e.getAsJsonObject().get("legend").getAsString());
+         else
+            root.addProperty("target", e.getAsJsonObject().get("dci").getAsString());
+         
          root.add("datapoints", datapoints);
          result.add(root);
       }