1. ElasticSearch파일- bin - elasticsearch.bat 실행
2. kibana파일 - bin - kibana.bat 실행 - http://localhost:5601
3. logstash파일 - bin - logstash -f "C:\logstash-7.6.0\logstash-7.6.0\config\test2.conf"
ELASTIC SEARCH명령어 윈도우용 - json 파일 업로드
curl -XPUT "http://localhost:9200/blog/user/dilbert" -H "Content-Type: application/json" -d "{ ""name"" : ""Dilbert Brown""}""
curl -XGET http://localhost:9200/blog?pretty
curl -XPUT "http://localhost:9200/classes/class/1" -H "Content-Type: application/json" -d "{ ""title"" : ""Algorithm"",""professor"":""John""}"
//document 추가 + 확인
curl -XPOST "http://localhost:9200/classes/class/1" -H "Content-Type: application/json" _update -d "{ ""doc"" : {""unit"":1}}"
curl -XGET http://localhost:9200/classes/class/1?pretty
curl -XPOST "http://localhost:9200/classes/class/1" -H "Content-Type: application/json" _update -d "{ ""doc"" : {""unit"":2}}"
//또다른방법
curl -XPOST "http://localhost:9200/classes/class/1" -H "Content-Type: application/json" _update -d "{ ""script"" : ""ctx._source.unit+=5""}"
//bulk파일
curl -s -XPOST "http://localhost:9200/_bulk" -H "Content-Type: application/json" --data-binary @classes.json
curl -XGET http://localhost:9200/classes?pretty
//mapping ->이방식은 이미 생성된 index에 대한 내장필드를 설정하는방법이다.
curl -XPUT "http://localhost:9200/yoonseo/class/_mapping?include_type_name=true" -d @classesRating_mapping.json -H "Content-Type: application/json"
curl -XGET http://localhost:9200/yoonseo?pretty
//데이터 넣어줌
curl -XPOST "http://localhost:9200/yoonseo/_bulk"?pretty -H "Content-Type: application/json" --data-binary @classes.json
curl -XGET http://localhost:9200/yoonseo/class/3?pretty
//search
curl -s -XPOST "http://localhost:9200/_bulk" -H "Content-Type: application/json" --data-binary @simple_basketball.json
curl -XGET http://localhost:9200/basketball/record/_search?pretty
검색1
curl -XGET "localhost:9200/basketball/record/_search?q=points:30&pretty"
검색2 //error
curl -XGET "localhost:9200/basketball/record/_search -d"
{
"query":{
"term":{ "points":30}
}
}"
//aggregation
curl -XPOST "http://localhost:9200/_search"?pretty -H "Content-Type: application/json" --data-binary @avg_points_aggs.json
curl -XPOST "http://localhost:9200/_search"?pretty -H "Content-Type: application/json" --data-binary @max_points_aggs.json
curl -XPOST "http://localhost:9200/_search"?pretty -H "Content-Type: application/json" --data-binary @stats_points_aggs.json
//bulk_aggregaion (basket지우고다시)
curl -XPUT localhost:9200/basketball
curl -XPUT "http://localhost:9200/basketball/record/_mapping?include_type_name=true" -d @basketball_mapping.json -H "Content-Type: application/json"
curl -s -XPOST "http://localhost:9200/_bulk" --data-binary @bulk_basketball.json -H "Content-Type: application/json"
curl -XGET http://localhost:9200/basketball/record/_search?pretty
curl -XGET "http://localhost:9200/_search"?pretty -H "Content-Type: application/json" --data-binary @terms_aggs.json #에러
curl -XGET "http://localhost:9200/_search"?pretty -H "Content-Type: application/json" --data-binary @stats_points_aggs.json
curl -XGET "http://localhost:9200/_search?pretty --data-binary @terms_aggs.json
curl -s -XPOST "http://localhost:9200/_bulk" -H "Content-Type: application/json" --data-binary @bulk_basketball.json
curl -s -XPOST "http://localhost:9200/_bulk" -H "Content-Type: application/json" --data-binary @classes.json
curl -X POST -H "Content-Type: application/x-ndjson" localhost:9200/_bulk --data-binary "@bulk_basketball.json"
{
"size": 0,
"aggs": { // 집계
"my_aggs": { // 집계 명 (사용자 정의)
"{metric_arrgs_type}": { // 집계 타입
"field": "{file_name}" // 집계 대상 필드
"order" : { "{field_name}" : "desc" } // 정렬
}
}
}
} //매트릭집계구조 GET /{index_name}/_search?pretty
logstash - 대량 csv파일 업로드용
---> 에러 발생시 logstash - logs안에 있는 제일 최근 텍스트 열어서 확인하기
아래 참조
'<수업> > 과제' 카테고리의 다른 글
Elastalert test alert with slack (0) | 2021.01.15 |
---|---|
SSH 원격파일을 로컬파일로 다운로드하기 (대용량 파일) (0) | 2021.01.15 |
Software Architecture Style 조사하기 - Elasticsearch (0) | 2021.01.13 |
Elastalert 가이드라인 README.md (0) | 2021.01.13 |
서울시 공공데이터(CSV) Logstash로 Elasticsearch에 올리고 Kibana에서 분석하기 (+한글깨짐해결) (0) | 2021.01.13 |