# Substitution text if value missing

**URL:** <https://discuss.elastic.co/t/substitution-text-if-value-missing/271301>\
**Category:** Logstash\
**Created:** [April 26, 2021, 10:34pm UTC](https://discuss.elastic.co/t/substitution-text-if-value-missing/271301 "2021-04-26T22:34:36Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![lquin1978](https://avatars.discourse-cdn.com/v4/letter/l/5daacb/32.png) [@lquin1978](https://discuss.elastic.co/u/lquin1978)\
**Post date:** [April 26, 2021, 10:34pm UTC](https://discuss.elastic.co/t/substitution-text-if-value-missing/271301/1 "2021-04-26T22:34:36Z")

</div>

Our firewall is sending log messages to our ELK stack. Most of these messages contain a source and destination IP address.. but occasionally these values are not present. These messages are being forward via email and the values %{src} or %{dst}) are shown if these values were not in the message received.

Is there any way to either remove or replace these with a string should these values not be present in a message received.

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [April 26, 2021, 11:09pm UTC](https://discuss.elastic.co/t/substitution-text-if-value-missing/271301/2 "2021-04-26T23:09:17Z")

</div>

> [@lquin1978](#):
>
> Is there any way to either remove or replace these with a string should these values not be present in a message received.

You could delete them using

```
prune {}

```

prune can whitelist and blacklist top-level fields based on either name or value. The default configuration is to blacklist (i.e. delete) any fields for which the name matches the regexp `%{[^}]+}`.

If you want to overwrite them you could use

```
if [nameOfDstField] == "%{dst}" { mutate { replace => { "nameOfDstField" => "someValue" } } }

```

etc.

---

<div class="post-metadata">

**Author:** ![lquin1978](https://avatars.discourse-cdn.com/v4/letter/l/5daacb/32.png) [@lquin1978](https://discuss.elastic.co/u/lquin1978)\
**Post date:** [April 27, 2021, 12:30pm UTC](https://discuss.elastic.co/t/substitution-text-if-value-missing/271301/3 "2021-04-27T12:30:04Z")

</div>

> [@Badger](#):
>
> an whitelist and blacklist top-level fields based on either name or value. The default configuration is to blacklist (i.e. delete) any fields for which the name matches the regexp `%{[^}]+}` .

Thanks for your response. Would this provide the flexibility to keep the field if the value exists, but remove if it does not?

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [April 27, 2021, 2:14pm UTC](https://discuss.elastic.co/t/substitution-text-if-value-missing/271301/4 "2021-04-27T14:14:46Z")

</div>

If the field exists it must have a value. What value does it have?

---

<div class="post-metadata">

**Author:** ![lquin1978](https://avatars.discourse-cdn.com/v4/letter/l/5daacb/32.png) [@lquin1978](https://discuss.elastic.co/u/lquin1978)\
**Post date:** [April 27, 2021, 2:54pm UTC](https://discuss.elastic.co/t/substitution-text-if-value-missing/271301/5 "2021-04-27T14:54:17Z")

</div>

What I am saying is some messages use the value, some do not. When they do not I would like to put a placeholder.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 25, 2021, 2:54pm UTC](https://discuss.elastic.co/t/substitution-text-if-value-missing/271301/6 "2021-05-25T14:54:28Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
