<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: jolttransformjson - transform some elements but keep others in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/jolttransformjson-transform-some-elements-but-keep-others/m-p/132922#M39506</link>
    <description>&lt;P&gt;Thank you &lt;A rel="user" href="https://community.cloudera.com/users/173/agrande.html" nodeid="173"&gt;@Andrew Grande&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Quick question. If I don't need to do any filtering in jolt, why do I need it? To flatten it?&lt;/P&gt;</description>
    <pubDate>Fri, 02 Sep 2016 23:54:18 GMT</pubDate>
    <dc:creator>mqureshi</dc:creator>
    <dc:date>2016-09-02T23:54:18Z</dc:date>
    <item>
      <title>jolttransformjson - transform some elements but keep others</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/jolttransformjson-transform-some-elements-but-keep-others/m-p/132920#M39504</link>
      <description>&lt;P&gt;I have a complex json and I am using jolttransformjson processor to flatten out the json. I have looked at following links which are very helpful.&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.google.com/presentation/d/1sAiuiFC4Lzz4-064sg1p8EQt2ev0o442MfEbvrpD1ls/edit#slide=id.g9798b391_00" target="_blank"&gt;https://docs.google.com/presentation/d/1sAiuiFC4Lzz4-064sg1p8EQt2ev0o442MfEbvrpD1ls/edit#slide=id.g9798b391_00&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/bazaarvoice/jolt/blob/master/jolt-core/src/main/java/com/bazaarvoice/jolt/Shiftr.java" target="_blank"&gt;https://github.com/bazaarvoice/jolt/blob/master/jolt-core/src/main/java/com/bazaarvoice/jolt/Shiftr.java&lt;/A&gt;&lt;/P&gt;&lt;P&gt;But what I still can't find is an example that shows transforming some attributes and not others. So, I have a json and the only thing I want to do really is keep records which contain certain value. Rest will be filtered out. but everything else in the json remains the way it is. Can someone share a quick example of this?&lt;/P&gt;</description>
      <pubDate>Fri, 02 Sep 2016 11:44:53 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/jolttransformjson-transform-some-elements-but-keep-others/m-p/132920#M39504</guid>
      <dc:creator>mqureshi</dc:creator>
      <dc:date>2016-09-02T11:44:53Z</dc:date>
    </item>
    <item>
      <title>Re: jolttransformjson - transform some elements but keep others</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/jolttransformjson-transform-some-elements-but-keep-others/m-p/132921#M39505</link>
      <description>&lt;P&gt;Hi, I'm not yet sure if that can be done in JOLT spec. However, how about approaching it from the flow-based programming standpoint? The steps should be:&lt;/P&gt;&lt;UL&gt;
&lt;LI&gt;Transform with JOLT - do all, no filtering&lt;/LI&gt;&lt;LI&gt;EvaluateJsonPath into an attribute - extract values that will be used to make a decision&lt;/LI&gt;&lt;LI&gt;RouteOnAttribute - use an expression against the above set of attributes to implement the filtering logic. E.g. discard or re-route records which don't match the criteria.&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Fri, 02 Sep 2016 18:27:08 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/jolttransformjson-transform-some-elements-but-keep-others/m-p/132921#M39505</guid>
      <dc:creator>andrewg</dc:creator>
      <dc:date>2016-09-02T18:27:08Z</dc:date>
    </item>
    <item>
      <title>Re: jolttransformjson - transform some elements but keep others</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/jolttransformjson-transform-some-elements-but-keep-others/m-p/132922#M39506</link>
      <description>&lt;P&gt;Thank you &lt;A rel="user" href="https://community.cloudera.com/users/173/agrande.html" nodeid="173"&gt;@Andrew Grande&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Quick question. If I don't need to do any filtering in jolt, why do I need it? To flatten it?&lt;/P&gt;</description>
      <pubDate>Fri, 02 Sep 2016 23:54:18 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/jolttransformjson-transform-some-elements-but-keep-others/m-p/132922#M39506</guid>
      <dc:creator>mqureshi</dc:creator>
      <dc:date>2016-09-02T23:54:18Z</dc:date>
    </item>
    <item>
      <title>Re: jolttransformjson - transform some elements but keep others</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/jolttransformjson-transform-some-elements-but-keep-others/m-p/132923#M39507</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/173/agrande.html" nodeid="173"&gt;@Andrew Grande&lt;/A&gt; &lt;/P&gt;&lt;P&gt;So, I have done step 1 and 2 as you suggested. I am not sure how to implement step 3. Using jolt json, I have flattened my json by moving following objects from array to now as another attribute of the record.&lt;/P&gt;&lt;P&gt;"event_1_detail":{"type":"comma separated values","Description":"&amp;lt;important value&amp;gt;",&amp;lt;many other attributes&amp;gt;}&lt;/P&gt;&lt;P&gt;"event_2_detail":{"type":"comma separated values","Description":"&amp;lt;important value&amp;gt;",&amp;lt;many other attributes&amp;gt;}&lt;/P&gt;&lt;P&gt;"event_3_detail":{"type":"comma separated values","Description":"&amp;lt;important value&amp;gt;",&amp;lt;many other attributes&amp;gt;}&lt;/P&gt;&lt;P&gt;and so on. it's going to be different for each json record.&lt;/P&gt;&lt;P&gt;I have created flow-file attribute using EvalueJson processor which gets the description value. Now out of the elements shown above, I need to drop everything and retain only the one where&lt;/P&gt;&lt;P&gt;"Description":"&amp;lt;the value I want to retain&amp;gt;"&lt;/P&gt;&lt;P&gt;this means of "event_x_detail" above only the one which satisfies my criteria for description should be retained. the rest of json of course still remains there. just rest of "event_x_detail" are dropped. How do i do this using RouteOnAttribute?&lt;/P&gt;</description>
      <pubDate>Tue, 06 Sep 2016 07:42:46 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/jolttransformjson-transform-some-elements-but-keep-others/m-p/132923#M39507</guid>
      <dc:creator>mqureshi</dc:creator>
      <dc:date>2016-09-06T07:42:46Z</dc:date>
    </item>
    <item>
      <title>Re: jolttransformjson - transform some elements but keep others</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/jolttransformjson-transform-some-elements-but-keep-others/m-p/132924#M39508</link>
      <description>&lt;P&gt;In a JOLT spec, if you don't explicitly provide a transformation for a particular field, it will be excluded. So you can include matching rules for the fields you care about (i.e. those that have a certain value), the rest will be discarded. Check the "Filter data from an Array, based on a leaf level value" example at the &lt;A target="_blank" href="http://jolt-demo.appspot.com/"&gt;JOLT Demo online app&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Sat, 13 May 2017 09:38:51 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/jolttransformjson-transform-some-elements-but-keep-others/m-p/132924#M39508</guid>
      <dc:creator>mburgess</dc:creator>
      <dc:date>2017-05-13T09:38:51Z</dc:date>
    </item>
    <item>
      <title>Re: jolttransformjson - transform some elements but keep others</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/jolttransformjson-transform-some-elements-but-keep-others/m-p/132925#M39509</link>
      <description>&lt;P&gt;If there anyway I can get both transformed and original json out of JoltTransformation processor?&lt;/P&gt;&lt;P&gt;,
&lt;/P&gt;&lt;P&gt;If there anyway I can get both transformed and original json out of JoltTransformation processor?&lt;/P&gt;</description>
      <pubDate>Wed, 09 Jan 2019 04:29:29 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/jolttransformjson-transform-some-elements-but-keep-others/m-p/132925#M39509</guid>
      <dc:creator>aniruddh02</dc:creator>
      <dc:date>2019-01-09T04:29:29Z</dc:date>
    </item>
    <item>
      <title>Re: jolttransformjson - transform some elements but keep others</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/jolttransformjson-transform-some-elements-but-keep-others/m-p/132926#M39510</link>
      <description>&lt;P style="margin-left: 20px;"&gt;Looks like &lt;A rel="user" href="https://community.cloudera.com/users/363/bbende.html" nodeid="363"&gt;@Bryan Bende&lt;/A&gt; answered &lt;A href="https://stackoverflow.com/questions/54099565/how-to-output-origianl-json-along-with-transformed-json-in-jolttransformation" target="_blank"&gt;your question on SO&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jan 2019 02:55:18 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/jolttransformjson-transform-some-elements-but-keep-others/m-p/132926#M39510</guid>
      <dc:creator>mburgess</dc:creator>
      <dc:date>2019-01-10T02:55:18Z</dc:date>
    </item>
    <item>
      <title>Re: jolttransformjson - transform some elements but keep others</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/jolttransformjson-transform-some-elements-but-keep-others/m-p/293003#M39511</link>
      <description>&lt;P&gt;You can use * and &amp;amp; to copy all in a shift operation&lt;/P&gt;</description>
      <pubDate>Tue, 31 Mar 2020 15:57:48 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/jolttransformjson-transform-some-elements-but-keep-others/m-p/293003#M39511</guid>
      <dc:creator>UselesssCat</dc:creator>
      <dc:date>2020-03-31T15:57:48Z</dc:date>
    </item>
    <item>
      <title>Re: jolttransformjson - transform some elements but keep others</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/jolttransformjson-transform-some-elements-but-keep-others/m-p/293004#M39512</link>
      <description>&lt;P&gt;For example I want to transform the zabbix payload from v4.0 to v4.4:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Zabbix Json Payload v4.0 (INPUT)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{
  "hosts": [
    "Host B",
    "Zabbix Server"
  ],
  "groups": [
    "Group X",
    "Group Y",
    "Group Z",
    "Zabbix servers"
  ],
  "tags": [
    {
      "tag": "availability",
      "value": ""
    },
    {
      "tag": "data center",
      "value": "Riga"
    }
  ],
  "name": "Either Zabbix agent is unreachable",
  "clock": 1519304285,
  "ns": 123456789,
  "eventid": 42,
  "value": 1
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the JOLT transform:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;[
  {
    "operation": "shift",
    "spec": {
      "hosts": {
        "*": [
          "hosts.[&amp;amp;].host",
          "hosts.[&amp;amp;].name"
        ]
      },
      "*": "&amp;amp;"
    }
  }
]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;The result ( Zabbix v4.4)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{
  "hosts" : [ {
    "host" : "Host B",
    "name" : "Host B"
  }, {
    "host" : "Zabbix Server",
    "name" : "Zabbix Server"
  } ],
  "groups" : [ "Group X", "Group Y", "Group Z", "Zabbix servers" ],
  "tags" : [ {
    "tag" : "availability",
    "value" : ""
  }, {
    "tag" : "data center",
    "value" : "Riga"
  } ],
  "name" : "Either Zabbix agent is unreachable",
  "clock" : 1519304285,
  "ns" : 123456789,
  "eventid" : 42,
  "value" : 1
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Mar 2020 15:58:56 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/jolttransformjson-transform-some-elements-but-keep-others/m-p/293004#M39512</guid>
      <dc:creator>UselesssCat</dc:creator>
      <dc:date>2020-03-31T15:58:56Z</dc:date>
    </item>
  </channel>
</rss>

