# Parsing rules -- occurrence negation

**URL:** <https://community.dynatrace.com/t/parsing-rules-occurrence-negation/42851>\
**Category:** DQL\
**Tags:** dql, log-processing\
**Created:** [November 27, 2023, 2:01pm UTC](https://community.dynatrace.com/t/parsing-rules-occurrence-negation/42851 "2023-11-27T14:01:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![MartinBurgos](https://avatars.discourse-cdn.com/v4/letter/m/958977/32.png) [@MartinBurgos](https://community.dynatrace.com/u/MartinBurgos)\
**Post date:** [November 27, 2023, 2:01pm UTC](https://community.dynatrace.com/t/parsing-rules-occurrence-negation/42851/1 "2023-11-27T14:01:49Z")

</div>

Hi team,

I need a helping hand with the following DQL parsing.

```markup
| PARSE content, "
DATA{1,70000}?
(
('tenantId'|'tenant '|'tenant'|'TenantID'|'TenantId'|'tenantID'|'tenant_id'| 'tenant id'| 'tenant ID'|'Tenant ID'|'Tenant Id')
('\\\\\\\\\\\\\"'|'\\\\\\\\\\\"'|'\\\\\\\\\"'|'\\\\\\\"'|'\\\\\"'|'\\\"'|'\"')? SPACE? [:|=]? SPACE?
('\\\\\\\\\\\\\"'|'\\\\\\\\\\\"'|'\\\\\\\\\"'|'\\\\\\\"'|'\\\\\"'|'\\\"'|'\"')? ([a-zA-Z0-9-_{*}]{32}:tenantID)
('\\\\\\\\\\\\\"'|'\\\\\\\\\\\"'|'\\\\\\\\\"'|'\\\\\\\"'|'\\\\\"'|'\\\"'|'\"')?
)
"

```

I need to fetch all the occurrences I have as tenantId but I should skip&nbsp;\_tenant\_&nbsp;and try to fetch&nbsp; the next thing (i.e. negate underscores before tenant):

This is an example:

```markup
{
  "Label": "messagingListener/processTrigger/processEvent",
  "caller": "generic_subscription.go:411",
  "level": "info",
  "message": "execution doesn't exist in db, proceeding to create it...",
  "periodType": "month",
  "resourceAction": "reload",
  "resourceType": "app",
  "scopemapping": "tenant",
  "spanID": "123412341234",
  "taskId": "123412341234",
  "taskdescription": "v1.app.reload.finished consumption context with tenant, resourceType, resourceAction scope",
  "taskname": "app_v1_reload_finished_with_tenant_resourceType_resourceAction_scope",
  "tenantId": "example-tfEokyGtBk7skpV3-example",
  "timestamp": "2023-11-27T10:00:25.032214397Z",
  "traceID": "km12mkl123mkl"
}

```

The outcome of what I am trying to parse should be “example-tfEokyGtBk7skpV3-example”.

Please note that I can’t parse the content as JSON because I’ll be applying this to other

Could you please help me with it?  
Thanks in advance!

---

<div class="post-metadata">

**Author:** ![Eric\_Yu](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/eric_yu/32/20360_2.png) [@Eric\_Yu](https://community.dynatrace.com/u/Eric_Yu)\
**Post date:** [November 27, 2023, 8:02pm UTC](https://community.dynatrace.com/t/parsing-rules-occurrence-negation/42851/2 "2023-11-27T20:02:24Z")

</div>

If you’re just trying to extract that portion of the payload you can do something like this:

```javascript
parse fieldToParse, "DATA '\"tenantId\": \"' DATA:tenantId '\",' DATA"

```

Example:

 ![Eric_Yu_0-1701115310176.png](https://global.discourse-cdn.com/dynatrace/original/2X/e/ef362194eaaae6925fd4a6b1879e8db3e3ff46a3.png)

Let me know if that helps.

---

<div class="post-metadata">

**Author:** ![MartinBurgos](https://avatars.discourse-cdn.com/v4/letter/m/958977/32.png) [@MartinBurgos](https://community.dynatrace.com/u/MartinBurgos)\
**Post date:** [November 28, 2023, 7:32am UTC](https://community.dynatrace.com/t/parsing-rules-occurrence-negation/42851/3 "2023-11-28T07:32:07Z")

</div>

Thanks Eric but unfortunately it does not apply to my real use case.

I have at least one hundred variations and I have found that whenever I have an underscore (e.g. \_TenantID,\_tenantID,\_tenant, etc) it’ll fetch the wrong string.

Would it be possible to negate the underscore? As the example below to skip \_tenant\_

 ![MartinBurgos_0-1701156664606.png](https://global.discourse-cdn.com/dynatrace/original/2X/5/54b3cea1353d6373c598a02336810164e853d46c.png)

Thanks in advance

---

<div class="post-metadata">

**Author:** ![sinisa\_zubic](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/sinisa_zubic/32/32498_2.png) [@sinisa\_zubic](https://community.dynatrace.com/u/sinisa_zubic)\
**Post date:** [November 28, 2023, 9:31am UTC](https://community.dynatrace.com/t/parsing-rules-occurrence-negation/42851/4 "2023-11-28T09:31:18Z")

</div>

Hi&nbsp;[@MartinBurgos](https://community.dynatrace.com/user/67478)

yes there is a [negative look ahead modifier](https://docs.dynatrace.com/docs/shortlink/dpl-modifiers#lookaround)

does this DPL work for you

```markup
$tenant = '"'('tenantId'|'tenant '|'tenant'|'TenantID'|'TenantID'|'tenant_id'|'tenant id'|'tenant ID'|'Tenant ID'|'Tenant Id') '"'!>>(','|'_'|EOL);
$tenantId = [a-zA-Z0-9-_{*}]{32};
DATA{1,15000} $tenant DATA? '"' $tenantId '"'

```

Best,  
Sini

---

<div class="post-metadata">

**Author:** ![MartinBurgos](https://avatars.discourse-cdn.com/v4/letter/m/958977/32.png) [@MartinBurgos](https://community.dynatrace.com/u/MartinBurgos)\
**Post date:** [December 11, 2023, 2:17pm UTC](https://community.dynatrace.com/t/parsing-rules-occurrence-negation/42851/5 "2023-12-11T14:17:55Z")

</div>

Hi&nbsp;[@sinisa\_zubic](https://community.dynatrace.com/user/38283),

I was OoO, thanks for the help but it unfortunately, I need to maintain the same structure and if I try to add&nbsp; _**!\<\<(‘\_’)**_ , it doesn’t work.

```auto
| PARSE content, "
DATA{1,70000}?
(
('tenantId'|'tenant '|'tenant'|'TenantID'|'TenantId'|'tenantID'|'tenant_id'| 'tenant id'| 'tenant ID'|'Tenant ID'|'Tenant Id')
('\\\\\\\\\\\\\"'|'\\\\\\\\\\\"'|'\\\\\\\\\"'|'\\\\\\\"'|'\\\\\"'|'\\\"'|'\"')? SPACE? [:|=]? SPACE?
('\\\\\\\\\\\\\"'|'\\\\\\\\\\\"'|'\\\\\\\\\"'|'\\\\\\\"'|'\\\\\"'|'\\\"'|'\"')? ([a-zA-Z0-9-_{*}]{32}:tenantID)
('\\\\\\\\\\\\\"'|'\\\\\\\\\\\"'|'\\\\\\\\\"'|'\\\\\\\"'|'\\\\\"'|'\\\"'|'\"')?
)
"

```

To provide you with more context, I need to skip if tenant starts with an underscore like --\> \_tenantID or \_tenant or \_tenant\_Id

I hope this provides you with some clarification and thanks for the help!
