<?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: Splunk query to retrieve logs containing empty query_string in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Splunk-query-to-retrieve-logs-containing-empty-query-string/m-p/678603#M232042</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Can you provide a sample of the raw data? It's probably JSON assuming what you've posted is from Splunk's "List" view. The spath command in your search also expects _raw (by default) to be JSON. If that's the case, the fields aren't empty. They have a literal hyphen as their value. For example:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{"body_bytes_sent": "0", "bytes_sent": "0", "host": "nice_host", "http_content_type": "-", "http_referer": "-", "http_user_agent": "-", "kong_request_id": "8853b73ffef1c5522b4a383c286c825e", "log_type": "kong", "query_string": "-", "remote_addr": "10.138.100.153", "request_id": "93258e0bc529fa9844e0fd2d69168d0f", "request_length": "1350", "request_method": "GET", "request_time": "0.162", "scheme": "https", "server_addr": "10.138.100.151", "server_protocol": "HTTP/1.1", "status": "499", "time_local": "25/Feb/2024:05:11:24 +0000", "upstream_addr": "10.138.103.157:8080", "upstream_host": "nice_host", "upstream_response_time": "0.000", "uri": "/v1/d5a413b6-7d00-4874-b706-17b15b7a140b"}
{"body_bytes_sent": "0", "bytes_sent": "0", "host": "nice_host", "http_content_type": "-", "http_referer": "-", "http_user_agent": "-", "kong_request_id": "89cea871feba9f2d5216856f7a884223", "log_type": "kong", "query_string": "productType=ALL", "remote_addr": "10.138.100.214", "request_id": "9dbf69defb49a3595cf1040e6ab5d4f2", "request_length": "1366", "request_method": "GET", "request_time": "0.167", "scheme": "https", "server_addr": "10.138.100.151", "server_protocol": "HTTP/1.1", "status": "499", "time_local": "25/Feb/2024:05:11:24 +0000", "upstream_addr": "10.138.98.140:8080", "upstream_host": "nice_host", "upstream_response_time": "0.000", "uri": "/v1/a8b7570f-d0af-4d0d-bd6d-f6cf31892267"}&lt;/LI-CODE&gt;&lt;P&gt;You can search for the literal value directly:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;query_string=-&lt;/LI-CODE&gt;&lt;P&gt;or&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;query_string="-"&lt;/LI-CODE&gt;&lt;P&gt;There is a caveat: the hyphen is a minor breaker and isn't indexed by Splunk as a term. All events will be returned initially, the query_string field will be extracted, and its value will be scanned for a hyphen to filter results.&lt;/P&gt;&lt;P&gt;If your JSON fields aren't auto-extracted, we can investigate your inputs.conf and props.conf settings.&lt;/P&gt;</description>
    <pubDate>Sun, 25 Feb 2024 17:13:18 GMT</pubDate>
    <dc:creator>tscroggins</dc:creator>
    <dc:date>2024-02-25T17:13:18Z</dc:date>
    <item>
      <title>Splunk query to retrieve logs containing empty query_string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-query-to-retrieve-logs-containing-empty-query-string/m-p/678583#M232040</link>
      <description>&lt;P&gt;Hello team&lt;/P&gt;&lt;P&gt;Below are my splunk logs:&lt;/P&gt;&lt;P&gt;{&lt;BR /&gt;body_bytes_sent: 0&lt;BR /&gt;bytes_sent: 0&lt;BR /&gt;host: nice_host&lt;BR /&gt;http_content_type: -&lt;BR /&gt;http_referer: -&lt;BR /&gt;http_user_agent: -&lt;BR /&gt;kong_request_id: 8853b73ffef1c5522b4a383c286c825e&lt;BR /&gt;log_type: kong&lt;BR /&gt;&lt;STRONG&gt;query_string: -&lt;/STRONG&gt;&lt;BR /&gt;remote_addr: 10.138.100.153&lt;BR /&gt;request_id: 93258e0bc529fa9844e0fd2d69168d0f&lt;BR /&gt;request_length: 1350&lt;BR /&gt;request_method: GET&lt;BR /&gt;request_time: 0.162&lt;BR /&gt;scheme: https&lt;BR /&gt;server_addr: 10.138.100.151&lt;BR /&gt;server_protocol: HTTP/1.1&lt;BR /&gt;status: 499&lt;BR /&gt;time_local: 25/Feb/2024:05:11:24 +0000&lt;BR /&gt;upstream_addr: 10.138.103.157:8080&lt;BR /&gt;upstream_host: nice_host&lt;BR /&gt;upstream_response_time: 0.000&lt;BR /&gt;&lt;STRONG&gt;uri: /v1/&lt;/STRONG&gt;d5a413b6-7d00-4874-b706-17b15b7a140b&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;{&lt;BR /&gt;body_bytes_sent: 0&lt;BR /&gt;bytes_sent: 0&lt;BR /&gt;host: nice_host&lt;BR /&gt;http_content_type: -&lt;BR /&gt;http_referer: -&lt;BR /&gt;http_user_agent: -&lt;BR /&gt;kong_request_id: 89cea871feba9f2d5216856f7a884223&lt;BR /&gt;log_type: kong&lt;BR /&gt;&lt;STRONG&gt;query_string: productType=ALL&lt;/STRONG&gt;&lt;BR /&gt;remote_addr: 10.138.100.214&lt;BR /&gt;request_id: 9dbf69defb49a3595cf1040e6ab5d4f2&lt;BR /&gt;request_length: 1366&lt;BR /&gt;request_method: GET&lt;BR /&gt;request_time: 0.167&lt;BR /&gt;scheme: https&lt;BR /&gt;server_addr: 10.138.100.151&lt;BR /&gt;server_protocol: HTTP/1.1&lt;BR /&gt;status: 499&lt;BR /&gt;time_local: 25/Feb/2024:05:11:24 +0000&lt;BR /&gt;upstream_addr: 10.138.98.140:8080&lt;BR /&gt;upstream_host: nice_host&lt;BR /&gt;upstream_response_time: 0.000&lt;BR /&gt;&lt;STRONG&gt;uri: /v1/&lt;/STRONG&gt;a8b7570f-d0af-4d0d-bd6d-f6cf31892267&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;From the above, I want to extract the request_time and upstream_response_time from the log event for the uri "/v1/*" which has query_string is empty(-)&lt;/P&gt;&lt;P&gt;I tried the below search query, but it returns result &lt;STRONG&gt;containing query_string as empty and with values(productType=ALL)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;index="my_indexx"&lt;BR /&gt;| spath host | search host="nice_host"&lt;BR /&gt;| eval Operations=case(&lt;BR /&gt;&lt;STRONG&gt;searchmatch("GET query_string: - /v1/*"),"getCart")&lt;/STRONG&gt;&lt;BR /&gt;| stats avg(request_time) as avg_request_time avg(upstream_response_time) as avg_upstreamTime perc90(request_time) as 90_request_time perc90(upstream_response_time) as 90_upstreamResponseTime by Operations&lt;BR /&gt;| eval avg_request_time=round(avg_request_time,2)&lt;BR /&gt;| eval avg_upstreamTime=round(avg_upstreamTime,2)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;index="ek_cloud_k8sdta_digital_platforms_kong"&lt;BR /&gt;| spath host | search host="shopping-carts-service-oxygen-dev.apps.stg01.digitalplatforms.aws.emirates.dev"&lt;BR /&gt;| eval Operations=case(&lt;BR /&gt;&lt;STRONG&gt;match(_raw, "/v1/[^/ ?]"),"getCart")&lt;/STRONG&gt;&lt;BR /&gt;| stats avg(request_time) as avg_request_time avg(upstream_response_time) as avg_upstreamTime perc90(request_time) as 90_request_time perc90(upstream_response_time) as 90_upstreamResponseTime by Operations&lt;BR /&gt;| eval avg_request_time=round(avg_request_time,2)&lt;BR /&gt;| eval avg_upstreamTime=round(avg_upstreamTime,2)&lt;/P&gt;&lt;P&gt;Can someone help on this.&lt;/P&gt;</description>
      <pubDate>Sun, 25 Feb 2024 08:49:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-query-to-retrieve-logs-containing-empty-query-string/m-p/678583#M232040</guid>
      <dc:creator>super_edition</dc:creator>
      <dc:date>2024-02-25T08:49:21Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk query to retrieve logs containing empty query_string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-query-to-retrieve-logs-containing-empty-query-string/m-p/678603#M232042</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Can you provide a sample of the raw data? It's probably JSON assuming what you've posted is from Splunk's "List" view. The spath command in your search also expects _raw (by default) to be JSON. If that's the case, the fields aren't empty. They have a literal hyphen as their value. For example:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{"body_bytes_sent": "0", "bytes_sent": "0", "host": "nice_host", "http_content_type": "-", "http_referer": "-", "http_user_agent": "-", "kong_request_id": "8853b73ffef1c5522b4a383c286c825e", "log_type": "kong", "query_string": "-", "remote_addr": "10.138.100.153", "request_id": "93258e0bc529fa9844e0fd2d69168d0f", "request_length": "1350", "request_method": "GET", "request_time": "0.162", "scheme": "https", "server_addr": "10.138.100.151", "server_protocol": "HTTP/1.1", "status": "499", "time_local": "25/Feb/2024:05:11:24 +0000", "upstream_addr": "10.138.103.157:8080", "upstream_host": "nice_host", "upstream_response_time": "0.000", "uri": "/v1/d5a413b6-7d00-4874-b706-17b15b7a140b"}
{"body_bytes_sent": "0", "bytes_sent": "0", "host": "nice_host", "http_content_type": "-", "http_referer": "-", "http_user_agent": "-", "kong_request_id": "89cea871feba9f2d5216856f7a884223", "log_type": "kong", "query_string": "productType=ALL", "remote_addr": "10.138.100.214", "request_id": "9dbf69defb49a3595cf1040e6ab5d4f2", "request_length": "1366", "request_method": "GET", "request_time": "0.167", "scheme": "https", "server_addr": "10.138.100.151", "server_protocol": "HTTP/1.1", "status": "499", "time_local": "25/Feb/2024:05:11:24 +0000", "upstream_addr": "10.138.98.140:8080", "upstream_host": "nice_host", "upstream_response_time": "0.000", "uri": "/v1/a8b7570f-d0af-4d0d-bd6d-f6cf31892267"}&lt;/LI-CODE&gt;&lt;P&gt;You can search for the literal value directly:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;query_string=-&lt;/LI-CODE&gt;&lt;P&gt;or&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;query_string="-"&lt;/LI-CODE&gt;&lt;P&gt;There is a caveat: the hyphen is a minor breaker and isn't indexed by Splunk as a term. All events will be returned initially, the query_string field will be extracted, and its value will be scanned for a hyphen to filter results.&lt;/P&gt;&lt;P&gt;If your JSON fields aren't auto-extracted, we can investigate your inputs.conf and props.conf settings.&lt;/P&gt;</description>
      <pubDate>Sun, 25 Feb 2024 17:13:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-query-to-retrieve-logs-containing-empty-query-string/m-p/678603#M232042</guid>
      <dc:creator>tscroggins</dc:creator>
      <dc:date>2024-02-25T17:13:18Z</dc:date>
    </item>
  </channel>
</rss>

