# Logstash get field from elasticsearch message

**URL:** https://discuss.elastic.co/t/logstash-get-field-from-elasticsearch-message/114325
**Category:** Logstash
**Created:** [January 5, 2018, 6:34pm UTC](https://discuss.elastic.co/t/logstash-get-field-from-elasticsearch-message/114325 "2018-01-05T18:34:35Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![faoc](https://avatars.discourse-cdn.com/v4/letter/f/c2a13f/32.png) [@faoc](https://discuss.elastic.co/u/faoc)
#### Post date: [January 5, 2018, 6:34pm UTC](https://discuss.elastic.co/t/logstash-get-field-from-elasticsearch-message/114325/1 "2018-01-05T18:34:35Z")

</div>

Hi,

I have this message on ElasticSearch  
{  
"\_index": "audit\_201712",  
"\_type": "ccc",  
"\_id": "AWAsoVnydQqBAYNwSrNi",  
"\_score": null,  
"\_source": {  
"resourceType": "AuditEvent",  
"id": "4306b213-65a2-4ae1-b7e6-d1221fac321a",  
"type": {  
"system": "[http://hl7.org/fhir/audit-event-type](http://hl7.org/fhir/audit-event-type)",  
"code": "rest",  
"display": "RESTful Operation"  
},  
"outcome": "2",  
"outcomeDesc": "Accepted",  
"agent": [  
{  
"name":"test"  
"role": [  
{  
"coding": [  
{  
"system": "[http://hl7.org/fhir/v3/ParticipationType](http://hl7.org/fhir/v3/ParticipationType)",  
"code": "AUT",  
"display": "author (originator)"  
}  
]  
}  
]  
]  
}

Im using logstash to get data from ElasticSearch and save data (using logstash-output-jdbc) on mysql.  
How can i, using logstash, get for example the field in \_source.outcome or \_source.agent[0].name?

---

<div class="post-metadata">

### Author: ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)
#### Post date: [January 6, 2018, 4:35pm UTC](https://discuss.elastic.co/t/logstash-get-field-from-elasticsearch-message/114325/2 "2018-01-06T16:35:37Z")

</div>

If you use an elasticsearch input the whole contents of `_source` will be available to filters and outputs. Without specifics on what you want to do I can't give a more specific answer.

---

<div class="post-metadata">

### Author: ![faoc](https://avatars.discourse-cdn.com/v4/letter/f/c2a13f/32.png) [@faoc](https://discuss.elastic.co/u/faoc)
#### Post date: [January 6, 2018, 7:30pm UTC](https://discuss.elastic.co/t/logstash-get-field-from-elasticsearch-message/114325/3 "2018-01-06T19:30:44Z")

</div>

thank you.  
i just want get the value of specific fields to add them on mysql insert statement... but I was not getting the value of the fields, because i didnt know the syntax ...

---

<div class="post-metadata">

### Author: ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)
#### Post date: [January 6, 2018, 9:05pm UTC](https://discuss.elastic.co/t/logstash-get-field-from-elasticsearch-message/114325/4 "2018-01-06T21:05:12Z")

</div>

[https://www.elastic.co/guide/en/logstash/current/event-dependent-configuration.html#logstash-config-field-references](https://www.elastic.co/guide/en/logstash/current/event-dependent-configuration.html#logstash-config-field-references)

---

<div class="post-metadata">

### Author: ![faoc](https://avatars.discourse-cdn.com/v4/letter/f/c2a13f/32.png) [@faoc](https://discuss.elastic.co/u/faoc)
#### Post date: [January 8, 2018, 9:35am UTC](https://discuss.elastic.co/t/logstash-get-field-from-elasticsearch-message/114325/5 "2018-01-08T09:35:18Z")

</div>

thank you...  
i'm gonna try this 🙂

---

<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, 2018, 9:35am UTC](https://discuss.elastic.co/t/logstash-get-field-from-elasticsearch-message/114325/6 "2018-02-05T09:35:38Z")

</div>

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