<?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: How can i assign a value to a variable in a splunk in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-can-i-assign-a-value-to-a-variable-in-a-splunk/m-p/692863#M115166</link>
    <description>&lt;P class="lia-align-right"&gt;Perfect ! thank you so much !&lt;/P&gt;</description>
    <pubDate>Wed, 10 Jul 2024 09:23:56 GMT</pubDate>
    <dc:creator>Med_Ryad</dc:creator>
    <dc:date>2024-07-10T09:23:56Z</dc:date>
    <item>
      <title>How can i assign a value to a variable in a splunk</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-can-i-assign-a-value-to-a-variable-in-a-splunk/m-p/692853#M115161</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;
&lt;P&gt;I am looking for a way to assign values to variables in order to avoid repetition in my query. I want to search in different resources using the same variables in the same query. I have tried the following, but it does not seem to work:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| makeresults
| eval var_1="var_1_content"
| eval var_2="var_2_content"
| search (sourcetype=var_1 OR sourcetype=var_2)&lt;/LI-CODE&gt;
&lt;P&gt;Could you please help me correct this or provide an alternative approach to achieve this? Thank you for your assistance!&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jul 2024 08:07:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-can-i-assign-a-value-to-a-variable-in-a-splunk/m-p/692853#M115161</guid>
      <dc:creator>Med_Ryad</dc:creator>
      <dc:date>2024-07-10T08:07:29Z</dc:date>
    </item>
    <item>
      <title>Re: How can i assign a value to a variable in a splunk</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-can-i-assign-a-value-to-a-variable-in-a-splunk/m-p/692855#M115162</link>
      <description>&lt;P&gt;It is a bit unclear what it is you are trying to do but perhaps this approach might help you&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=main [! makeresults
  | eval sourcetype=split("var_1_content,var_2_content",",")
  | mvexpand sourcetype
  | table sourcetype]&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 10 Jul 2024 07:57:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-can-i-assign-a-value-to-a-variable-in-a-splunk/m-p/692855#M115162</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2024-07-10T07:57:36Z</dc:date>
    </item>
    <item>
      <title>Re: How can i assign a value to a variable in a splunk</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-can-i-assign-a-value-to-a-variable-in-a-splunk/m-p/692857#M115163</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp; , thanks for your answer&amp;nbsp; ,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following query:&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;(sourcetype="mysource1" OR sourcetype="mysource2") AND (Node__name="myserver_name" OR (object__Name="myserver_name*") OR (location__Name="*myserver_name*"))&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;What I am trying to achieve is to assign the value "myserver_name" to a variable (e.g., servername) in order to avoid repetition. This way, if I need to modify the query, I only have to update the declared variable. I am looking for something like this:&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;| eval servername = "myserver_name"&lt;BR /&gt;(sourcetype="mysource1" OR sourcetype="mysource2") AND (Node__name=servername OR (object__Name=servername) OR (location__Name=servername))&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;This would allow me to use the variable servername instead of repeating the value "myserver_name" multiple times in the query.&lt;BR /&gt;&lt;BR /&gt;i hope that it's clear now !&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jul 2024 08:18:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-can-i-assign-a-value-to-a-variable-in-a-splunk/m-p/692857#M115163</guid>
      <dc:creator>Med_Ryad</dc:creator>
      <dc:date>2024-07-10T08:18:48Z</dc:date>
    </item>
    <item>
      <title>Re: How can i assign a value to a variable in a splunk</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-can-i-assign-a-value-to-a-variable-in-a-splunk/m-p/692859#M115164</link>
      <description>&lt;P&gt;Try something like this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(sourcetype="mysource1" OR sourcetype="mysource2") [| makeresults
| eval servername="myserver_name"
| eval Node__name=servername
| eval object__Name=servername."*"
| eval location__Name=servername."*"
| format "" "" "OR" "" "" ""]&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 10 Jul 2024 08:40:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-can-i-assign-a-value-to-a-variable-in-a-splunk/m-p/692859#M115164</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2024-07-10T08:40:37Z</dc:date>
    </item>
    <item>
      <title>Re: How can i assign a value to a variable in a splunk</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-can-i-assign-a-value-to-a-variable-in-a-splunk/m-p/692863#M115166</link>
      <description>&lt;P class="lia-align-right"&gt;Perfect ! thank you so much !&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jul 2024 09:23:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-can-i-assign-a-value-to-a-variable-in-a-splunk/m-p/692863#M115166</guid>
      <dc:creator>Med_Ryad</dc:creator>
      <dc:date>2024-07-10T09:23:56Z</dc:date>
    </item>
  </channel>
</rss>

