Hello Everyone,
I developed a powershell script to send message in bulk to Elastiseach using the Invoke-RestMethod command.
When I send a bulk request directly to Elasticsearch, I can see the properties of my json object stored in the source field.
  
  
    
gistfile1.txt 
    "hits": [
      {
        "_index": "citrix",
        "_type": "default",
        "_id": "GRtKvGMB6tu_wn77Xaob",
        "_score": 1,
        "_source": {
          "ClientAddress": "192.168.0.20,
          "UserName": "username",
          "LogonTime": "2018-06-01T14:54:18.0000000", 
This file has been truncated. show original 
   
  
    
    
  
  
 
However, when I use logstash in the middle, the  json object gets stored in the message field as string.
  
  
    
gistfile1.txt 
"hits": [
      {
        "_index": "logstash-2018.06.01",
        "_type": "doc",
        "_id": "BhtTvGMB6tu_wn77jMwS",
        "_score": 1,
        "_source": {
          "@timestamp": "2018-06-01T17:09:41.773Z",
          "host": "192.168.0.20",
          "headers": { 
This file has been truncated. show original 
   
  
    
    
  
  
 
I`ve already read this discussing here , but I am still confused.
How I can send bulk messages through Logstash so that they I will get correctly store on ElasticSearch?
Thank for you help
             
            
               
               
               
            
            
           
          
            
            
              I forgot to mention how I am sending data through logstash
Here is the powershell command I am using to send messages:
Invoke-RestMethod -Uri ($uri + '/_bulk') -Method POST -ContentType 'application/x-ndjson' -Body $jsonObjectToSend
             
            
               
               
               
            
            
           
          
            
            
              I'm assuming you're using an http input. Set its codec option to json.
             
            
               
               
               
            
            
           
          
            
            
              Yes, I am. But I have already solved this problem.
input { 
http { 
port => "5001" 
codec => "json" 
} 
} 
filter{ 
json { 
source => "message" 
remove_field => ["message"] 
}
    mutate{
            remove_field => ["headers","message"]
    }
 
}
output { 
elasticsearch { 
hosts => ["http://localhost:9200 "] 
index => "logstash-windows-filereport-%{+YYYY.MM.dd}" 
user => "username" 
password => "password" 
} 
#stdout {} 
}
             
            
               
               
              1 Like 
            
            
           
          
            
              
                system  
                (system)
                  Closed 
               
              
                  
                    July 16, 2018,  5:54pm
                   
                   
              6 
               
             
            
              This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.