传统意义上,Elk是作为代替splunk的一个开源解决方案。Splunk是日志分析领域的领导者。日志分析不仅包括系统产生的错误日志、异常,也包括业务逻辑、任何文本类的分析,而基于日志分的分析,能够产生非常多的解决方案;比如:
docker Registry Mirrors推荐
{
"registry-mirrors": ["https://e2iytqf0.mirror.aliyuncs.com/"]
}
下载链接: https://pan.baidu.com/s/1duGzCPdiuBO6z9r8iGaq5w 提取码: p5yr
执行安装
chmod a+rwx run
./run
docker exec -it es elasticsearch-setup-passwords interactive
#执行结果:密码:root123456
[root@cd36 env]# docker exec -it es elasticsearch-setup-passwords interactive
Initiating the setup of passwords for reserved users elastic,apm_system,kibana,kibana_system,logstash_system,beats_system,remote_monitoring_user.
You will be prompted to enter passwords as the process progresses.
Please confirm that you would like to continue [y/N]y
Enter password for [elastic]:
Reenter password for [elastic]:
Enter password for [apm_system]:
Reenter password for [apm_system]:
Enter password for [kibana_system]:
Reenter password for [kibana_system]:
Enter password for [logstash_system]:
Reenter password for [logstash_system]:
Enter password for [beats_system]:
Reenter password for [beats_system]:
Enter password for [remote_monitoring_user]:
Reenter password for [remote_monitoring_user]:
Changed password for user [apm_system]
Changed password for user [kibana_system]
Changed password for user [kibana]
Changed password for user [logstash_system]
Changed password for user [beats_system]
Changed password for user [remote_monitoring_user]
Changed password for user [elastic]
xpack.security.enabled: true
#xpack配置参考:https://www.elastic.co/guide/en/kibana/7.9/security-settings-kb.html
#kibana配置参考:https://www.elastic.co/guide/en/kibana/7.9/settings.html
server.name: kibana
server.host: "0.0.0.0"
elasticsearch.hosts: [ "http://es:9200" ]
i18n.locale: zh-CN
#elasticsearch.username: "kibana_system"
#elasticsearch.password: "root123456"
#
#
#
#安全配置:xpack.security.encryptionKey在kibana.yml 配置文件中设置属性。您可以使用32个字符或更长的任何文本字符串作为加密密钥
#参考地址:https://www.elastic.co/guide/en/kibana/7.9/using-kibana-with-security.html
xpack.security.encryptionKey: "8884aea3bdfb65e3083a9280f4758086"
#
#
#报告配置:要设置用于报告的静态加密密钥,请xpack.reporting.encryptionKey在kibana.yml 配置文件中设置 属性。您可以使用任何至少32个字符的字母数字文本字符串作为加密密钥。
#参考地址:https://www.elastic.co/guide/en/kibana/7.9/configuring-reporting.html
xpack.reporting.encryptionKey: "8884aea3bdfb65e3083a9280f4758086"
#
#参考地址:https://www.elastic.co/guide/en/security/7.9/detections-permissions-section.html
xpack.encryptedSavedObjects.encryptionKey: "8884aea3bdfb65e3083a9280f4758086"
docker exec -it kibana /usr/share/kibana/bin/kibana-keystore create
docker exec -it kibana /usr/share/kibana/bin/kibana-keystore add elasticsearch.username
docker exec -it kibana /usr/share/kibana/bin/kibana-keystore add elasticsearch.password
http://192.168.10.191:5601
账户:elastic
密码:你自己密码
http://192.168.10.191:9200
账户:elastic
密码:你自己密码
docker run --rm -itd -u fluent -v $(pwd)/test/fluentd_client.conf:/fluentd/etc/fluent.conf -v $(pwd)/test/json.log:/fluentd/log/json.log --name fluent_test elk_fluentd
php ./test/generate.php >> json.log
#获取所有角色
http://192.168.10.191:9200/_security/role
#获取所有其中一个角色
http://192.168.10.191:9200/_security/role/fluentd
#获取所有用户
http://192.168.10.191:9200/_security/user
#获取所有其中一个用户
http://192.168.10.191:9200/_security/user/fluentd
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least
解决方案:执行命令: sysctl -w vm.max_map_count=262144
{"type":"log","@timestamp":"2020-08-13T01:57:03Z","tags":["warning","plugins","licensing"],"pid":6,"message":"License information could not be obtained from Elasticsearch due to [security_exception] missing authentication credentials for REST request [/_xpack], with { header={ WWW-Authenticate=\"Basic realm=\\\"security\\\" charset=\\\"UTF-8\\\"\" } } :: {\"path\":\"/_xpack\",\"statusCode\":401,\"response\":\"{\\\"error\\\":{\\\"root_cause\\\":[{\\\"type\\\":\\\"security_exception\\\",\\\"reason\\\":\\\"missing authentication credentials for REST request [/_xpack]\\\",\\\"header\\\":{\\\"WWW-Authenticate\\\":\\\"Basic realm=\\\\\\\"security\\\\\\\" charset=\\\\\\\"UTF-8\\\\\\\"\\\"}}],\\\"type\\\":\\\"security_exception\\\",\\\"reason\\\":\\\"missing authentication credentials for REST request [/_xpack]\\\",\\\"header\\\":{\\\"WWW-Authenticate\\\":\\\"Basic realm=\\\\\\\"security\\\\\\\" charset=\\\\\\\"UTF-8\\\\\\\"\\\"}},\\\"status\\\":401}\",\"wwwAuthenticateDirective\":\"Basic realm=\\\"security\\\" charset=\\\"UTF-8\\\"\"} error"}
解决方案:在kibana配置账户信息
2020-09-14 08:37:11 +0000 [warn]: #0 failed to flush the buffer. retry_time=1 next_retry_seconds=2020-09-14 08:37:12 +0000 chunk="5af41f0aa1db3bef7795533234cac3ff" error_class=Fluent::Plugin::ElasticsearchOutput::RecoverableRequestFailure error="could not push logs to Elasticsearch cluster ({:host=>\"es\", :port=>9200, :scheme=>\"http\", :user=>\"fluentd\", :password=>\"obfuscated\"}): [403] {\"error\":{\"root_cause\":[{\"type\":\"security_exception\",\"reason\":\"action [indices:data/write/bulk] is unauthorized for user [fluentd]\"}],\"type\":\"security_exception\",\"reason\":\"action [indices:data/write/bulk] is unauthorized for user [fluentd]\"},\"status\":403}"
解决方案:创建的fluentd角色权限不对;把索引权限设置为*,操作权限为all
warning: 299 Elasticsearch-7.8.1-b5ca9c58fb664ca8bf9e4057fc229b3396bf3a89 "[types removal] Specifying types in bulk requests is deprecated."
解决方案:根据官网的教程下载的fluent-plugin-elasticsearch是3.5.2;将插件升级到4.1.1然再添加配置
suppress_type_name true