Grafana分析Nginx日志

按日期对ES的index进行分割:html

logstash配置:nginx

input{ file{ path => "/home/hottopic/logs/trend-shotting-api/metric/*" type => "trend-shotting-api-metric" start_position => "beginning" codec => json { charset => "UTF-8" } } } output{ if [type] == "trend-shotting-api-metric" { elasticsearch { hosts=> ["172.17.213.60:9200"] index=> "trend-shotting-api-metrick.%{+YYYY-MM}" } } }

grafana源配置:(注意日期格式要统一,好比YYYY-MM或YYYY.MM)json

 


 

配置Groub by -Terms时报错,提示须要设置fielddata=true,报错内容大概以下: api

"Fielddata is disabled on text fields by default ... "app

 

解决方法以下:curl

https://www.elastic.co/guide/en/elasticsearch/reference/current/fielddata.html#_fielddata_is_disabled_on_literal_text_literal_fields_by_defaultelasticsearch

curl -X PUT "localhost:9200/nginx/_mapping/doc" -H 'Content-Type: application/json' -d' { "properties": { "xforward": { "type":     "text", "fielddata": true } } } '

 

操做后仍然报错,因而ide

curl -X PUT "localhost:9200/nginx/_mapping/doc?update_all_types" -H 'Content-Type: application/json' -d'         
{ "properties": { "xforward": { "type":     "text", "fielddata": true } } } '

以上nginx为index名称  xforward为字段名称。ui

修改完后查看结果显示已修改为功url

 返回到Grafana进行再一次设置

 

修改为功后,能够正常出图。

相关文章
相关标签/搜索