# Share your LEQL query tips and tricks!

**URL:** <https://discuss.rapid7.com/t/share-your-leql-query-tips-and-tricks/12126>\
**Category:** Log Search\
**Tags:** queries\
**Created:** [May 9, 2022, 6:03pm UTC](https://discuss.rapid7.com/t/share-your-leql-query-tips-and-tricks/12126 "2022-05-09T18:03:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jordan\_bacher](https://discuss.rapid7.com/letter_avatar_proxy/v4/letter/j/7c8e57/32.png) [@jordan\_bacher](https://discuss.rapid7.com/u/jordan_bacher)\
**Post date:** [May 9, 2022, 6:03pm UTC](https://discuss.rapid7.com/t/share-your-leql-query-tips-and-tricks/12126/1 "2022-05-09T18:03:42Z")

</div>

Within InsightIDR, you can use LEQL queries to search through your logs, create custom alerts, and power your dashboards. With so many different uses for LEQL, the Rapid7 team is looking into how we can make LEQL easier to use all around and we want to hear about the different ways that you use LEQL.

- What are some LEQL queries that you have been using frequently?
- What does querying help you to accomplish?
- What types of LEQL queries would you like to see included in InsightIDR?
- Is there anything that has tripped you up while using LEQL?
- Do you have any tips for new LEQL users?

---

<div class="post-metadata">

**Author:** ![mbabinski](https://discuss.rapid7.com/user_avatar/discuss.rapid7.com/mbabinski/32/938_2.png) [@mbabinski](https://discuss.rapid7.com/u/mbabinski)\
**Post date:** [May 10, 2022, 5:49pm UTC](https://discuss.rapid7.com/t/share-your-leql-query-tips-and-tricks/12126/2 "2022-05-10T17:49:19Z")

</div>

Here’s a handy query I’ve used for identifying Private IPs:  
`where(source_ip = IP(192.168.0.0/16) OR source_ip = IP(172.16.0.0/12) OR source_ip = IP(10.0.0.0/8) OR source_ip = IP(169.254.0.0/16))`

Reverse the logic above to get public IPs.

One cool improvement (just brainstorming here) to LEQL and the log search experience would be the ability to create and save user-defined functions that could be used elsewhere in the app. Something like:  
`define_function(is_private_ip(ip_address) where(ip_address= IP(192.168.0.0/16) OR ip_address= IP(172.16.0.0/12) OR ip_address= IP(10.0.0.0/8) OR ip_address = IP(169.254.0.0/16))`

Then you could write the query above like:  
`where(is_private_ip(source_ip))`

Micah

---

<div class="post-metadata">

**Author:** ![holly\_wilsey](https://discuss.rapid7.com/user_avatar/discuss.rapid7.com/holly_wilsey/32/78_2.png) [@holly\_wilsey](https://discuss.rapid7.com/u/holly_wilsey)\
**Post date:** [November 2, 2022, 7:01pm UTC](https://discuss.rapid7.com/t/share-your-leql-query-tips-and-tricks/12126/3 "2022-11-02T19:01:17Z")

</div>


