Xml filter : remove a useless node name before array

I have a microsoft sql input and i parse an xml column thanks to the filter xml

My sql column contains xml like bellow:

<actors>
  <actor last_name="RICHARDSON" first_name="Ian" />
  <actor last_name="LANDAU" first_name="Martin" />
  <actor last_name="BERRY" first_name="Halle" />
  <actor last_name="DESSELLE" first_name="Natalie" />
</actors>

my flogstash conf file contains that samples:

input {
      jdbc {
         ...
        ....
          statement => "	
						  SELECT 								
						actors
						FROM [dbo].[VIEW_SQL] movie
						"
    }
}

filter
{
	
    xml  {
		    source => "actors"
		    xpath => [ "//actor/@last_name", "last_name" ]
		    xpath => [ "//actor/@first_name", "first_name" ]
			target => "actors"	   
       }
}

output {
     stdout { codec => rubydebug }
}

It output an object:

 "actors": {
            "actor": [
              {
                "last_name": "RICHARDSON",
                "first_name": "Ian"
              },
              {
                "last_name": "LANDAU",
                "first_name": "Martin"
              },
              {
                "last_name": "BERRY",
                "first_name": "Halle"
              },
              {
                "last_name": "DESSELLE",
                "first_name": "Natalie"
              }
            ]
          }

I want to have directly an array without a object wrapper like bellow:

 "actors": [
              {
                "last_name": "RICHARDSON",
                "first_name": "Ian"
              },
              {
                "last_name": "LANDAU",
                "first_name": "Martin"
              },
              {
                "last_name": "BERRY",
                "first_name": "Halle"
              },
              {
                "last_name": "DESSELLE",
                "first_name": "Natalie"
              }
            ]

I tried (maybe badly) to use remove_namespaces => true and remove_tag => [ "actor" ] i saw in xml docs but it dos not appear to procuce any effects

Do you know how to use the xml filterfor doing that please?

I'm not sure if you can do that with the xml filter, but a ruby filter can certainly clean this up for you.

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