<?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>topic Re: Log processing IP attribute manipulation in DQL</title>
    <link>https://community.dynatrace.com/t5/DQL/Log-processing-IP-attribute-manipulation/m-p/241382#M791</link>
    <description>&lt;P&gt;Let me share my AWS VPC Flow Log parsing rule. It contains braking down content line line into fields and replacing some IP addresses belonging to specific networks (while keeping originals under different names however for temporary/testing purposes):&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;PARSE(content, "
STRING:account_id SPACE
STRING:action SPACE
STRING:az_id SPACE
INT:bytes SPACE
IPV4:dstaddr SPACE
INT:dstport SPACE
STRING:end SPACE
STRING:flow_direction SPACE
STRING:instance_id SPACE
STRING:interface_id SPACE
STRING:log_status SPACE
INT:packets SPACE
STRING:pkt_dst_aws_service SPACE
IPADDR:pkt_dstaddr SPACE
STRING:pkt_src_aws_service SPACE
IPV4:pkt_srcaddr SPACE
INT:protocol SPACE
STRING:region SPACE
IPV4:srcaddr SPACE
INT:srcport SPACE
STRING:start SPACE
STRING:sublocation_id SPACE
STRING:sublocation_type SPACE
STRING:subnet_id SPACE
INT:tcp_flags SPACE
STRING:traffic_path SPACE
STRING:type SPACE
STRING:version SPACE
STRING:vpc_id"
)
| FIELDS_ADD(
    log.type:("aws.vpc"),
    srcaddr_orig:srcaddr,
    dstaddr_orig:dstaddr)
| FIELDS_ADD (
	dstaddr : IF( 
       flow_direction=="egress" AND pkt_dst_aws_service=="-" AND NOT (
       IP_TRUNC(dstaddr,8)==IPADDR("10.0.0.0") OR IP_TRUNC(dstaddr,12)==IPADDR("172.16.0.0") OR IP_TRUNC(dstaddr,16)==IPADDR("192.168.0.0")),
       IPADDR("0.0.0.0") ,
       dstaddr),
	srcaddr : IF( 
       flow_direction=="ingress" AND pkt_src_aws_service=="-" AND NOT (
       IP_TRUNC(srcaddr,8)==IPADDR("10.0.0.0") OR IP_TRUNC(srcaddr,12)==IPADDR("172.16.0.0") OR IP_TRUNC(srcaddr,16)==IPADDR("192.168.0.0")),
       IPADDR("0.0.0.0"), 
       srcaddr)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kris&lt;/P&gt;</description>
    <pubDate>Thu, 28 Mar 2024 18:30:43 GMT</pubDate>
    <dc:creator>krzysztof_hoja</dc:creator>
    <dc:date>2024-03-28T18:30:43Z</dc:date>
    <item>
      <title>Log processing IP attribute manipulation</title>
      <link>https://community.dynatrace.com/t5/DQL/Log-processing-IP-attribute-manipulation/m-p/241327#M788</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;I'm currently parsing the "content" of logs and splitting it into different fields, one of which is called "srcaddr".&lt;/P&gt;&lt;P&gt;I want to change the IP addresses so that they show the name of the source, instead of the IP itself.&lt;/P&gt;&lt;P&gt;Sources can have a few IP's within a range, so I'm trying to do a query like:&lt;/P&gt;&lt;P&gt;|FIELDS_ADD(srcaddr: IF_THEN_ELSE(srcaddr ....(range of IP addresses)...., "name of source", srcaddr)&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;For example&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;If a "srcaddr" is between xxx.xx2.0.1 and xxx.xx2.15.254, call it "Source 1"&lt;/LI&gt;&lt;LI&gt;If a "srcaddr" is between xxx.xx2.16.1 and xxx.xx2.30.254, call it "Source 2"&lt;/LI&gt;&lt;LI&gt;If "srcaddr" is between xxx.xx4.0.1 and xxx.xx4.15.254, call it "Source 3", etc. etc.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've found this in the documentation- it refers to IPADDR(), but I'm not sure how I'd utilize it properly...&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.dynatrace.com/docs/shortlink/lma-log-processing-functions#ipaddr" target="_blank"&gt;https://docs.dynatrace.com/docs/shortlink/lma-log-processing-functions#ipaddr&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How would you think about doing this? When I parse the "content" of the log, is it okay that the IP addresses are in "String" form instead of IP or something else?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;Asaf&lt;/P&gt;</description>
      <pubDate>Thu, 28 Mar 2024 11:58:58 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Log-processing-IP-attribute-manipulation/m-p/241327#M788</guid>
      <dc:creator>AsafAx</dc:creator>
      <dc:date>2024-03-28T11:58:58Z</dc:date>
    </item>
    <item>
      <title>Re: Log processing IP attribute manipulation</title>
      <link>https://community.dynatrace.com/t5/DQL/Log-processing-IP-attribute-manipulation/m-p/241382#M791</link>
      <description>&lt;P&gt;Let me share my AWS VPC Flow Log parsing rule. It contains braking down content line line into fields and replacing some IP addresses belonging to specific networks (while keeping originals under different names however for temporary/testing purposes):&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;PARSE(content, "
STRING:account_id SPACE
STRING:action SPACE
STRING:az_id SPACE
INT:bytes SPACE
IPV4:dstaddr SPACE
INT:dstport SPACE
STRING:end SPACE
STRING:flow_direction SPACE
STRING:instance_id SPACE
STRING:interface_id SPACE
STRING:log_status SPACE
INT:packets SPACE
STRING:pkt_dst_aws_service SPACE
IPADDR:pkt_dstaddr SPACE
STRING:pkt_src_aws_service SPACE
IPV4:pkt_srcaddr SPACE
INT:protocol SPACE
STRING:region SPACE
IPV4:srcaddr SPACE
INT:srcport SPACE
STRING:start SPACE
STRING:sublocation_id SPACE
STRING:sublocation_type SPACE
STRING:subnet_id SPACE
INT:tcp_flags SPACE
STRING:traffic_path SPACE
STRING:type SPACE
STRING:version SPACE
STRING:vpc_id"
)
| FIELDS_ADD(
    log.type:("aws.vpc"),
    srcaddr_orig:srcaddr,
    dstaddr_orig:dstaddr)
| FIELDS_ADD (
	dstaddr : IF( 
       flow_direction=="egress" AND pkt_dst_aws_service=="-" AND NOT (
       IP_TRUNC(dstaddr,8)==IPADDR("10.0.0.0") OR IP_TRUNC(dstaddr,12)==IPADDR("172.16.0.0") OR IP_TRUNC(dstaddr,16)==IPADDR("192.168.0.0")),
       IPADDR("0.0.0.0") ,
       dstaddr),
	srcaddr : IF( 
       flow_direction=="ingress" AND pkt_src_aws_service=="-" AND NOT (
       IP_TRUNC(srcaddr,8)==IPADDR("10.0.0.0") OR IP_TRUNC(srcaddr,12)==IPADDR("172.16.0.0") OR IP_TRUNC(srcaddr,16)==IPADDR("192.168.0.0")),
       IPADDR("0.0.0.0"), 
       srcaddr)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kris&lt;/P&gt;</description>
      <pubDate>Thu, 28 Mar 2024 18:30:43 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Log-processing-IP-attribute-manipulation/m-p/241382#M791</guid>
      <dc:creator>krzysztof_hoja</dc:creator>
      <dc:date>2024-03-28T18:30:43Z</dc:date>
    </item>
    <item>
      <title>Re: Log processing IP attribute manipulation</title>
      <link>https://community.dynatrace.com/t5/DQL/Log-processing-IP-attribute-manipulation/m-p/241464#M794</link>
      <description>&lt;P&gt;Hi Kris, thank you for your reply!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;It seems to me that the &lt;A href="https://docs.dynatrace.com/docs/shortlink/ba-processing-functions#ip-trunc" target="_self"&gt;IP_TRUNK() function&lt;/A&gt;&amp;nbsp;with operators (all within a conditional "if" statement) is the right way to do it:&lt;/P&gt;&lt;P&gt;IP_TRUNC(srcaddr, 8 ) &amp;gt;= IPADDR("xx.xx2.0.1") AND IP_TRUNC(srcaddr, 8 ) &amp;lt;= IPADDR("xx.xx2.15.254"))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have yet to implement it in our environment, but I'm sure that it'll work or get very close to the right result.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your help!&lt;/P&gt;&lt;P&gt;Asaf&lt;/P&gt;</description>
      <pubDate>Sat, 30 Mar 2024 10:37:57 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Log-processing-IP-attribute-manipulation/m-p/241464#M794</guid>
      <dc:creator>AsafAx</dc:creator>
      <dc:date>2024-03-30T10:37:57Z</dc:date>
    </item>
  </channel>
</rss>

