elastic search log configuration is not working - elasticsearch

I tried to enable logs in the elastic search server using the below link
https://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules-slowlog.html
I verified my index setting using the url
http://localhost:9200/_all/_settings
The result is below
{"myindex":{"settings":{"index":{"search":{"slowlog":{"threshold":{"fetch":{"warn":"1ms","trace":"1ms","debug":"1ms","info":"1ms"},"query":{"warn":"1ms","trace":"1ms","debug":"1ms","info":"1ms"}}}},"number_of_shards":"3","provided_name":"occindex","creation_date":"1508319257925","number_of_replicas":"2","uuid":"dVAWgk62Sgivzr2B_OuCzA","version":{"created":"5040399"}}}}}
As per the document, I expect the logs to be populated when the threshold is breached.
I have set 1 ms as the threshold in order to log all queries that are hitting elastic search
I observed that under logs folder , the log files elasticsearch_index_search_slowlog.log and elasticsearch.log does not show the queries which are hitting elastic search.
Let me know if my configuration is correct.

The log worked after I inserted one record.
If you fire the query when there are no records in the index , the log was not updated

Related

Elasticsearch queries in kibana

I want to log all the queries made to Elasticsearch along with their response bodies in kibana.
Is there a way to do that?
I came to know a way to set. t he slowlogs threshold to 0 and log all the queries i slowlogs and then use filebeat to push those queries to kibana.
Is there any other way to do that
As far as I know, this is not available atleast in basic and free version and even if you set search slowlog threshold to 0ms it will just log the search query and other metadata of search query but wouldn't log the search query response.
It would be better to do this in your application which generated the search query and parse the response, then using filebeat you can send the application logs to Elasticsearch.

How to create a Grafana dashboard from ElasticSearch logs

I have connected grafana to an elasticsearch data source. The goal is to create metric dashboards out of elastic search logs. I have two lucene queries in grafana. The first query retrieves all logs in the specified log path
log.file.path:\/data\/gitlab\/logs\/gitlab-rails\/release_job_logs.json AND fields.environment:production
The second query retrieves logs in the specified path that has a ‘success’ value in the json.job_status field
log.file.path:\/data\/gitlab\/logs\/gitlab-rails\/release_job_logs.json AND fields.environment:production AND json.job_status:success
I will like to create a dashboard that creates a percentage of the logs with a ‘success’ value in the json.job_status field.
So essentially if the first query gives me a count of 100 and the second query gives a count of 90 then the dashboard should display 90%. Which will mean 90% of all logs have a json.job_status:success
The image below shows what I have now from the two queries above. How do I get a percentage dashboard

Most popular search phrases in an elasticsearch index

Is it possible to see which are the most popular searched phrases/words within a particular index in elasticsearch.
Can this be set up in kibana at all.
You can do that by using Search Slow log - https://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules-slowlog.html
You can set the slow log setting dynamically too. Once this is set you should see the logs in index_search_slowlog.log. Ingest these logs back to elasticsearch and visualize in kibana. You can create the dashboard from this data.
We use these slow logs to monitor slow queries, popular queries etc.

Kibana Logstash ElasticSearch | Unindexed fields cannot be searched

I am exploring ELK stack and coming across an issue.
I have generated logs, forwarded the logs to logstash, logs are in JSON format so they are pushed directly into ES with only JSON filter in Logstash config, connected and started Kibana pointing to the ES.
Logstash Config:
filter {
json {
source => "message"
}
Now I have indexes created for each day's log and Kibana happily shows all of the logs from all indexes.
My issue is: there are many fields in logs which are not enabled/indexed for filtering in Kibana. When I try to add them to the filer in Kibana, it says "unindexed fields cannot be searched".
Note: these are not sys/apache log. There are custom logs in JSON format.
Log format:
{"message":"ResponseDetails","#version":"1","#timestamp":"2015-05-23T03:18:51.782Z","type":"myGateway","file":"/tmp/myGatewayy.logstash","host":"localhost","offset":"1072","data":"text/javascript","statusCode":200,"correlationId":"a017db4ebf411edd3a79c6f86a3c0c2f","docType":"myGateway","level":"info","timestamp":"2015-05-23T03:15:58.796Z"}
fields like 'statusCode', 'correlationId' are not getting indexed. Any reason why?
Do I need to give a Mapping file to ES to ask it to index either all or given fields?
You've updated the Kibana field list?
Kibana.
Settings.
Reload field list.
Newer version:
Kibana.
Management.
Refresh icon on the top right.
As of 6.4.0:
The warning description puts it very simply:
Management > Index Patterns > Select your Index > Press the refresh button in the top right corner.
If you try to refresh and you can't solve it try to change index.blocks.write: "false"
enter image description here

Seeing latest results in Kibana after the page limit is reached

I am new to logstash. I have set up my logstash to populate elastic search and have Kibana read out of it. The problem I am facing is that after the
number of records = results per page x page limit
the UI stops getting new results. Is there a way to set Kibana up such that it discards the old results instead of the latest after the limit is reached?
To have kibana read the latest results, reload the query.
To have more pages available (or more results per page), edit the panel.
Make sure the table is reverse sorted by #timestamp.

Resources