This is an automated email from the ASF dual-hosted git repository.

avijayan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ambari-metrics.git


The following commit(s) were added to refs/heads/master by this push:
     new 8341a3b  [AMBARI-25089] NIFI-Hosts dashboard does not show any metrics 
in Grafana. (#14)
8341a3b is described below

commit 8341a3b89465c2cd570b2870b15dbc2ae071c585
Author: avijayanhwx <avija...@hortonworks.com>
AuthorDate: Mon Feb 11 09:34:11 2019 -0800

    [AMBARI-25089] NIFI-Hosts dashboard does not show any metrics in Grafana. 
(#14)
---
 ambari-metrics-grafana/ambari-metrics/datasource.js                | 4 ++++
 .../ambari/metrics/core/timeline/query/MetadataQueryCondition.java | 7 ++++++-
 .../metrics/core/timeline/discovery/TestMetadataManager.java       | 2 +-
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/ambari-metrics-grafana/ambari-metrics/datasource.js 
b/ambari-metrics-grafana/ambari-metrics/datasource.js
index 6dc0446..70c3f56 100644
--- a/ambari-metrics-grafana/ambari-metrics/datasource.js
+++ b/ambari-metrics-grafana/ambari-metrics/datasource.js
@@ -291,6 +291,10 @@ define([
         // To speed up querying on templatized dashboards.
         var getAllHostData = function (target) {
           var instanceId = typeof target.templatedCluster == 'undefined' ? '' 
: '&instanceId=' + target.templatedCluster;
+          var appId = target.app;
+          if ((appId === 'nifi' || appId === 'druid') && !instanceId) {
+            instanceId = "%"
+          }
           var precision = target.precision === 'default' || typeof 
target.precision == 'undefined' ? '' : '&precision='
             + target.precision;
           var metricAggregator = target.aggregator === "none" ? '' : '._' + 
target.aggregator;
diff --git 
a/ambari-metrics-timelineservice/src/main/java/org/apache/ambari/metrics/core/timeline/query/MetadataQueryCondition.java
 
b/ambari-metrics-timelineservice/src/main/java/org/apache/ambari/metrics/core/timeline/query/MetadataQueryCondition.java
index f6e8c6a..0f6f611 100644
--- 
a/ambari-metrics-timelineservice/src/main/java/org/apache/ambari/metrics/core/timeline/query/MetadataQueryCondition.java
+++ 
b/ambari-metrics-timelineservice/src/main/java/org/apache/ambari/metrics/core/timeline/query/MetadataQueryCondition.java
@@ -60,7 +60,7 @@ public class MetadataQueryCondition extends 
TransientMetricCondition {
     }
 
     String instanceId = getInstanceId();
-    if (StringUtils.isNotEmpty(instanceId)) {
+    if (StringUtils.isNotEmpty(instanceId) && !"%".equals(instanceId)) {
       if (instanceId.contains("%")) {
         appendConjunction = append(sb, appendConjunction, instanceId, " 
INSTANCE_ID LIKE ?");
       } else {
@@ -71,6 +71,11 @@ public class MetadataQueryCondition extends 
TransientMetricCondition {
     return sb;
   }
 
+  @Override
+  public String getInstanceId() {
+    return instanceId == null || "%".equals(instanceId) || 
instanceId.isEmpty() ? null : instanceId;
+  }
+
   public boolean isMetricMetadataCondition() {
     return isMetricMetadataCondition;
   }
diff --git 
a/ambari-metrics-timelineservice/src/test/java/org/apache/ambari/metrics/core/timeline/discovery/TestMetadataManager.java
 
b/ambari-metrics-timelineservice/src/test/java/org/apache/ambari/metrics/core/timeline/discovery/TestMetadataManager.java
index 90a5d10..0d9c3e5 100644
--- 
a/ambari-metrics-timelineservice/src/test/java/org/apache/ambari/metrics/core/timeline/discovery/TestMetadataManager.java
+++ 
b/ambari-metrics-timelineservice/src/test/java/org/apache/ambari/metrics/core/timeline/discovery/TestMetadataManager.java
@@ -331,7 +331,7 @@ public class TestMetadataManager extends 
AbstractMiniHBaseClusterTest {
 
     uuids = 
metadataManager.getUuidsForGetMetricQuery(Collections.singletonList("%"),
       Collections.singletonList("%"), "%", "%");
-    Assert.assertTrue(uuids.size() == 6);
+    Assert.assertTrue(uuids.size() == 9);
   }
 
   @Test

Reply via email to