Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kibana: Search within text for string

I have A log message in Kibana that contains this:

org.hibernate.exception.GenericJDBCException: Cannot open connection
at org.springframework.orm.hibernate3.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:597)

Actual search that isn't returning results: log_message: "hibernate3"

If I search for "hibernate3" this message will not appear. I am using an Elasticsearch template and have indexed the field, but also want to be able to do case-insensitive full-text searching. Is this possible?

Template that is in use:

{
"template": "filebeat-*",
"mappings": {
    "mainProgram": {
        "properties": {
            "@timestamp": {
                "type": "date",
                "format": "strict_date_optional_time||epoch_millis"
            },
            "@version": {
                "type": "text"
            },
            "beat": {
                "properties": {
                    "hostname": {
                        "type": "text"
                    },
                    "name": {
                        "type": "text"
                    }
                }
            },
            "class_method": {
                "type": "text",
                "fielddata": "true",
                "index": "true"
            },
            "class_name": {
                "type": "text",
                "fielddata": "true"
            },
            "clientip": {
                "type": "ip",
                "index": "not_analyzed"
            },
            "count": {
                "type": "long"
            },
            "host": {
                "type": "text",
                "index": "not_analyzed"
            },
            "input_type": {
                "type": "text",
                "index": "not_analyzed"
            },
            "log_level": {
                "type": "text",
                "fielddata": "true",
                "index": "true"
            },
            "log_message": {
                "type": "text",
                "index": "true"
            },
            "log_timestamp": {
                "type": "text"
            },
            "log_ts": {
                "type": "long",
                "index": "not_analyzed"
            },
            "message": {
                "type": "text"
            },
            "offset": {
                "type": "long",
                "index": "not_analyzed"
            },
            "query_params": {
                "type": "text",
                "index": "true"
            },
            "sessionid": {
                "type": "text",
                "index": "true"
            },
            "source": {
                "type": "text",
                "index": "not_analyzed"
            },
            "tags": {
                "type": "text"
            },
            "thread": {
                "type": "text",
                "index": "true"
            },
            "type": {
                "type": "text"
            },
            "user_account_combo": {
                "type": "text",
                "index": "true"
            },
            "version": {
                "type": "text"
            }
        }
    },
    "access": {
        "properties": {
            "@timestamp": {
                "type": "date",
                "format": "strict_date_optional_time||epoch_millis"
            },
            "@version": {
                "type": "text"
            },
            "beat": {
                "properties": {
                    "hostname": {
                        "type": "text"
                    },
                    "name": {
                        "type": "text"
                    }
                }
            },
            "clientip": {
                "type": "ip",
                "index": "not_analyzed"
            },
            "count": {
                "type": "long",
                "index": "not_analyzed"
            },
            "host": {
                "type": "text",
                "index": "true"
            },
            "input_type": {
                "type": "text",
                "index": "not_analyzed"
            },
            "log_timestamp": {
                "type": "text"
            },
            "log_ts": {
                "type": "long",
                "index": "not_analyzed"
            },
            "message": {
                "type": "text"
            },
            "offset": {
                "type": "long",
                "index": "not_analyzed"
            },
            "query_params": {
                "type": "text",
                "index": "true"
            },
            "response_time": {
                "type": "long"
            },
            "sessionid": {
                "type": "text",
                "index": "true"
            },
            "source": {
                "type": "text",
                "index": "not_analyzed"
            },
            "statuscode": {
                "type": "long"
            },
            "tags": {
                "type": "text"
            },
            "thread": {
                "type": "text",
                "index": "true"
            },
            "type": {
                "type": "text",
                "index": "true"
            },
            "uripath": {
                "type": "text",
                "index": "true"
            },
            "user_account_combo": {
                "type": "text",
                "index": "true"
            },
            "verb": {
                "type": "text",
                "index": "true"
            }
        }
    }
}
}
like image 901
A_Elric Avatar asked Feb 28 '17 17:02

A_Elric


People also ask

How do I search for a specific string in Kibana?

To search for an exact string, you need to wrap the string in double quotation marks. Without quotation marks, the search in the example would match any documents containing one of the following words: "Cannot" OR "change" OR "the" OR "info" OR "a" OR "user". Kibana allows you to search specific fields.

How do I filter transactions in Kibana?

In Kibana, you can filter transactions either by entering a search query or by clicking on elements within a visualization.

How do I use regular expression in Kibana?

Kibana supports regular expression for filters and expressions. For example, to search for all HTTP responses with JSON as the returned value type: http.response_headers.content_type: *json. See Elasticsearch regexp query for more details about the syntax.

How to search for a string in a text file?

If a file is large, use the mmap to search a string in a file. We don’t need to read the whole file in memory, which will make our solution memory efficient. We will see each solution one by one. Use the file read () method and string class find () method to search for a string in a text file. Here are the steps.


2 Answers

message: *.hibernate3.*

also works (please note, that no quotes are needed for that)

like image 152
Ilya Yevlampiev Avatar answered Oct 08 '22 13:10

Ilya Yevlampiev


According to your scenario, what you're looking for is an analyzed type string which would first analyze the string and then index it. A quote from the doc.

In other words, index this field as full text.

Thus make sure that, you have your mapping of the necessary fields properly so that you'll be able to do a full-text search on the docs.

Assuming that, in Kibana if the log line is under the field message, you could simply search for the word by:

message:"hibernate3"

You might also want to refer this, to identify the variance between Term Based and Full-Text.

EDIT

Have the mapping of the field log_message as such:

"log_message": {
       "type": "string", <- to make it analyzed
       "index": "true"
}

Also try doing a wildcard search as such:

{"wildcard":{"log_message":"*.hibernate3.*"}}
like image 34
Kulasangar Avatar answered Oct 08 '22 11:10

Kulasangar