def getModelUrl(url, datasource='prometheus', isUpper=None): # None to make sure drop anomaly is tured on #if modeDropAnomaly is None: # return None origMetricName = None if datasource == 'prometheus': origMetricName = retrieveMetricName(url) elif datasource == 'wavefront': origMetricName, others = parseQueryData(url) newMetricName = getModelMetricName(origMetricName, datasource, isUpper) return url.replace(origMetricName, newMetricName)
def test_wavefront_2(self): nn, kv = parseQueryData(self.str3) expected_nn = 'appdynamics_apm_transactions_errors_per_min' self.assertEqual(nn, expected_nn)
def test_wavefront_0(self): nn, kv = parseQueryData(self.str1) expected_nn = 'ad_apm_errors_errors_per_min' self.assertEqual(nn, expected_nn)
def test_wavefront_1(self): nn, kv = parseQueryData(self.str2) expected_nn = 'tf_http_server_requests_count' self.assertEqual(nn, expected_nn)
#import sys #sys.path.append('../') from wavefront.metric import parseQueryData str1 = 'sum(ts(tf.http.server.requests.count, env="prd" and app="abc" and status="5*"))' nn, kv = parseQueryData(str1) print(nn) print(kv) str1 = 'avg(align(60s, mean, ts("ad.apm.errors.errors_per_min", env="prd" and app="efg")), app)' nn, kv = parseQueryData(str1) print(nn) print(kv)