# How to Replace certain part of URL in a log content

**URL:** <https://community.dynatrace.com/t/how-to-replace-certain-part-of-url-in-a-log-content/50806>\
**Category:** DQL\
**Tags:** dql, notebooks, dpl, logs\
**Created:** [March 20, 2025, 2:45pm UTC](https://community.dynatrace.com/t/how-to-replace-certain-part-of-url-in-a-log-content/50806 "2025-03-20T14:45:18Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![susmita\_k](https://avatars.discourse-cdn.com/v4/letter/s/7993a0/32.png) [@susmita\_k](https://community.dynatrace.com/u/susmita_k)\
**Post date:** [March 20, 2025, 2:45pm UTC](https://community.dynatrace.com/t/how-to-replace-certain-part-of-url-in-a-log-content/50806/1 "2025-03-20T14:45:18Z")

</div>

I have a log content like this :

URL: /v1/agreements/12345678/vins/xx123456KL456/validate

How can I replace the 3rd and 5th portion so that for all vins and agreements # dynatrace treat them as same url ?

---

<div class="post-metadata">

**Author:** ![KeeganNelson](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/keegannelson/32/20333_2.png) [@KeeganNelson](https://community.dynatrace.com/u/KeeganNelson)\
**Post date:** [March 21, 2025, 8:29pm UTC](https://community.dynatrace.com/t/how-to-replace-certain-part-of-url-in-a-log-content/50806/2 "2025-03-21T20:29:50Z")

</div>

I would recommend using the DPL architect after clicking on this specific field and choosing extract. This will allow you to parse the information and then represent it in a new field.

Here are the docs on this,&nbsp;[DPL Architect — Dynatrace Docs](https://docs.dynatrace.com/docs/discover-dynatrace/references/dynatrace-pattern-language/dpl-architect)

---

<div class="post-metadata">

**Author:** ![Mohammed-Samy](https://avatars.discourse-cdn.com/v4/letter/m/2bfe46/32.png) [@Mohammed-Samy](https://community.dynatrace.com/u/Mohammed-Samy)\
**Post date:** [April 3, 2025, 12:23pm UTC](https://community.dynatrace.com/t/how-to-replace-certain-part-of-url-in-a-log-content/50806/3 "2025-04-03T12:23:17Z")

</div>

Hello&nbsp;[@susmita\_k](https://community.dynatrace.com/user/67050),

you can try the DQL replace pattern

```javascript
data record(content="URL: /v1/agreements/12345678/vins/xx123456KL456/validate")
| fieldsAdd content = replacePattern(content, "'agreements/' ld '/'", "agreements/***/")
| fieldsAdd content = replacePattern(content, "'vins/' ld '/'", "vins/***/")

```

Output :&nbsp;URL: /v1/agreements/\*\*\*/vins/\*\*\*/validate

here’s the documentation reference:&nbsp;[replacePattern](https://docs.dynatrace.com/docs/discover-dynatrace/references/dynatrace-query-language/functions/string-functions#replacePattern)

---

<div class="post-metadata">

**Author:** ![susmita\_k](https://avatars.discourse-cdn.com/v4/letter/s/7993a0/32.png) [@susmita\_k](https://community.dynatrace.com/u/susmita_k)\
**Post date:** [April 9, 2025, 5:40pm UTC](https://community.dynatrace.com/t/how-to-replace-certain-part-of-url-in-a-log-content/50806/4 "2025-04-09T17:40:57Z")

</div>

I have multiple type of urls and i would like to do it dynamically.. also, when I do it, I dont want it to update the v1 or v2s present in the url. while replacepattern is working, but not able to do it for all type of url with single line of code.

---

<div class="post-metadata">

**Author:** ![Mohammed-Samy](https://avatars.discourse-cdn.com/v4/letter/m/2bfe46/32.png) [@Mohammed-Samy](https://community.dynatrace.com/u/Mohammed-Samy)\
**Post date:** [April 11, 2025, 8:05am UTC](https://community.dynatrace.com/t/how-to-replace-certain-part-of-url-in-a-log-content/50806/5 "2025-04-11T08:05:01Z")

</div>

if you have some sort of pattern for these URLs you can identify them using dpl and replace them even if there’s some slight differences you can use the or operator to pick one variant

for example if we have these 3 patterns :

URL:&nbsp;/v1/agreements/12345678/vins/xx123456KL456/validate  
URL:&nbsp;/v1/agreements1/12345678/vins/xx123456KL456/validate  
URL:&nbsp;/v1/agreements2/12345678/vins/xx123456KL456/validate

```javascript
data record(content="URL: /v1/agreements/12345678/vins/xx123456KL456/validate"),
record(content="URL: /v1/agreements1/12345678/vins/xx123456KL456/validate"),
record(content="URL: /v1/agreements2/12345678/vins/xx123456KL456/validate")
| fieldsAdd content = replacePattern(content, "('agreements/' | 'agreements1/' | 'agreements2/') ld '/'", "agreements/***/")
| fieldsAdd content = replacePattern(content, "'vins/' ld '/'", "vins/***/")

```

you can make them in a single line of code but then it will be more sensitive to any pattern change

---

<div class="post-metadata">

**Author:** ![Derrick\_1](https://avatars.discourse-cdn.com/v4/letter/d/ecb155/32.png) [@Derrick\_1](https://community.dynatrace.com/u/Derrick_1)\
**Post date:** [July 30, 2026, 3:22pm UTC](https://community.dynatrace.com/t/how-to-replace-certain-part-of-url-in-a-log-content/50806/6 "2026-07-30T15:22:06Z")

</div>

Thank you. No where in their documentation could i find an example of the syntax for multiple patterns in a replace pattern. I much prefer it over multiple nested replace strings.
