# Customize document fields in elasticsearch

**URL:** <https://discuss.elastic.co/t/customize-document-fields-in-elasticsearch/139522>\
**Category:** Logstash\
**Created:** [July 11, 2018, 9:14am UTC](https://discuss.elastic.co/t/customize-document-fields-in-elasticsearch/139522 "2018-07-11T09:14:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![waitangi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/waitangi/32/110887_2.png) [@waitangi](https://discuss.elastic.co/u/waitangi)\
**Post date:** [July 11, 2018, 9:14am UTC](https://discuss.elastic.co/t/customize-document-fields-in-elasticsearch/139522/1 "2018-07-11T09:14:28Z")

</div>

I need to customize document fields in elasticsearch.  
My logstash config is:  
input {  
file {  
type =\> "IISLog"  
path =\> "C:/inetpub/logs/LogFiles/W3SVC\*/\*.log"  
start\_position =\> "beginning"  
}  
}

filter {  
#ignore comments  
if [message] =~ "^#" {  
drop {}  
}

```
grok {
	#match => ["message", "%{COMBINEDAPACHELOG}"]
	match => ["message", "%{TIMESTAMP_ISO8601:log_timestamp} %{WORD:serviceName} %{WORD:serverName} %{IP:serverIP} %{WORD:method} %{URIPATH:uriStem} %{NOTSPACE:uriQuery} %{NUMBER:port} %{NOTSPACE:username} %{IPORHOST:clientIP} %{NOTSPACE:protocolVersion} %{NOTSPACE:userAgent} %{NOTSPACE:cookie} %{NOTSPACE:referer} %{NOTSPACE:requestHost} %{NUMBER:response} %{NUMBER:subresponse} %{NUMBER:win32response} %{NUMBER:bytesSent} %{NUMBER:bytesReceived} %{NUMBER:timetaken}"]
}

mutate {
	add_field => {"bytes_sent" => "%{message}{bytesSent}"}
}

```

}

output {  
stdout {  
codec =\> rubydebug  
}  
elasticsearch {  
hosts =\> ["localhost:9200"]  
index =\> "logs"  
}  
}

All I want is to add document attribute 'bytes\_sent' where bytes\_sent is extracted from grok. How to get this part from grok expression? %{message.bytesSent} does not seems to work

---

<div class="post-metadata">

**Author:** ![waitangi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/waitangi/32/110887_2.png) [@waitangi](https://discuss.elastic.co/u/waitangi)\
**Post date:** [July 11, 2018, 11:25am UTC](https://discuss.elastic.co/t/customize-document-fields-in-elasticsearch/139522/2 "2018-07-11T11:25:02Z")

</div>

Sorry... My log entry did not matched grok expression. Now it works

---

<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:** [August 8, 2018, 11:25am UTC](https://discuss.elastic.co/t/customize-document-fields-in-elasticsearch/139522/3 "2018-08-08T11:25:07Z")

</div>

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