# Regex Query to extract a number

**URL:** <https://discuss.elastic.co/t/regex-query-to-extract-a-number/160617>\
**Category:** Elasticsearch\
**Created:** [December 12, 2018, 8:32pm UTC](https://discuss.elastic.co/t/regex-query-to-extract-a-number/160617 "2018-12-12T20:32:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arnav\_Bose](https://avatars.discourse-cdn.com/v4/letter/a/ce73a5/32.png) [@Arnav\_Bose](https://discuss.elastic.co/u/Arnav_Bose)\
**Post date:** [December 12, 2018, 8:32pm UTC](https://discuss.elastic.co/t/regex-query-to-extract-a-number/160617/1 "2018-12-12T20:32:38Z")

</div>

I am new to ES. I have a log message coming and I want to extract some field:

{"msg":"Certificate is going to expire in 1088 Regenerate the same","days\_left":1088}

I would like to check if the date is less than 60. Is there any way this can be handled using any regex query?

---

<div class="post-metadata">

**Author:** ![chandra0651](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chandra0651/32/30484_2.png) [@chandra0651](https://discuss.elastic.co/u/chandra0651)\
**Post date:** [December 12, 2018, 8:43pm UTC](https://discuss.elastic.co/t/regex-query-to-extract-a-number/160617/2 "2018-12-12T20:43:18Z")

</div>

At first you need to save the day\_left as a field in ES document and later you can use the range query in ES to check the condition

---

<div class="post-metadata">

**Author:** ![Arnav\_Bose](https://avatars.discourse-cdn.com/v4/letter/a/ce73a5/32.png) [@Arnav\_Bose](https://discuss.elastic.co/u/Arnav_Bose)\
**Post date:** [December 12, 2018, 9:20pm UTC](https://discuss.elastic.co/t/regex-query-to-extract-a-number/160617/3 "2018-12-12T21:20:53Z")

</div>

Will it not work without having it in the document? This whole json is coming in Kibana as part of only the log message. if I search for "days\_left: 1088" I get the desired field. But the value will change tomorrow. So, I cannot hardcode my search string.

---

<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:** [January 9, 2019, 9:33pm UTC](https://discuss.elastic.co/t/regex-query-to-extract-a-number/160617/4 "2019-01-09T21:33:26Z")

</div>

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