forked from techfolios/template-old
-
Notifications
You must be signed in to change notification settings - Fork 0
so_elk dsl_tut
amaskey edited this page Mar 27, 2018
·
2 revisions
Elasticsearch DSL - Honza Kral
-
imports:
from elasticsearch_dsl import connections, Search, Q
-
create client connection:
es = connections.create_connection( hosts= ['localhost'], timeout=20)`
-
create Search, bind it to client:
s = Search(using=es)
-
query:
s.query('match', title='python')
-
query twice:
s = s.query( 'match', title='python').query( ~Q('match', title='ruby ) )
-
combines queries
- alternative:
s.query( Q() & ~Q() )
- alternative:
-
equivalent
Q('match', title='python') == Match(title='python') == Q({match:{title:'python'}})
- boolean
Q(1) & Q(2) == Q('bool', must=[ Q(1), Q(2) ])
Q(1) | Q(2) | Q(3) == Q('bool', should=[ Q(1), Q(2), Q(3) ])
-
filter:
s = s.filter('range', creation_date={ "from": date(2012, 1, 1)})
- filter will turn into filtered query
-
chaining
copy is made in each change
s2 = s1.query( Q(1) )
-->s1 != s2
same for other methods
s[0:10], s.using(es), s.index('today', 'yesterday'), ...
- chaining different except Aggs
s.aggs.bucket('per_tag').metric('avg).metric('max')
s.aggs.bucket('per_country').bucket('per_tag'), metric('avg')
s.aggs['per_country'].metric(...)
- execute:
result = s.execute()
- returns result object
response = s.execute()
if not response.success():
print("partial result")
- iterate over iterate
for h in response:
print(h._meta.id, h.title)
- accessing aggregations top_tag = response.aggregations.per_tag.bucker[0]
foot
- TODO
- troubleshoot
- Tutorials
- Security Onion Overview
- Elastic Stack
- bro
- Snort
- sguil
- squert
- netsniff-ng
- ossec
- cif
- beat
- banyard
- pulled pork
- pf ring
- CapMe
- apache
- my-sql
- python basic
- Sequences - list, dict, string...
- Regular expression
- functions
- Data Abstraction
- Trees
- containers
- object
- Libraries
-
useful libs
- datetime, json, pyperclip, io
- numpy
- matplotlib
- wavelets
- pandas
- pickle
-
useful libs
- Tutorial
- foot printing and reconnaissance
- scanning networks
- enumeration
- System Hacking
- Malware Threats
- Sniffing
- Social Engineering
- Denial-of-Service
- Session Hijacking
- Hacking Webservers
- Hacking Web Application
- SQL Injection
- Hacking Wireless Networks
- Hacking Mobile Platforms
- Evading IDS, Firewalls, and Honeypots
- Cloud Computing
- Cryptography