add --program and set it to docker/statusd-mail
Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
parent
5f143ab855
commit
a7983b2f50
|
@ -49,6 +49,8 @@ Options:
|
|||
Name of the field to count.
|
||||
-F FLEET, --fleet=FLEET
|
||||
Name of the fleet to query.
|
||||
-D PROGRAM, --program=PROGRAM
|
||||
Name of the program to query.
|
||||
-m MAX_SIZE, --max-size=MAX_SIZE
|
||||
Max number of counts to find.
|
||||
-l LOG_LEVEL, --log-level=LOG_LEVEL
|
||||
|
|
8
main.py
8
main.py
|
@ -29,10 +29,12 @@ def parse_opts():
|
|||
help='PostgreSQL database name.')
|
||||
parser.add_option('-i', '--index-pattern', default='logstash-*',
|
||||
help='Patter for matching indices.')
|
||||
parser.add_option('-f', '--field', type='str', default='peer_id',
|
||||
parser.add_option('-f', '--field', default='peer_id',
|
||||
help='Name of the field to count.')
|
||||
parser.add_option('-F', '--fleet', type='str', default='eth.prod',
|
||||
parser.add_option('-F', '--fleet', default='eth.prod',
|
||||
help='Name of the fleet to query.')
|
||||
parser.add_option('-D', '--program', default='docker/statusd-mail',
|
||||
help='Name of the program to query.')
|
||||
parser.add_option('-m', '--max-size', type='int', default=100000,
|
||||
help='Max number of counts to find.')
|
||||
parser.add_option('-l', '--log-level', default='INFO',
|
||||
|
@ -81,10 +83,12 @@ def main():
|
|||
index=index,
|
||||
field=opts.field,
|
||||
fleet=opts.fleet,
|
||||
program=opts.program,
|
||||
max_query=opts.max_size
|
||||
)
|
||||
if len(rval) == 0:
|
||||
LOG.warning('No entries found!')
|
||||
LOG.debug('Found: %s', len(rval))
|
||||
peers.extend(rval)
|
||||
|
||||
if len(peers) == 0:
|
||||
|
|
11
query.py
11
query.py
|
@ -31,13 +31,18 @@ class ESQueryPeers():
|
|||
def get_indices(self, pattern='logstash-*'):
|
||||
return self.client.indices.get(index=pattern).keys()
|
||||
|
||||
def get_peers(self, index, field='peer_id', fleet='eth.prod', max_query=10000):
|
||||
def get_peers(self, index, field, fleet, program, max_query=10000):
|
||||
body = {
|
||||
'size': 0, # Don't return actual values
|
||||
'size': 10, # Don't return actual values
|
||||
'aggs': {
|
||||
'peers': {
|
||||
'filter': {
|
||||
'term': { 'fleet': fleet },
|
||||
'bool': {
|
||||
'must': [
|
||||
{ 'term': { 'fleet': fleet } },
|
||||
{ 'term': { 'program': program } },
|
||||
],
|
||||
},
|
||||
},
|
||||
'aggs': {
|
||||
'fpeers': {
|
||||
|
|
Loading…
Reference in New Issue