Search code examples
elasticsearchpacketbeat

Changing field properties


I am using packetbeat to monitor mysql port on 3306 and it is working very well. I can easily search for any word on discovery tab. For e.g.

method:SET

This works as expected. But If I change it to

query:SET

then it does not return the documents with the word "SET" in query field. Is the query field indexed differently? How do I make "query" field searchable?


Update:

Is this because of parameter "ignore_above" that is used for all string fields? I checked the mapping using this API...

GET /packetbeat-2018.02.01/_mapping/mysql/

How do I remove this restriction and make all future beats to index query field?


Update 2:

If I mention the entire string in the search based on "query" field, it works as expected...

query:"SELECT name, type, comment FROM mysql.proc WHERE name like 'residentDetails_get' and db <=> 'portal' ORDER BY name, type"

This returns all 688 records in the last 15 minutes. When I search the following, I expect to get more...

query:"SELECT"

But I do not get a single record. I guess this is because the way document is indexed. I will prefer to get back equivalent of SQL : query like '%SELECT%'


Solution

  • The query field of packetbeat is declared as "keyword". Therefore you can search the entire query only. For e.g.

    query: "select * from mytable"
    

    But what if we need to search for query: "mytable" ? You need to make the query field searchable by modifying fields.yml file. Add the type:text parameter to query field of MySQL section of fields.yml file found in /etc/packetbeat

    The relevant section of the file will look like this...

    - name: query
      type: text
      description: >
        The query in a human readable format. For HTTP, it will typically be
        something like `GET /users/_search?name=test`. For MySQL, it is
        something like `SELECT id from users where name=test`.