geth 新版 豪秒產生無法匯入
geth新版的geth.log 會產生豪秒
舊 INFO [04-22|16:29:56]
新 INFO [03-28|13:43:35.004]
差別在.004
看log會發現只有logstash的warning,經同事正確解釋是:
>>因為logstash轉換出來的日期格式2019-03-28 13:43:35.004,Elasticsearch不認得,所以對logstash來說是Warning,但對Elasticsearch是Error,造成Log寫不進去~
所以在logstash.conf上必須在解析date上,補上 "YYYY-MM-dd HH:mm:ss,SSS", "YYYY-MM-dd HH:mm:ss.SSS"
這樣就可以正常匯入geth.log了
舊 INFO [04-22|16:29:56]
新 INFO [03-28|13:43:35.004]
差別在.004
看log會發現只有logstash的warning,經同事正確解釋是:
>>因為logstash轉換出來的日期格式2019-03-28 13:43:35.004,Elasticsearch不認得,所以對logstash來說是Warning,但對Elasticsearch是Error,造成Log寫不進去~
所以在logstash.conf上必須在解析date上,補上 "YYYY-MM-dd HH:mm:ss,SSS", "YYYY-MM-dd HH:mm:ss.SSS"
date {
match => [ "gethdate" , "YYYY-MM-dd HH:mm:ss", "YYYY-MM-dd HH:mm:ss,SSS", "YYYY-MM-dd HH:mm:ss.SSS"]
target => "gethdate"
timezone => "Asia/Taipei"
}
這樣就可以正常匯入geth.log了
ElastAlert elasticsearch elk
docker-compose
version: '3.3'
services:
elasticsearch:
build:
context: elasticsearch/
volumes:
#- ./elasticsearch/esdata:/usr/share/elasticsearch/data:rw
- alldata:/usr/share/elasticsearch/data:rw
#- ./elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml:ro
ports:
- "9200:9200"
- "9300:9300"
environment:
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
nofile:
soft: 65536
hard: 65536
networks:
- fastdev
logstash:
build:
context: logstash/
volumes:
- ./logstash/config/logstash.yml:/etc/logstash/logstash.yml:ro
- ./logstash/pipeline:/etc/logstash/conf.d:ro
ports:
- "5000:5000"
- "5044:5044"
environment:
LS_JAVA_OPTS: "-Xmx256m -Xms256m"
networks:
- fastdev
depends_on:
- elasticsearch
kibana:
build:
context: kibana/
volumes:
- ./kibana/config/:/usr/share/kibana/config:ro
ports:
- "5601:5601"
networks:
- fastdev
depends_on:
- elasticsearch
fakelog:
build:
context: fakelog/
volumes:
- ./fakelog/logs:/ethereum-etl/output/:rw
networks:
- fastdev
elastalert:
build:
context: elastalert/
volumes:
- ./elastalert/config/config.json:/opt/elastalert-server/config/config.json:ro
- ./elastalert/config/elastalert.yaml:/opt/elastalert/config.yaml:ro
- ./elastalert/rules:/opt/elastalert/rules:rw
- ./elastalert/rule_templates:/opt/elastalert/rule_templates:ro
ports:
- "3030:3030"
# - "3333:3333"
environment:
- net=elasticsearch
networks:
- fastdev
volumes:
alldata:
networks:
fastdev:
driver: bridge
Only elasticsearch/Dockerfile some error happen because debian mirror. Other YAML see before blogs
FROM java:8-jre
# grab gosu for easy step-down from root
ENV GOSU_VERSION 1.7
RUN set -x \
&& wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture)" \
&& wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture).asc" \
&& export GNUPGHOME="$(mktemp -d)" \
&& gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 \
&& gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu \
&& rm -r "$GNUPGHOME" /usr/local/bin/gosu.asc \
&& chmod +x /usr/local/bin/gosu \
&& gosu nobody true
# https://www.elastic.co/guide/en/elasticsearch/reference/current/setup-repositories.html
# https://packages.elasticsearch.org/GPG-KEY-elasticsearch
#RUN apt-key adv --keyserver ha.pool.sks-keyservers.net --recv-keys 46095ACC8548582C1A2699A9D27D666CD88E42B4
#ENV ELASTICSEARCH_MAJOR 1.7
#ENV ELASTICSEARCH_VERSION 1.7.5
#ENV ELASTICSEARCH_REPO_BASE http://packages.elasticsearch.org/elasticsearch/1.7/debian
#RUN echo "deb $ELASTICSEARCH_REPO_BASE stable main" > /etc/apt/sources.list.d/elasticsearch.list
#RUN set -x \
# && apt-get clean && apt-get update \
# && apt-get install -y --no-install-recommends elasticsearch=$ELASTICSEARCH_VERSION \
# && rm -rf /var/lib/apt/lists/*
RUN wget -qO - https://packages.elastic.co/GPG-KEY-elasticsearch | apt-key add -
RUN echo "deb http://packages.elastic.co/elasticsearch/1.7/debian stable main" | tee -a /etc/apt/sources.list.d/elasticsearch-1.7.list
RUN echo "deb [check-valid-until=no] http://archive.debian.org/debian jessie-backports main" > /etc/apt/sources.list.d/jessie.list
RUN echo "deb [check-valid-until=no] http://cdn-fastly.deb.debian.org/debian jessie main" > /etc/apt/sources.list.d/jessie.list
RUN echo "deb [check-valid-until=no] http://archive.debian.org/debian jessie-backports main" > /etc/apt/sources.list.d/jessie-backports.list
RUN sed -i '/deb http:\/\/deb.debian.org\/debian jessie-updates main/d' /etc/apt/sources.list
RUN apt-get -o Acquire::Check-Valid-Until=false update && apt-get install elasticsearch
ENV PATH /usr/share/elasticsearch/bin:$PATH
WORKDIR /usr/share/elasticsearch
RUN set -ex \
&& for path in \
./data \
./logs \
./config \
./config/scripts \
; do \
mkdir -p "$path"; \
chown -R elasticsearch:elasticsearch "$path"; \
done
COPY config ./config
#VOLUME /usr/share/elasticsearch/data
COPY docker-entrypoint.sh /
RUN chmod +x /docker-entrypoint.sh
EXPOSE 9200 9300
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["elasticsearch"]
ElastAlert/Dockerfile
FROM bitsensor/elastalert:latest
ElastAlert/config/config.json
{
"appName": "elastalert-server",
"port": 3030,
"wsport": 3333,
"elastalertPath": "/opt/elastalert",
"verbose": false,
"es_debug": false,
"debug": false,
"rulesPath": {
"relative": true,
"path": "/rules"
},
"templatesPath": {
"relative": true,
"path": "/rule_templates"
},
"es_host": "elasticsearch",
"es_port": 9200,
"writeback_index": "elastalert_status"
}
ElastAlert/config/elastalert.yaml
es_host: elasticsearch
es_port: 9200
rules_folder: rules
# How often ElastAlert will query elasticsearch
# The unit can be anything from weeks to seconds
run_every:
seconds: 5
#minutes: 1
# ElastAlert will buffer results from the most recent
# period of time, in case some log sources are not in real time
buffer_time:
minutes: 15
# If an alert fails for some reason, ElastAlert will retry
# sending the alert until this time period has elapsed
alert_time_limit:
minutes: 2
#days: 2
writeback_index: elastalert_status
#smtp_host: ""
ElastAlert/config/rules/test_metric.yaml
name: Example rule
# How often ElastAlert will query elasticsearch
# The unit can be anything from weeks to seconds
run_every:
seconds: 5
#minutes: 1
# ElastAlert will buffer results from the most recent
# period of time, in case some log sources are not in real time
buffer_time:
minutes: 15
# If an alert fails for some reason, ElastAlert will retry
# sending the alert until this time period has elapsed
alert_time_limit:
minutes: 2
#days: 2
type: metric_aggregation
index: filebeat-*
metric_agg_key: project
metric_agg_type: value_count
#query_key: "name.keyword"
doc_type: _type
max_threshold: 32
min_threshold: 19
filter:
- query:
query_string:
query: "srctype: geth AND project: hr AND mined AND geth_ip: \"xxx.xxx.xxx.xxx\""
#alert_subject: "No data on dashboard"
# "|" means remove useless characters
alert_text: |
test attach
alert_text_args: []
alert:
- "email"
email:
- "1803110@narlabes.org.tw"
ElastAlert/config/rule_templates
copy file from github or not copy.https://github.com/Yelp/elastalert/tree/master/example_rules
run ElastAlert or ElastAlert test
cd /opt/elastalert
a. elastalert
b. elastalert-test-rule ./rules/test_metric.yaml --start 2019-04-10T08:40:00.000
#At /opt/elastalert run command, it auto load config.yaml on this path. You can find "ls config.yaml".
And rules (test_metric.yaml) put on path /opt/elastalert/rules
elastalert.yml and config.json put on path /opt/elastalert-server/config
ethereum etl ELK docker docker-compose .env startblock endblock
ethereum-etl export data every time write over file. Filebeat always reload file then ELK receive repeat records...
So
source get file that path need to be careful
So
.env
STARTBLOCK=01205866
ENDBLOCK=01205888
startetl.sh
IP_PORT is go-ethereum-node1 outside ip & port. here is docker-machinesource get file that path need to be careful
#!/bin/bash
IP_PORT=192.168.99.100:18545
ETH_METHOD=eth_blockNumber
BLOCKNUMBER_JSON_HEX=$(curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"'$ETH_METHOD'","params":[],"id":1}' $IP_PORT | jq '.result' | tr -d '"')
BLOCKNUMBER_DEX=$(printf "%08d\n" $BLOCKNUMBER_JSON_HEX)
printf "\n===== Now Geth BlockerNumber =====\n"
printf "HEX: %s\n" $BLOCKNUMBER_JSON_HEX
printf "DEC: %s\n" $BLOCKNUMBER_DEX
source .env
#source ~/ethereum_etl/.env
printf "\n===== .env BLOCK VARS =====\n"
printf "STARTBLOCK: %s\n" $STARTBLOCK
printf "ENDBLOCK: %s\n" $ENDBLOCK
if [[ $BLOCKNUMBER_DEX =~ ^?[0-9]+$ ]] || [ -z $BLOCKNUMBER_DEX ]; then
printf "NOT Number Geth BLOCKNUMBER, check Geth\n"
exit
fi
if [[ $STARTBLOCK =~ ^?[0-9]+$ ]] || [ -z $STARTBLOCK ]; then
printf "NOT Number .env STARTBLOCK, check .env\n"
exit
fi
if [[ $ENDBLOCK =~ ^?[0-9]+$ ]] || [ -z $ENDBLOCK ]; then
printf "NOT Number .env ENDBLOCK, check .env\n"
exit
fi
#printf "\n%s\n" $BLOCKNUMBER_DEX
#printf "%s" $STARTBLOCK
#printf "\n%s\n" $((10#$BLOCKNUMBER_DEX - 10#$STARTBLOCK))
if (( (( 10#$BLOCKNUMBER_DEX - 10#$STARTBLOCK -1 )) > 0 )); then
printf "\n===== Change .env =====\n"
printf "startblock: %s => %s\n" $STARTBLOCK $((10#$ENDBLOCK+1))
printf "endblock: %s => %s\n" $ENDBLOCK $BLOCKNUMBER_DEX
STARTBLOCK=$(printf "%08d\n" $((10#$ENDBLOCK+1)) )
echo STARTBLOCK=$STARTBLOCK > ~/ethereum_etl/.env
echo ENDBLOCK=$BLOCKNUMBER_DEX >> .env
#echo STARTBLOCK=$STARTBLOCK > ~/ethereum_etl/.env
#echo ENDBLOCK=$BLOCKNUMBER_DEX >> ~ethereum_etl/.env
fi
docker-compose up --build ethereum_etl
docker-compose.yml
version: '3.3'
services:
go-ethereum-node1:
build:
context: go-ethereum-node1/
volumes:
#- ./go-ethereum/keystore:/root/.ethereum/devchain/keystore:rw
- ./go-ethereum-node1/genesis/poa_for_dev.json:/root/genesis/poa_for_dev.json:ro
- alldata:/root/.ethereum/devchain
- /etc/localtime:/etc/localtime:ro
#- ./go-ethereum/log:/root/log:rw
entrypoint: /root/start.sh
ports:
- "18545:8545"
- "30313:30303"
- "30313:30303/udp"
networks:
- etl
ethereum_etl:
build:
context: ethereum-etl/
env_file: .env
volumes:
- alldata:/ethereum-etl/output:rw
#- /root/go/src/github.com/ethereum/go-ethereum/build/bin/data:/ethereum-etl/ipc
#restart: unless-stopped
networks:
- etl
volumes:
alldata:
networks:
etl:
driver: bridge
ethereum_etl DOCKERFILE
FROM python:3.6-alpine
MAINTAINER Eric Lim
ENV PROJECT_DIR=ethereum-etl
RUN apk add unzip
RUN wget https://github.com/blockchain-etl/ethereum-etl/archive/develop.zip \
&& unzip develop.zip && rm develop.zip
RUN mv ethereum-etl-develop /$PROJECT_DIR
WORKDIR /$PROJECT_DIR
RUN apk add --no-cache gcc musl-dev #for C libraries:
RUN pip install --upgrade pip && pip install -e /$PROJECT_DIR/
#CMD ["export_all", "-s", "01990000", "-e", "99999999", "-p", "http://xxx.xxx.xxx.xxx:8545", "-o", "output"]
#CMD ["sh","-c", "echo startblock=$STARTBLOCK endblock=$ENDBLOCK"]
CMD ["sh","-c","python ethereumetl export_all -s $STARTBLOCK -e $ENDBLOCK -p http://xxx.xxx.xxx.xxx:8545 -o output"]
go-ethereum-node1
see https://sueboy.blogspot.com/search?q=poaelk oss kibana error docker
{"type":"log","@timestamp":"2019-01-21T08:57:51Z","tags":["status","plugin:elasticsearch@6.5.2","error"],"pid":1,"state":"red","message":"Status changed from yellow to red - Request Timeout after 3000ms","prevState":"yellow","prevMsg":"Waiting for Elasticsearch"}
1. First use oss
FROM docker.elastic.co/elasticsearch/elasticsearch-oss:6.5.2
FROM docker.elastic.co/kibana/kibana-oss:6.5.2
So Not X-pack problem
2. Truly Problem is connect to elasticsearch failed
Even login kibana docker then ping elasticsearch docker that get response. But kibana logs always get this error message.
kibana website message "Kibana server is not ready yet"
Try to get docker elasticsearch ip, change docker kibana.yml like example:
#elasticsearch.url: http://elasticsearch:9200
elasticsearch.url: http://172.19.0.2:9200
docker-compose up --build # sure image rebuild
elk kibana search geth ethereum
https://blog.csdn.net/qq_38486203/article/details/80817037
Search minedNumber
Get minedNumber
Search minedNumber
GET /filebeat-6.*-geth*/_search?q=geth_ip:xxx.xxx.xxx.xxx
{
"_source": ["name", "minedNumber", "gethdate"],
"sort": [
{
"gethdate": {
"order": "desc"
}
}
],
"from": 1,
"size": 1
}
Get minedNumber
curl -XGET "http://xxx.xxx.xxx.xxx:9200/filebeat-6.*-geth*/_search?q=geth_ip:xxx.xxx.xxx.xxx" -H 'Content-Type: application/json' -d'
{
"_source": ["name", "minedNumber", "gethdate"],
"sort": [
{
"gethdate": {
"order": "desc"
}
}
],
"from": 1,
"size": 1
}' | jq ".hits.hits[]._source.minedNumber"
kibana geo_point How to Part 6
Kibana Dev Tools
GET _cat
GET _cat/indices?v
GET _cat/indices?v&s=index
GET _cat/segments?v
GET /_settings
GET /_stats
GET /_template
GET _cluster/health
GET filebeat-6.5.1-2019.01.01
POST filebeat-6.5.1-2019.01.01
PUT filebeat-6.5.1-2019.01.01
DELETE filebeat-6.5.1-2019.01.01
GET filebeat-6.5.1-2019.01.*
POST filebeat-6.5.1-2019.01.*
PUT filebeat-6.5.1-2019.01.*
DELETE filebeat-6.5.1-2019.01.*
GET filebeat-6.5.1-2019.01.01/_stats
GET filebeat-6.5.1-2019.01.01/_mapping
POST /_refresh
POST /_cache/clear
POST /_flush/synced
?v
show column nameSegments Merge
https://my.oschina.net/fufangchun/blog/1541156https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-forcemerge.html#forcemerge-multi-index
GET _cat/segments?v
POST /filebeat-6.5.1-2019.01.01/_forcemerge?max_num_segments=1&flush=true

https://my.oschina.net/weiweiblog/blog/2989931
ethereum-etl ethereumetl elk logstash kibana part2
filter {
if [etltype] == "blocks" { #[fields][srctype]
csv {
columns => [
"number", "hash", "parent_hash", "nonce", "sha3_uncles", "logs_bloom", "transactions_root",
"state_root", "receipts_root", "miner", "difficulty", "total_difficulty", "size", "extra_data",
"gas_limit", "gas_used", "timestamp", "transaction_count"
]
separator => ","
remove_field => ["message"]
skip_empty_columns => true
skip_empty_rows => true
}
}else if [etltype] == "contracts" { #[fields][srctype]
csv {
columns => [
"address", "bytecode", "function_sighashes", "is_erc20", "is_erc721"
]
separator => ","
remove_field => ["message"]
skip_empty_columns => true
skip_empty_rows => true
}
}else if [etltype] == "logs" { #[fields][srctype]
csv {
columns => [
"log_index", "transaction_hash", "transaction_index", "block_hash", "block_number",
"address", "data", "topics"
]
separator => ","
remove_field => ["message"]
skip_empty_columns => true
skip_empty_rows => true
}
}else if [etltype] == "receipts" { #[fields][srctype]
csv {
columns => [
"transaction_hash", "transaction_index", "block_hash", "block_number", "cumulative_gas_used",
"gas_used", "contract_address", "root", "status"
]
separator => ","
remove_field => ["message"]
skip_empty_columns => true
skip_empty_rows => true
}
}else if [etltype] == "token_transfers" { #[fields][srctype]
csv {
columns => [
""
]
separator => ","
remove_field => ["message"]
skip_empty_columns => true
skip_empty_rows => true
}
}else if [etltype] == "tokens" { #[fields][srctype]
csv {
columns => [
""
]
separator => ","
remove_field => ["message"]
skip_empty_columns => true
skip_empty_rows => true
}
}else if [etltype] == "transactions" { #[fields][srctype]
csv {
columns => [
"hash", "nonce", "block_hash", "block_number", "transaction_index", "from_address",
"to_address", "value", "gas", "gas_price", "inputcontext"
]
separator => ","
remove_field => ["message"]
skip_empty_columns => true
skip_empty_rows => true
}
}
}
output {
if [etltype] == "blocks" {
elasticsearch {
hosts => "xxx.xxx.xxx.xxx:9200"
manage_template => false
index => "%{[@metadata][beat]}-%{[@metadata][version]}-blocks-%{+YYYY.MM.dd}"
document_id => "%{[hash]}"
}
}else if [etltype] == "logs" {
elasticsearch {
hosts => "xxx.xxx.xxx.xxx:9200"
manage_template => false
index => "%{[@metadata][beat]}-%{[@metadata][version]}-logs-%{+YYYY.MM.dd}"
}
}else if [etltype] == "transactions" {
elasticsearch {
hosts => "xxx.xxx.xxx.xxx:9200"
manage_template => false
index => "%{[@metadata][beat]}-%{[@metadata][version]}-transactions-%{+YYYY.MM.dd}"
document_id => "%{[hash]}"
}
}else if [etltype] == "contracts" {
elasticsearch {
hosts => "xxx.xxx.xxx.xxx:9200"
manage_template => false
index => "%{[@metadata][beat]}-%{[@metadata][version]}-contracts-%{+YYYY.MM.dd}"
document_id => "%{[address]}"
}
}else{
elasticsearch {
hosts => "xxx.xxx.xxx.xxx:9200"
manage_template => false
index => "%{[@metadata][beat]}-%{[@metadata][version]}-%{+YYYY.MM.dd}"
}
}
stdout { codec => rubydebug }
}
transactions csv fileds are
hash,nonce,block_hash,block_number,transaction_index,from_address,to_address,value,gas,gas_price,input
input
must change to other name likeinputcontext
like this:
hash,nonce,block_hash,block_number,transaction_index,from_address,to_address,value,gas,gas_price,inputcontext
Fxxxx No change name can't import success, even logstash get correct. But this bug sometime use new docker-compose ELK can import success. So just change name more easy.
===============================
Error No Use
if [etltype] in ["blocks"]
Correct
if [etltype] == "blocks"
Only more then two args
if [etltype] in ["blocks", "transactions" ...]
This is ok
ELK filebeat logstash FXXX
Use filebeat nginx module send nginx log to logstash or driect to elastick all get error!!
BUT some nginx log record can send success. That success records try to copy to other VM that have filebeat and logstash, try to send again. all get error!!
BUT some nginx log record can send success. That success records try to copy to other VM that have filebeat and logstash, try to send again. all get error!!
filebeat resend log file
https://stackoverflow.com/questions/41703689/how-do-i-force-rebuild-logs-data-in-filebeat-5
sudo service filbeat stop
mv /var/lib/filebeat/registry /var/lib/filebeat/registry.old
sudo service filbeat start
[轉]ELK:kibana使用的lucene查询语法
https://segmentfault.com/a/1190000002972420
通配符
? 匹配单个字符
* 匹配0到多个字符
kiba?a, el*search
? * 不能用作第一个字符,例如:?text *text
====================
正则
es支持部分正则功能,性能较差
name:/joh?n(ath[oa]n)/
====================
模糊搜索
quikc~ brwn~ foks~
~:在一个单词后面加上~启用模糊搜索,可以搜到一些拼写错误的单词
first~ 这种也能匹配到 frist
还可以设置编辑距离(整数),指定需要多少相似度
cromm~1 会匹配到 from 和 chrome
默认2,越大越接近搜索的原始值,设置为1基本能搜到80%拼写错误的单词
====================
逻辑操作
AND
OR
+:搜索结果中必须包含此项
-:不能含有此项
+apache -jakarta test aaa bbb:结果中必须存在apache,不能有jakarta,剩余部分尽量都匹配到
====================
分组
(jakarta OR apache) AND jakarta
====================
转义特殊字符
+ - = && || > < ! ( ) { } [ ] ^ " ~ * ? : \ /
以上字符当作值搜索的时候需要用\转义
\(1\+1\)\=2用来查询(1+1)=2
====================
通配符
? 匹配单个字符
* 匹配0到多个字符
kiba?a, el*search
? * 不能用作第一个字符,例如:?text *text
====================
正则
es支持部分正则功能,性能较差
name:/joh?n(ath[oa]n)/
====================
模糊搜索
quikc~ brwn~ foks~
~:在一个单词后面加上~启用模糊搜索,可以搜到一些拼写错误的单词
first~ 这种也能匹配到 frist
还可以设置编辑距离(整数),指定需要多少相似度
cromm~1 会匹配到 from 和 chrome
默认2,越大越接近搜索的原始值,设置为1基本能搜到80%拼写错误的单词
====================
逻辑操作
AND
OR
+:搜索结果中必须包含此项
-:不能含有此项
+apache -jakarta test aaa bbb:结果中必须存在apache,不能有jakarta,剩余部分尽量都匹配到
====================
分组
(jakarta OR apache) AND jakarta
====================
转义特殊字符
+ - = && || > < ! ( ) { } [ ] ^ " ~ * ? : \ /
以上字符当作值搜索的时候需要用\转义
\(1\+1\)\=2用来查询(1+1)=2
====================
elk 清除 indices delete clean windows curator
ELK 教學 - 定期清除 Elasticsearch 資料
https://blog.johnwu.cc/article/elk-purge-elasticsearch-index.html
https://www.elastic.co/guide/en/elasticsearch/client/curator/current/configfile.html
https://www.elastic.co/guide/en/elasticsearch/client/curator/current/ex_delete_indices.html
https://anjia0532.github.io/2017/04/06/elasticsearch-delete-indices-by-date/
config.yml
curator_filebeat.yml
curator_heartbeat.yml
If very slow or get error, try use curl command line. Delete some indices then use curator again.
https://blog.johnwu.cc/article/elk-purge-elasticsearch-index.html
https://www.elastic.co/guide/en/elasticsearch/client/curator/current/configfile.html
https://www.elastic.co/guide/en/elasticsearch/client/curator/current/ex_delete_indices.html
https://anjia0532.github.io/2017/04/06/elasticsearch-delete-indices-by-date/
config.yml
# Remember, leave a key empty if there is no value. None will be a string,
# not a Python "NoneType"
client:
hosts:
- xxx.xxx.xxx.xxx
port: 9200
url_prefix:
use_ssl: False
certificate:
client_cert:
client_key:
ssl_no_validate: False
http_auth:
timeout: 30
#timeout: 60
master_only: False
logging:
loglevel: INFO
logfile:
logformat: default
blacklist: ['elasticsearch', 'urllib3']
curator_filebeat.yml
# Remember, leave a key empty if there is no value. None will be a string,
# not a Python "NoneType"
#
# Also remember that all examples have 'disable_action' set to True. If you
# want to use this action as a template, be sure to set this to False after
# copying it.
actions:
1:
action: delete_indices
description: >-
Delete indices older than 30 days (based on index name), for logstash-
prefixed indices. Ignore the error if the filter does not result in an
actionable list of indices (ignore_empty_list) and exit cleanly.
options:
ignore_empty_list: True
disable_action: False
filters:
- filtertype: pattern
kind: prefix
value: filebeat-
- filtertype: age
source: name
direction: older
timestring: '%Y.%m.%d'
unit: days
unit_count: 30
curator_heartbeat.yml
# Remember, leave a key empty if there is no value. None will be a string,
# not a Python "NoneType"
#
# Also remember that all examples have 'disable_action' set to True. If you
# want to use this action as a template, be sure to set this to False after
# copying it.
actions:
1:
action: delete_indices
description: >-
Delete indices older than 15 days (based on index name), for logstash-
prefixed indices. Ignore the error if the filter does not result in an
actionable list of indices (ignore_empty_list) and exit cleanly.
options:
ignore_empty_list: True
disable_action: False
filters:
- filtertype: pattern
kind: prefix
value: heartbeat-
- filtertype: age
#source: name
source: creation_date
direction: older
timestring: '%Y.%m.%d'
unit: days
unit_count: 15
curator.exe --config config.yml curator_filebeat.yml
curator.exe --config config.yml curator_heartbeat.yml
If very slow or get error, try use curl command line. Delete some indices then use curator again.
curl "http://localhost:9200/_cat/indices?v&h=i"
curl -XDELETE "http://xxx.xxx.xxx.xxx:9200/filebeat-6.5.1-2018.12.17"
ethereum-etl ethereumetl elk logstash kibana
all output columns with logstash
filter {
if [srctype] == "etl" { #[fields][srctype]
csv {
columns => [
"number", "hash", "parent_hash", "nonce", "sha3_uncles", "logs_bloom", "transactions_root",
"state_root", "receipts_root", "timestamp", "extra_data", "transaction_count", "gas_limit",
"size", "total_difficulty", "difficulty", "miner", "block_hash", "block_number",
"transaction_index", "from_address", "to_address", "value", "gas", "gas_price", "input",
"address", "bytecode", "function_sighashes", "is_erc20", "is_erc721", "log_index",
"transaction_hash", "data", "topics", "cumulative_gas_used", "gas_used", "contract_address",
"root,status"
]
separator => ","
remove_field => ["message"]
#autodetect_column_names => true #have problems
#autogenerate_column_names => true #have problems
skip_empty_columns => true
skip_empty_rows => true
}
}
logstash fileds if
https://sueboy.blogspot.com/2018/11/elk60filebeatdocumenttype.html
filebeat.yml
- type: log
paths:
- /var/log/geth.log
exclude_files: ['.gz$']
fields:
srctype: "geth"
pipleline logstah.conf
if [fields][srctype] == "geth" {
BUT fields_under_root: true
- type: log
paths:
- /var/log/geth.log
exclude_files: ['.gz$']
fields:
srctype: "geth"
fields_under_root: true
if [srctype] == "geth" {
kibana geo_point How to Part 5
Oragin
geoip {
source => "filebeatserverip"
target => "filebeatserveripgeoip"
add_field => [ "[filebeatserveripgeoip][coordinates]", "%{[filebeatserveripgeoip][longitude]}" ]
add_field => [ "[filebeatserveripgeoip][coordinates]", "%{[filebeatserveripgeoip][latitude]}" ]
}
mutate {
convert => ["[filebeatserveripgeoip][coordinates]", "float"]
}
Delete
add_field => [ "[filebeatserveripgeoip][coordinates]", "%{[filebeatserveripgeoip][longitude]}" ]
add_field => [ "[filebeatserveripgeoip][coordinates]", "%{[filebeatserveripgeoip][latitude]}" ]
convert => ["[filebeatserveripgeoip][coordinates]", "float"]
geoip {
source => "filebeatserverip"
target => "filebeatserveripgeoip"
}
mutate {
}
=====
{
"index_patterns": ["filebeat*", "heartbeat*"],
"settings": {
"number_of_shards": 1
},
"mappings": {
"doc": {
"properties": {
"filebeatserveripgeoip.coordinates": {
"type": "geo_point"
}
}
}
}
}
Change filebeatserveripgeoip.coordinates -> filebeatserveripgeoip.location
{
"index_patterns": ["filebeat*", "heartbeat*"],
"settings": {
"number_of_shards": 1
},
"mappings": {
"doc": {
"properties": {
"filebeatserveripgeoip.location": {
"type": "geo_point"
}
}
}
}
}
template_filebeat.json
curl -v -XPUT elasticsearch:9200/_template/template_filebeat -H 'Content-Type: application/json' -d @/usr/share/config/template_filebeat.json
curl -v -XPUT elasticsearch:9200/_template/template_filebeat -H 'Content-Type: application/json' -d'
{
"index_patterns": ["filebeat*", "heartbeat*"],
"settings": {
"number_of_shards": 1
},
"mappings": {
"doc": {
"properties": {
"filebeatserveripgeoip.location": {
"type": "geo_point"
}
}
}
}
}'
location be created by geoip plugin.
MAX Import
GET _cat/indices?v
GET _cat/indices?v&s=index
GET filebeat-6.5.1-2018.12.06
DELETE filebeat-6.5.1-2018.12.06
GET _cat/indices?v
GET filebeat-6.5.1-2018.12.06
AND
refresh chrome (brwoser)
geth log No Year
geth log mined
INFO [12-07|13:04:44] 🔨 mined potential block number=1934700 hash=3f9161…88da7d
only month-day .......
Recreate index
GET _cat/indices?v
GET _cat/indices?v&s=index
GET filebeat-6.5.1-2018.12.06
DELETE filebeat-6.5.1-2018.12.06
GET _cat/indices?v
GET filebeat-6.5.1-2018.12.06
If index rebuild, Kibana DISCOVER table will be see.
INFO [12-07|13:04:44] 🔨 mined potential block number=1934700 hash=3f9161…88da7d
only month-day .......
grok {
match => ["message", "%{LOGLEVEL:logType} \[%{DATA:gethmm}-%{DATA:gethdd}\|%{DATA:gethtime}\] %{GREEDYDATA:tmessage} number=(?\b\w+\b) hash=(?\b\w+...\w+\b)"]
add_field => ["gethdate", "%{[gethmm]}-%{[gethdd]} %{[gethtime]}"]
}
ruby {
code =>
" tstamp = event.get('@timestamp').to_i
event.set('epoch',tstamp)
event.set('gethdate', Time.at(tstamp).strftime('%Y')+'-'+event.get('gethdate'))
"
}
date {
match => [ "gethdate" , "YYYY-MM-dd HH:mm:ss"]
target => "gethdate"
timezone => "Asia/Taipei"
}
Recreate index
GET _cat/indices?v
GET _cat/indices?v&s=index
GET filebeat-6.5.1-2018.12.06
DELETE filebeat-6.5.1-2018.12.06
GET _cat/indices?v
GET filebeat-6.5.1-2018.12.06
If index rebuild, Kibana DISCOVER table will be see.
訂閱:
文章 (Atom)
