Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* [sql DBs](docs/snippets/databases/rdbs.md) - sql databases
* [Aerospike db](docs/snippets/databases/aerospike.md) - AE database
* [Mongo db](docs/snippets/databases/mongodb.md) - Mongo database
* [Elasticsearch](docs/snippets/databases/elasticsearch.md) - Elasticsearch

## Web Servers:
* [Nginx](docs/snippets/webservers/nginx.conf.md) - nginx web server
Expand Down
14 changes: 14 additions & 0 deletions docs/snippets/aws/athena.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ WITH SERDEPROPERTIES (
LOCATION 's3://your_log_bucket/prefix/AWSLogs/AWS_account_ID/elasticloadbalancing/';
```

# Querying the data:

### for the jdbc connection use this jdbc url:

`jdbc:awsathena://athena.THE_ATHENA_REGION.amazonaws.com:443/`
Expand All @@ -42,3 +44,15 @@ LOCATION 's3://your_log_bucket/prefix/AWSLogs/AWS_account_ID/elasticloadbalancin
[https://medium.com/datamindedbe/connect-to-aws-athena-using-datagrip-c34762e37a17](https://medium.com/datamindedbe/connect-to-aws-athena-using-datagrip-c34762e37a17) - workstation setup


### Parsing timestamps:
* **the format is CASE SENSIITVE**
`parse_datetime(request_timestamp, 'yyyy-MM-dd''T''HH:mm:ss.SSSSSS''Z''')`

* Query to calculate AVG/CNT grouped daily by verb and ret code:
```
select date(parse_datetime(request_timestamp, 'yyyy-MM-dd''T''HH:mm:ss.SSSSSS''Z''')) as req_date, request_verb, elb_response_code, avg(backend_processing_time) as avg_dur, count(*) as cnt from elb_logs_2 where parse_datetime(request_timestamp, 'YYYY-MM-dd''T''HH:mm:ss.SSSSSS''Z''') > date (now() - interval '6' day) group by date(parse_datetime(request_timestamp, 'yyyy-MM-dd''T''HH:mm:ss.SSSSSS''Z''')), request_verb , elb_response_code;
```

select request_verb, date(parse_datetime(request_timestamp, 'yyyy-MM-dd''T''HH:mm:ss.SSSSSS''Z''')) as req_date, avg(backend_processing_time) as avg_dur, count(*) as cnt from elb_logs_2 where parse_datetime(request_timestamp, 'YYYY-MM-dd''T''HH:mm:ss.SSSSSS''Z''') > parse_datetime('2018-01-20T09:00:07.490349Z', 'YYYY-MM-dd''T''HH:mm:ss.SSSSSS''Z''') group by date(parse_datetime(request_timestamp, 'yyyy-MM-dd''T''HH:mm:ss.SSSSSS''Z''')) ;

limit 10;
4 changes: 3 additions & 1 deletion docs/snippets/bash_snippets.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,5 +132,7 @@ shell locking to prevent concurrent execution:
flock -n -c command
```


# Shell execution detection
Checking if a script is sourced or subshelled:
`[[$0!="$BASH_SOURCE"]]||(echo"This script should be sourced. use'source$0'";exit1)`

13 changes: 13 additions & 0 deletions docs/snippets/databases/elasticsearch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@


# fix read-only indices :
```
PUT _settings
{
"index": {
"blocks": {
"read_only_allow_delete": "false"
}
}
}
```
11 changes: 11 additions & 0 deletions docs/snippets/langs/python_gen.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,14 @@ python --version
# py.test
...



# Usefull Links

[weblogs](https://www.artima.com/weblogs/viewpost.jsp?thread=240845)

[drastically-improve-your-python-understanding-pythons-execution-model](http://www.jeffknupp.com/blog/2013/02/14/drastically-improve-your-python-understanding-pythons-execution-model/)

[python classes](http://www.jeffknupp.com/blog/2014/06/18/improve-your-python-python-classes-and-object-oriented-programming/)

[python magic methods](http://www.rafekettler.com/magicmethods.html#appendix1)