#splunk #splunk_replace #spl #commands
## What is SPL replace ?
The command `replace` in *Splunk Search Processing Language* is used to replace the value of a field in our results by another value.
## Basic Syntax
``` jsx
replace <value_to_replace> with <new_value> in <field>
```
> Please note that the field 'value_to_replace' is case-sensitive.
## Examples
### Example 1 - basic example
Here is a request that get the *count*, *max* and *average* bytes received per IP Address :
``` JSX
index=botsv1 sourcetype="stream:http"
| stats count(bytes_in) as CountBytesIn, avg(bytes_in) as AvgBytesIn, max(bytes_in) as MaxBytesIn by c_ip
| search AvgBytesIn > 500
```
**Result** :
![[Pasted image 20240516111649.png]]
> In our results we can see the Client IP Address on the left, and the max and average bytes received.
We wil present the result to the management and we want to display the user's name with the IP address `192.168.250.100`. In this example, we will replace the IP with the value `Bob_IP`.
To replace the IP address with `Bob_IP` will simply add the following command at the end of the previous one :
``` jsx
| replace 192.168.250.100 with Bob_IP in c_ip
```
**The full command** :
``` jsx
index=botsv1 sourcetype="stream:http"
| stats count(bytes_in) as CountBytesIn, avg(bytes_in) as AvgBytesIn, max(bytes_in) as MaxBytesIn by c_ip
| search AvgBytesIn > 500
| replace 192.168.250.100 with Bob_IP in c_ip
```
**Result** :
![[Pasted image 20240516111850.png]]