forked from onebirdrocks/geektime-ELK
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d3014a1
commit 1b1c878
Showing
18 changed files
with
9,076 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
mkdir server_metrics | ||
cd server_metrics | ||
wget https://download.elasticsearch.org/demos/machine_learning/gettingstarted/server_metrics.tar.gz | ||
tar -xvf server_metrics.tar.gz |
Binary file not shown.
6,200 changes: 6,200 additions & 0 deletions
6,200
part-4/14.3用机器学习实现时序数据的异常检测-上/user-activity/user-activity.json
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# 集群Backup & Restore | ||
## 课程demo | ||
``` | ||
PUT /_snapshot/my_fs_backup | ||
{ | ||
"type": "fs", | ||
"settings": { | ||
"location": "/Users/yiruan/geektime/mount/my_backup", | ||
"compress": true | ||
} | ||
} | ||
PUT /_snapshot/my_fs_backup/snapshot_5?wait_for_completion=true | ||
DELETE /_snapshot/my_fs_backup/snapshot_2 | ||
GET /_snapshot/my_fs_backup/_all | ||
GET /_snapshot/my_fs_backup/_current | ||
POST /_snapshot/my_fs_backup/snapshot_1/_restore | ||
{ | ||
"indices": "testxxx", | ||
"index_settings": { | ||
"index.number_of_replicas": 5 | ||
}, | ||
"ignore_index_settings": [ | ||
"index.refresh_interval" | ||
] | ||
} | ||
GET testxxx/_settings | ||
DELETE testxxx | ||
GET testxxx | ||
PUT /_snapshot/my_fs_backup/snapshot_3?wait_for_completion=true | ||
{ | ||
"indices": "testxxx", | ||
"ignore_unavailable": true, | ||
"include_global_state": false, | ||
"metadata": { | ||
"taken_by": "yiming", | ||
"taken_because": "backup before upgrading" | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# 用 Java 和 Elasticsearch 开发应用 | ||
# 课程demo | ||
``` | ||
``` |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
课程demo | ||
``` | ||
安装配置 | ||
app-search.yml: | ||
allow_es_settings_modification: true | ||
#Allow Elasticsearch to create indexes automatically: Add the following line #within either Elasticsearch cluster settings or elasticsearch.yml: | ||
action.auto_create_index: ".app-search-*-logs-*,-.app-search-*,+*" | ||
``` |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import requests | ||
import json | ||
import os | ||
import sys | ||
|
||
indexName ="tmdb" | ||
queryFolder ="./query" | ||
headers={"Content-Type":"application/json","Accept":"application/json"} | ||
|
||
def search(query, printHighlight): | ||
print query | ||
url = "http://localhost:9200/%s/_search" %indexName | ||
resp = requests.get(url,headers=headers,data=json.dumps(query)) | ||
hits = json.loads(resp.text)["hits"] | ||
print "\r\n######################## Results ################################\r\n" | ||
print "No\tScore\t\t\tTitle" | ||
for idx, hit in enumerate(hits["hits"]): | ||
print "%s\t%s\t\t\t%s" %(idx+1, hit["_score"], hit["_source"]["title"]) | ||
print "---------------------------------------------------------------" | ||
if printHighlight: | ||
if (("highlight" in hit.keys()) and ("title" in hit["highlight"].keys())): | ||
hl = ";".join(hit["highlight"]["title"]).replace("<em>","\033[1;31;40m").replace("</em>","\033[0m") | ||
print "title: \033[0;32;40m%d hit(s)\033[0m \r\n%s\r\n--" %(len(hit["highlight"]["title"]) ,hl) | ||
if (("highlight" in hit) and ("overview" in hit["highlight"])): | ||
hl = ";".join(hit["highlight"]["overview"]).replace("<em>","\033[1;31;40m").replace("</em>","\033[0m") | ||
print "overview: \033[0;32;40m%d hit(s)\033[0m \r\n%s\r\n--" %( len(hit["highlight"]["overview"]), hl) | ||
|
||
|
||
def select_query(): | ||
print "\r\n>> Please select the query file.\r\n" | ||
queryList=os.listdir(queryFolder) | ||
for idx, queryItem in enumerate(queryList): | ||
print "[%d] %s" %(idx,queryItem) | ||
userInput = raw_input() | ||
try: | ||
selectIndex = int(userInput) | ||
except ValueError: | ||
selectIndex =-1 | ||
if(selectIndex==-1 or selectIndex > len(queryList)): | ||
print '\033[31mPlease provide a valid integer \033[0m' | ||
msg = "from 0 to %d." %(len(queryList)) | ||
print msg | ||
exit() | ||
queryName = queryList[selectIndex] | ||
fileName="%s/%s" %(queryFolder,queryName) | ||
f = open(fileName) | ||
query = {} | ||
if f: | ||
query = json.loads(f.read()); | ||
return query | ||
|
||
def main(): | ||
highlight = False | ||
for arg in sys.argv: | ||
if arg == "h" or arg == "hl" or arg == "highlight": | ||
highlight = True | ||
query = select_query() | ||
search(query, highlight) | ||
|
||
if __name__== "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
requests==2.20.0 |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.