# Logstash Ruby : Find Matching Value From Two Different Array

**URL:** <https://discuss.elastic.co/t/logstash-ruby-find-matching-value-from-two-different-array/276460>\
**Category:** Logstash\
**Created:** [June 20, 2021, 10:01am UTC](https://discuss.elastic.co/t/logstash-ruby-find-matching-value-from-two-different-array/276460 "2021-06-20T10:01:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ankitdevnalkar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ankitdevnalkar/32/46158_2.png) [@ankitdevnalkar](https://discuss.elastic.co/u/ankitdevnalkar)\
**Post date:** [June 20, 2021, 10:01am UTC](https://discuss.elastic.co/t/logstash-ruby-find-matching-value-from-two-different-array/276460/1 "2021-06-20T10:01:36Z")

</div>

I have two different arrays `outputs` and `info.policy.rules` coming in the same log document and I would like to run a ruby loop to find if there is any matching value available for `adderss` field in the array of `outputs` against an array value of `info.policy.rules.condition.address`. If the value is found, I would like to add a new filed `result : matchFound`

outputs array sample :

```auto
"outputs": [
      {
        "wallet": "my_wallet",
        "valueUnitAmount": value,
        "id": "my_id",
        "address": "1234",
        "chain": 0,
        "value": value,
        "isSegwit": false,
        "walletInfo": {
          "walletStorageType": "WARM",
          "displayName": "warm",
          "policy": {
            "thresholdBal": 38,
            "thresholdTX": 20
          },
          "walletId": "my_id",
          "type": "warm"
        },
        {
         "wallet": "my_wallet",
        "valueUnitAmount": value,
        "id": "my_id",
        "address": "12345",
        "chain": 0,
        "value": value,
        "isSegwit": false,
        "walletInfo": {
          "walletStorageType": "hot",
          "displayName": "hot",
          "policy": {
            "thresholdBal": 38,
            "thresholdTX": 20
          }
          "walletId": "my_id",
          "type": "hot"
        },   
      }
    ]

```

info.policy.rules array sample :

```auto
"info": {
      "policy": {
        "rules": [
          {
            "coin": "btc",
            "id": "my_id",
            "condition": {
              "address": "12345",
              "label": "warm",
              "type": "address"
            },
            {
            "coin": "btc",
            "id": "my_id",
            "condition": {
              "address": "12",
              "label": "warm",
              "type": "address"
            },
            {
            "coin": "btc",
            "id": "my_id",
            "condition": {
              "address": "23",
              "label": "warm",
              "type": "address"
            }
            "action": "log",
            "type": "whitelist"
          }
        ]
      }
    }

```

---

<div class="post-metadata">

**Author:** ![ankitdevnalkar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ankitdevnalkar/32/46158_2.png) [@ankitdevnalkar](https://discuss.elastic.co/u/ankitdevnalkar)\
**Post date:** [June 20, 2021, 5:51pm UTC](https://discuss.elastic.co/t/logstash-ruby-find-matching-value-from-two-different-array/276460/2 "2021-06-20T17:51:30Z")

</div>

can anyone help?

---

<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:** [July 18, 2021, 5:52pm UTC](https://discuss.elastic.co/t/logstash-ruby-find-matching-value-from-two-different-array/276460/3 "2021-07-18T17:52:20Z")

</div>

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