<?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: Query formatting error. in Security</title>
    <link>https://community.splunk.com/t5/Security/Query-formatting-error/m-p/492034#M15353</link>
    <description>&lt;PRE&gt;&lt;CODE&gt;your search
| dedup hostname,  Interface
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 28 Jan 2020 11:27:03 GMT</pubDate>
    <dc:creator>to4kawa</dc:creator>
    <dc:date>2020-01-28T11:27:03Z</dc:date>
    <item>
      <title>Query formatting error.</title>
      <link>https://community.splunk.com/t5/Security/Query-formatting-error/m-p/492031#M15350</link>
      <description>&lt;P&gt;Need help in filtering words from the RAW output.&lt;BR /&gt;
Below is a sample message that am getting from my index.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;2020-01-24T18:48:03.593Z USDALPOD03-DCNPL2023 &amp;lt;29&amp;gt; ifIndex 515, ifAdminStatus up(1), ifOperStatus up(1), ifName et-0/0/50
2020-01-24T18:48:01.793Z USDALPOD03-DCNPL2023 &amp;lt;28&amp;gt; ifIndex 515, ifAdminStatus up(1), ifOperStatus down(2), ifName et-0/0/50
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Below is the code that am using.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=nw_syslog  "et-*" "ifoper*"
| rex field=_raw "ifName (?&amp;lt;Interface&amp;gt;.*)"
| rex field=_raw "ifOperStatus (?&amp;lt;Status&amp;gt;.*)"
| table hostname, Status, Interface
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Below is the output that am getting.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;hostname    Status  Interface
USDALPOD03-DCNPL2023    up(1), ifName et-0/0/50 et-0/0/50
USDALPOD03-DCNPL2023    down(2), ifName et-0/0/50   et-0/0/50
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Expected output&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;hostname    Status  Interface    Time
USDALPOD03-DCNPL2023    up  et-0/0/50  XX:XX:XX
USDALPOD03-DCNPL2023    down    et-0/0/50  XX:XX:XX
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;While am giving | rex field=_raw "ifOperStatus (?.*)("  this qurry, its giving me error. please help in formatting.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jan 2020 09:31:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/Query-formatting-error/m-p/492031#M15350</guid>
      <dc:creator>jerinvarghese</dc:creator>
      <dc:date>2020-01-28T09:31:29Z</dc:date>
    </item>
    <item>
      <title>Re: Query formatting error.</title>
      <link>https://community.splunk.com/t5/Security/Query-formatting-error/m-p/492032#M15351</link>
      <description>&lt;P&gt;Hi @jerinvarghese,&lt;BR /&gt;
at first use this regex&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;ifIndex\s+(?&amp;lt;ifIndex&amp;gt;[^,]*),\sifAdminStatus\s+(?&amp;lt;ifAdminStatus&amp;gt;[^,]*),\s+ifOperStatus\s+(?&amp;lt;Status&amp;gt;[^\(]*)\(\d+\),\s+ifName\s+(?&amp;lt;Interface&amp;gt;.*)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;that you can test at &lt;A href="https://regex101.com/r/KRBboF/2"&gt;https://regex101.com/r/KRBboF/2&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;So you can modify your output having a search like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=nw_syslog  "et-*" "ifoper*"
 | rex "ifIndex\s+(?&amp;lt;ifIndex&amp;gt;[^,]*),\sifAdminStatus\s+(?&amp;lt;ifAdminStatus&amp;gt;[^,]*),\s+ifOperStatus\s+(?&amp;lt;Status&amp;gt;[^\(]*)\(\d+\),\s+ifName\s+(?&amp;lt;Interface&amp;gt;.*)"
| table hostname, Status, Interface
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Ciao.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jan 2020 09:46:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/Query-formatting-error/m-p/492032#M15351</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2020-01-28T09:46:47Z</dc:date>
    </item>
    <item>
      <title>Re: Query formatting error.</title>
      <link>https://community.splunk.com/t5/Security/Query-formatting-error/m-p/492033#M15352</link>
      <description>&lt;P&gt;Thanks so much for the regex command.&lt;/P&gt;

&lt;P&gt;I edited little more in that&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=nw_syslog  "et-*" "ifoper*"
  | rex "ifIndex\s+(?&amp;lt;ifIndex&amp;gt;[^,]*),\sifAdminStatus\s+(?&amp;lt;ifAdminStatus&amp;gt;[^,]*),\s+ifOperStatus\s+(?&amp;lt;Status&amp;gt;[^\(]*)\(\d+\),\s+ifName\s+(?&amp;lt;Interface&amp;gt;.*)"
  | stats  latest(_time) as Time_CST count by hostname, Status, Interface
  | sort - Time_CST
 | fieldformat Time_CST=strftime(Time_CST,"%x %X")
 | table hostname, Status, Interface, Time_CST, count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Output came as &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;hostname    Status  Interface   Time_CST    count
USDALPOD03-DCNPL2023    up  et-0/0/50   01/24/20 12:48:03   2
USDALPOD03-DCNPL2023    down    et-0/0/50   01/24/20 12:48:01   1
USDALPOD03-DCNPL2023    up  et-0/0/48   01/24/20 12:33:27   2
USDALPOD03-DCNPL2023    down    et-0/0/48   01/24/20 12:33:26   1
USDALPOD03-DCNPL2021    down    et-0/0/48   01/24/20 10:26:53   1
USDALPOD03-DCNPL2021    up  et-0/0/48   01/24/20 10:26:52   1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Is it possible to dedup the Interface w.r.t to the hostname and display the latest one Status based.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jan 2020 11:09:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/Query-formatting-error/m-p/492033#M15352</guid>
      <dc:creator>jerinvarghese</dc:creator>
      <dc:date>2020-01-28T11:09:34Z</dc:date>
    </item>
    <item>
      <title>Re: Query formatting error.</title>
      <link>https://community.splunk.com/t5/Security/Query-formatting-error/m-p/492034#M15353</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;your search
| dedup hostname,  Interface
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Jan 2020 11:27:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/Query-formatting-error/m-p/492034#M15353</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-01-28T11:27:03Z</dc:date>
    </item>
    <item>
      <title>Re: Query formatting error.</title>
      <link>https://community.splunk.com/t5/Security/Query-formatting-error/m-p/492035#M15354</link>
      <description>&lt;P&gt;Hi @jerinvarghese,&lt;BR /&gt;
if you want to list all the Statuses, you can modify your stats command in &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats  latest(_time) as Time_CST values(Status) AS Status count by hostname Interface
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;if instead you want only the last one:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats  latest(_time) as Time_CST max(Status) AS Status count by hostname Interface
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Ciao.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jan 2020 13:13:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/Query-formatting-error/m-p/492035#M15354</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2020-01-28T13:13:58Z</dc:date>
    </item>
  </channel>
</rss>

