# How to write queries to pull a specific data in ELK

**URL:** https://discuss.elastic.co/t/how-to-write-queries-to-pull-a-specific-data-in-elk/349481
**Category:** Kibana
**Tags:** kql-kibana-query-language
**Created:** [December 16, 2023, 4:30am UTC](https://discuss.elastic.co/t/how-to-write-queries-to-pull-a-specific-data-in-elk/349481 "2023-12-16T04:30:00Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Kumbum](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kumbum/32/124254_2.png) [@Kumbum](https://discuss.elastic.co/u/Kumbum)
#### Post date: [December 16, 2023, 4:30am UTC](https://discuss.elastic.co/t/how-to-write-queries-to-pull-a-specific-data-in-elk/349481/1 "2023-12-16T04:30:00Z")

</div>

Hi Team,

How to write queries to pull specific information in the custom dashboards. I want to pull specific information in the drop-down list in the custom dashboard.

I was able to create a drop-down list(control type) in the custom dashboard but was unable to see accurate details in the drop-down list. I have through some articles. They say queries may give accurate data but I am new to ELK and don't know how to write them. I am looking for some useful material related this.

---

<div class="post-metadata">

### Author: ![Priscilla\_Parodi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/priscilla_parodi/32/43047_2.png) [@Priscilla\_Parodi](https://discuss.elastic.co/u/Priscilla_Parodi)
#### Post date: [January 2, 2024, 7:57pm UTC](https://discuss.elastic.co/t/how-to-write-queries-to-pull-a-specific-data-in-elk/349481/2 "2024-01-02T19:57:04Z")

</div>

Hello @Kumbum,

Could you please share which version you are using? (you can check in Stack Management). Additionally, more details on what you mean by accurate data would be helpful. What would be considered specific information in this case?

---

<div class="post-metadata">

### Author: ![Kumbum](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kumbum/32/124254_2.png) [@Kumbum](https://discuss.elastic.co/u/Kumbum)
#### Post date: [January 2, 2024, 9:14pm UTC](https://discuss.elastic.co/t/how-to-write-queries-to-pull-a-specific-data-in-elk/349481/3 "2024-01-02T21:14:22Z")

</div>

@Priscilla_Parodi  
I use Filebeat to stream the logs to ELK. The version is 7.17.11  
Yes, a specific information.

---

<div class="post-metadata">

### Author: ![Priscilla\_Parodi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/priscilla_parodi/32/43047_2.png) [@Priscilla\_Parodi](https://discuss.elastic.co/u/Priscilla_Parodi)
#### Post date: [January 5, 2024, 9:07pm UTC](https://discuss.elastic.co/t/how-to-write-queries-to-pull-a-specific-data-in-elk/349481/4 "2024-01-05T21:07:01Z")

</div>

> [@Kumbum](#):
>
> They say queries may give accurate data

You mean by filtering, correct?

You can use the [Kibana Query Language (KQL)](https://www.elastic.co/guide/en/kibana/7.17/kuery-query.html) for filtering data:

 ![Screen Shot 2024-01-05 at 4.01.24 PM](https://us1.discourse-cdn.com/elastic/original/3X/4/0/408be16b327d5afdcceb339035076069d6ee7205.png)

Or you can edit as a [query DSL](https://www.elastic.co/guide/en/elasticsearch/reference/7.17/query-dsl.html):

 ![Screen Shot 2024-01-05 at 4.00.02 PM](https://us1.discourse-cdn.com/elastic/original/3X/b/9/b9f9b8d4cc298f3caf00047048c63c5733e267fa.jpeg)

---

<div class="post-metadata">

### Author: ![Kumbum](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kumbum/32/124254_2.png) [@Kumbum](https://discuss.elastic.co/u/Kumbum)
#### Post date: [January 6, 2024, 6:03am UTC](https://discuss.elastic.co/t/how-to-write-queries-to-pull-a-specific-data-in-elk/349481/5 "2024-01-06T06:03:56Z")

</div>

@Priscilla_Parodi

Let me give a brief background about this. I have a program that creates a log file once a day. It contains the following information. And, the filebeat has been configured to push these logs as follows to ELK. Now, I want to create a custom dashboard to display the following metrics on it.

**Log\_01052024.log** - Every day a new log gets generated by the program. The following are the sample details.

LOG\_LEVELS, TIMESTAMP, USER, DESCRIPTION, Otherinformation  
INFO, 01/05/2024 23:00:00, USER1, "Task Started", ""  
INFO, 01/05/2024 23:00:10, USER1, "Deployment is successful", "CHG123"  
INFO, 01/05/2024 23:00:20, USER1, "Task Ended", ""  
INFO, 01/05/2024 23:00:30, USER1, "Task Started", ""  
INFO, 01/05/2024 23:00:40, USER1, "Deployment is successful", "CHG456"  
INFO, 01/05/2024 23:00:50, USER1, "Task Ended", ""  
INFO, 01/05/2024 23:01:00, USER1, "Task Started", ""  
INFO, 01/05/2024 23:01:10, USER1, "Deployment is unsuccessful", "CHG789"  
INFO, 01/05/2024 23:01:20, USER1, "Task Ended", ""  
.  
.  
.  
so on

This is how the data shows in ELK. Because I have added a script in filebeat.yaml file to split the log details.

Entry 1  
LOG\_LEVELS : INFO  
TIMESTAMP : 01/05/2024 23:10:00  
USER. : USER1  
DESCRIPTION : "Task Started"  
Otherinformation : ""

Entry 2  
LOG\_LEVELS : INFO  
TIMESTAMP : 01/05/2024 23:00:00  
USER. : USER1  
DESCRIPTION : "Deployment is successful"  
Otherinformation : "CHG123"

Entry 3  
LOG\_LEVELS : INFO  
TIMESTAMP : 01/05/2024 23:20:00  
USER. : USER1  
DESCRIPTION : "Task Ended"  
Otherinformation : ""  
.  
.  
So on

I want to pull the following details on the dashboard.

* * *

## |Metric 1 | Metric 2| |Metric 3 | |

Metric 1: Total number deployments : 3  
Metric 2: Total number of success and fail deployment :  
Deployment is successful: 2  
Deployment is unsuccessful: 1  
Metric 3:  
CHG123 : Deployment is successful  
CHG456 : Deployment is successful  
CHG789 : Deployment is unsuccessful  
.  
.  
so on.

I hope this is very clear to you now. I was creating visualization for these but was unable to pull metrics how I wanted to show. Please help me with how this can accomplished.

---

<div class="post-metadata">

### Author: ![Priscilla\_Parodi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/priscilla_parodi/32/43047_2.png) [@Priscilla\_Parodi](https://discuss.elastic.co/u/Priscilla_Parodi)
#### Post date: [January 8, 2024, 8:28pm UTC](https://discuss.elastic.co/t/how-to-write-queries-to-pull-a-specific-data-in-elk/349481/6 "2024-01-08T20:28:36Z")

</div>

Thanks for the additional info. Are you already able to visualize these logs in Kibana?

Filebeat comes packaged with example dashboards (and visualizations) for visualizing Filebeat data. You need to [config the dashboard loading](https://www.elastic.co/guide/en/beats/filebeat/7.17/configuration-dashboards.html#configuration-dashboards). And before you can use the dashboards, you need to [create an index pattern](https://www.elastic.co/guide/en/kibana/7.17/index-patterns.html), `filebeat-*`.

Now, if you've already done that and your question is only about different types of visualization, you probably want to check [TSVB](https://www.elastic.co/guide/en/kibana/7.17/tsvb.html#tsvb) and [aggregation-based visualizations](https://www.elastic.co/guide/en/kibana/7.17/add-aggregation-based-visualization-panels.html), 'metric' is a good one here, if you’re unsure about the visualization type [Lens](https://www.elastic.co/guide/en/kibana/7.17/lens.html) is a good option, it will provide some suggestions based on the data.

---

<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: [February 5, 2024, 8:29pm UTC](https://discuss.elastic.co/t/how-to-write-queries-to-pull-a-specific-data-in-elk/349481/7 "2024-02-05T20:29:13Z")

</div>

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