# Search Substring of Log Text Field

**URL:** <https://discuss.elastic.co/t/search-substring-of-log-text-field/267576>\
**Category:** Kibana\
**Created:** [March 17, 2021, 8:40pm UTC](https://discuss.elastic.co/t/search-substring-of-log-text-field/267576 "2021-03-17T20:40:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![MCDELTAT](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mcdeltat/32/78953_2.png) [@MCDELTAT](https://discuss.elastic.co/u/MCDELTAT)\
**Post date:** [March 17, 2021, 8:40pm UTC](https://discuss.elastic.co/t/search-substring-of-log-text-field/267576/1 "2021-03-17T20:40:47Z")

</div>

I know this has been asked a million times, but none of the solutions seem to work. I'm trying to filter for a specific, reproducible error, to find out how long it had been going on. I have the following thus far for KQL to find logs for errors in a specific microservice

```auto
service.name : "benefits" and level: "ERROR"

```

The error I'm looking for is:

```auto
System.NullReferenceException: Object reference not set to an instance of an object.
at System.IdentityModel.Tokens.JwtPayload.get_Claims()
at System.IdentityModel.Tokens.JwtSecurityToken.get_Claims()
at <obfuscated>.OwinRestService.Host.Services.TokenIdentificationService.GetIdentification(JwtSecurityToken jwt, IOwinContext context)
at <obfuscated>.OwinRestService.Host.Extensions.OwinContextExtensions.CreateContextDto(IOwinContext context, IContextIdentificationService contextIdentifierService, ILogger logger)
at <obfuscated>.OwinRestService.Host.Middlewares.RequestContextMiddleware.<Invoke>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at <obfuscated>.OwinRestService.Host.Middlewares.ExceptionHandlingMiddleware.<Invoke>d__4.MoveNext()

```

The Kibana KQL box autosuggests a query with the full string, but using it's own autosuggestion, nothing comes up. Hoping to try just a substring I changed my query to

```auto
service.name : "benefits" and level: "ERROR" and exception:"System.NullReferenceException"

```

Nothing. I've tried it without the quotes, with the :\* operator, all forms of combinations but nothing comes up. How can I query for just a substring or something unique to this error log.

---

<div class="post-metadata">

**Author:** ![AClerk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aclerk/32/55297_2.png) [@AClerk](https://discuss.elastic.co/u/AClerk)\
**Post date:** [March 18, 2021, 3:41am UTC](https://discuss.elastic.co/t/search-substring-of-log-text-field/267576/2 "2021-03-18T03:41:59Z")

</div>

Use [wildcard](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-wildcard-query.html) query.

---

<div class="post-metadata">

**Author:** ![MCDELTAT](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mcdeltat/32/78953_2.png) [@MCDELTAT](https://discuss.elastic.co/u/MCDELTAT)\
**Post date:** [March 22, 2021, 3:54pm UTC](https://discuss.elastic.co/t/search-substring-of-log-text-field/267576/3 "2021-03-22T15:54:07Z")

</div>

Thanks. The bare minimum requirements to match that substring look like this.

```auto
GET /filebeat-7.6.1-*/_search
{
  "query": {
    "wildcard": {
      "exception": {
        "value": "System.NullReferenceException*"
      }
    }
  }
}

```

However, I'm still looking into how to better filter with the other conditions that I already had in place and will report back when a more advanced example can be provided.

---

<div class="post-metadata">

**Author:** ![AClerk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aclerk/32/55297_2.png) [@AClerk](https://discuss.elastic.co/u/AClerk)\
**Post date:** [March 23, 2021, 12:08am UTC](https://discuss.elastic.co/t/search-substring-of-log-text-field/267576/4 "2021-03-23T00:08:54Z")

</div>

You can add more/other constraints to your query.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 20, 2021, 12:09am UTC](https://discuss.elastic.co/t/search-substring-of-log-text-field/267576/5 "2021-04-20T00:09:02Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
