def find_nodes(self, query): if query.pattern == 'foo': yield BranchNode('foo') elif query.pattern == 'bar.*': for i in range(10): path = 'bar.{0}'.format(i) yield LeafNode(path, DummyReader(path))
def _nodes_from_rra(self, full_path, patterns, parent_metric, ds): assert len(patterns) == 1 for cf in self._get_cfs(full_path): if not self._match(cf, patterns[0]): continue reader = Reader(full_path, ds, cf) yield LeafNode("%s.%s" % (parent_metric, cf), reader)
def find_nodes(self, query): request = requests.post('%s/search' % graphouse_url, data={'query': query.pattern}) request.raise_for_status() result = request.text.split('\n') for metric in result: if not metric: continue if metric.endswith('.'): yield BranchNode(metric[:-1]) else: yield LeafNode(metric, GraphouseReader(metric, graphouse_url=self.graphouse_url))
def find_nodes(self, query): request = requests.get( '%s/search?%s' % (self.graphouse_url, urllib.parse.urlencode({'query': query.pattern}))) request.raise_for_status() result = request.text.split('\n') for metric in result: if not metric: continue if metric.endswith('.'): yield BranchNode(metric[:-1]) else: yield LeafNode(metric, GraphouseReader(metric, self.graphouse_url))
def find_nodes(self, query): logger.debug("find_nodes", finder="newts", start=query.startTime, end=query.endTime, pattern=query.pattern) for resource, metric, is_leaf in self._search_nodes(query.pattern): # XXX ambigous, : is valid in graphite name dot_path = resource.replace(':', '.') if not is_leaf: yield BranchNode(dot_path) else: reader = NewtsReader(self.client, resource, metric, self.config['fetch.maxpoints']) yield LeafNode('{}.{}'.format(dot_path, metric), reader)
def find_nodes(self, query): clean_pattern = query.pattern.replace('\\', '') pattern_parts = clean_pattern.split('.') for root_dir in self.dirs: for abs_path in self._find_paths(root_dir, pattern_parts): relative_path = abs_path[len(root_dir):].lstrip(os.sep) metric_path = fs_to_metric(relative_path) # Now we construct and yield an appropriate Node object if isdir(abs_path): yield BranchNode(metric_path) elif isfile(abs_path): if abs_path.endswith(KENSHIN_EXT): reader = KenshinReader(abs_path, metric_path, self.carbonlink) yield LeafNode(metric_path, reader)
def find_nodes(self, query): res = self.es.search(index=self.es_index, doc_type='_doc', body={ 'query': { 'regexp': { 'name': query.pattern.replace( '.', '\\.').replace( '*', '[-a-z0-9_;:]*') } } }, _source=['name', 'leaf']) for hit in res.get('hits', {}).get('hits'): metric = hit.get('_source') if metric['leaf']: yield LeafNode(metric['name'], Reader(metric['name'])) else: yield BranchNode(metric['name'])
def find_nodes(self, query, reqkey): metricsearch = getattr(settings, 'METRICSEARCH', '127.0.0.1') queries = self.expand_braces(query.pattern) result = [] for query in queries: request = requests.get( 'http://%s:7000/search?%s' % (metricsearch, urllib.urlencode({'query': query}))) request.raise_for_status() result += request.text.split('\n') for metric in result: if not metric: continue if metric.endswith('.'): yield BranchNode(metric[:-1]) else: yield LeafNode(metric, ClickHouseReader(metric, reqkey))
def find_nodes(self, query): try: query_depth = len(query.pattern.split('.')) #print 'DAS QUERY ' + str(query_depth) + ' ' + query.pattern client = Client(self.bf_query_endpoint, self.tenant) values = client.find_metrics(query.pattern) for obj in values: metric = obj['metric'] parts = metric.split('.') metric_depth = len(parts) if metric_depth > query_depth: yield BranchNode('.'.join(parts[:query_depth])) else: yield LeafNode( metric, TenantBluefloodReader(metric, self.tenant, self.bf_query_endpoint)) except Exception as e: print "Exception in Blueflood find_nodes: " print e raise e
def find_nodes(self, query): # query.pattern is basically regex, though * should become [^\.]+ and . \. # but list series doesn't support pattern matching/regex yet regex = query.pattern.replace('.', '\.').replace('*', '[^\.]+') self.logger.info("find_nodes query: %s -> %s" % (query.pattern, regex)) regex = re.compile(regex) series = self.client.query("list series") for s in series: self.logger.info("matching %s" % s['name']) series = [ s['name'] for s in series if regex.match(s['name']) is not None ] seen_branches = set() # for leaf "a.b.c" we should yield branches "a" and "a.b" for s in series: self.logger.info("leaf %s" % s) yield LeafNode(s, InfluxdbReader(self.client, s, self.logger)) branch = s.rpartition('.')[0] while branch != '' and branch not in seen_branches: self.logger.info("branch %s" % branch) yield BranchNode(branch) seen_branches.add(branch) branch = branch.rpartition('.')[0]