BlueSpirit  
                (Aditya Gupta)
               
                 
              
                  
                    January 30, 2019,  9:33am
                   
                   
              1 
               
             
            
              My original data.
{
  message: {
      data: "["1,2","3,4","5,6"]"
  }
}
 
Now I want to convert value of data field to an array. 
So it should become:
{
  message: {
      data: ["1,2", "3,4", "5,6"]
  }
}
 
By using
mutate {
    gsub => ["data", "[\[\]]", ""]
  }
 
I got rid of square brackets.
After this, I tried splitting based on commas. But that won't work. Since my data has commas as well.
I tried writing a dissect block  but that is not useful.
So how should I go ahead with this?
             
            
               
               
               
            
            
           
          
            
              
                Badger  
                
               
              
                  
                    January 30, 2019,  1:48pm
                   
                   
              2 
               
             
            
              
 BlueSpirit:
 
{ data: "["1,2","3,4","5,6"]" }
 
 
Transform "," into a character that you can split on?
    mutate { gsub => [ "data", '","', '|', "data", '^\["', "", "data", '"]$', "" ] }
    mutate { split => { "data" => '|' } }
 
             
            
               
               
              1 Like 
            
            
           
          
            
              
                BlueSpirit  
                (Aditya Gupta)
               
              
                  
                    January 31, 2019,  7:02am
                   
                   
              3 
               
             
            
              Nice approach.
Although, I fixed it by using
json{
  source => "message"
}
json {
  source => "data"
  target => "data"
} 
             
            
               
               
               
            
            
           
          
            
              
                system  
                (system)
                  Closed 
               
              
                  
                    February 28, 2019,  7:02am
                   
                   
              4 
               
             
            
              This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.