# How to index a log content in order to filter a specific field?

**URL:** <https://discuss.elastic.co/t/how-to-index-a-log-content-in-order-to-filter-a-specific-field/357645>\
**Category:** Elastic Observability\
**Created:** [April 17, 2024, 5:29pm UTC](https://discuss.elastic.co/t/how-to-index-a-log-content-in-order-to-filter-a-specific-field/357645 "2024-04-17T17:29:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Helder\_Versatti](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/helder_versatti/32/133611_2.png) [@Helder\_Versatti](https://discuss.elastic.co/u/Helder_Versatti)\
**Post date:** [April 17, 2024, 5:29pm UTC](https://discuss.elastic.co/t/how-to-index-a-log-content-in-order-to-filter-a-specific-field/357645/1 "2024-04-17T17:29:45Z")

</div>

Hi guys,

I have a python application that raise logs in the json format, find example below:

```auto
{
    "levelname": "INFO",
    "message": "REQUEST STARTED",
    "name": "requests_middleware.middlewares", 
}

```

I was wondering if is it possible map those json fields from my logs to a kibana indexes, in order to be possible select the visualization of specific fields.

For example, in the image below, I can select message as a field of my log, I would like to filter the information inside of my log

 ![kibana](https://us1.discourse-cdn.com/elastic/original/3X/3/6/364c397e68732891c08662e5a4e01f374d8ed3bd.png)

---

<div class="post-metadata">

**Author:** ![adword](https://avatars.discourse-cdn.com/v4/letter/a/96bed5/32.png) [@adword](https://discuss.elastic.co/u/adword)\
**Post date:** [April 17, 2024, 6:36pm UTC](https://discuss.elastic.co/t/how-to-index-a-log-content-in-order-to-filter-a-specific-field/357645/2 "2024-04-17T18:36:44Z")

</div>

> [@Helder\_Versatti](#):
>
> I was wondering if is it possible map those json fields from my logs to a kibana indexes, in order to be possible select the visualization of specific fields.
> 
> For example, in the image below, I can select message as a field of my log, I would like to filter the information inside of my log

[Install `elasticsearch` library (`pip install elasticsearch`).  
Send logs directly:

from elasticsearch import Elasticsearch

es = Elasticsearch([{'host': 'localhost', 'port': 9200}]) # Update host/port if needed

log\_data = {"levelname": "INFO", "message": "REQUEST STARTED  
, "name": "middleware"}  
es.index(index="logs", body=log\_data) # Index named "logs"]

Create an index pattern (optional but recommended): `logs-*`  
Go to Discover tab[.](https://alightmotionsapps.com/)  
Select index pattern (if created).  
Visualize/filter using the Kibana interface:  
Visualize fields (Terms, Histogram, etc.)  
Filter logs by fields (search bar)
